SlideShare a Scribd company logo
1 of 4
Download to read offline
Initrd
Creation of Initrd:
To create an (initially empty) initrd use the following steps:
note: you can change the count to your required file system size. e.g: count = 16384
you will get a 16MB ramdisk.
$ mkdir Ramdisk
$ cd Ramdisk
$ sudo dd if = /dev/zero of=/dev/ram0 bs=1k count=16834
$ sudo mke2fs -vm0 /dev/ram0 16384
$ sudo tune2fs -c 0 /dev/ram0
$ sudo dd if=/dev/ram0 bs=1k count=16384 | gzip -v9 > ramdisk.gz
$ ls
ramdisk.gz
Now we have a (empty) gzipped ramdisk image with (extracted) size of 16384.
Filling Initrd:
To fill empty ramdisk created above with all files needed for ramdisk, mount the
image and fill it. Content would be e.g: Busybox and/or other applications and/or
libraries.
$ sudo mkdir mnt
$ gunzip ramdisk.gz
$ ls
ramdisk
$ sudo mount -o loop ramdisk mnt/
$ ls
mnt ramdisk
Now create below files in 'mnt' directory:
bin, dev, etc, lib, proc, root , sbin, sys, appmount, tmp, usr, usr/bin, usr/sbin.
After creating files in 'mnt' directory, copy the busybox executable and init file in
mnt/bin/.
Note : contents of sd card, creation of busybox
executable and init file is described later in this
document.
1
Initrd
$ cd mnt
$ sudo mkdir bin
$ sudo mkdir dev
$ sudo mkdir etc
$ sudo mkdir lib
$ sudo mkdir proc
$ sudo mkdir root
$ sudo mkdir sbin
$ sudo mkdir sys
$ sudo mkdir appmount
$ sudo mkdir tmp
$ sudo mkdir usr
$ sudo mkdir -p usr/bin
$ sudo mkdir -p usr/sbin
$ ls
appmount bin dev etc lib proc root sbin sys tmp usr
Now copy the busybox executable and init file in bin,
$ cp <busybox directory path>/busybox bin/busybox
$ cp <init file created directory path>/init bin/init
$ cd bin
$ ls
init busybox
$ cd ..
$ sudo umount mnt
$ gzip -v9 ramdisk
$ ls
mnt ramdisk.gz
Now copy this ramdisk.gz to sd card in boot partition,
$ cp ramdisk.gz /media/boot
Using this ramdisk.gz, we are going to boot beaglebone black through sd card.
2
Initrd
Booting BBB using Ramdisk:
Insert micro SD card, by holding the user boot button power up the board, Press the
space bar for booting u-boot.
U­boot# setenv bootargs console=tty00, 115200n8 root=/dev/ram0 rw
ramdisk_size=16384 initrd=0x81000000, 16M rootfstype=ext2
u­boot# fatload mmc 0:1 0x81000000 ramdisk.gz
u­boot# fatload mmc 0:1 0x80200000 uImage
u­boot# fatload mmc 0:1 0x82000000 am335x-boneblack.dtb
u­boot# bootm 0x80200000 – 0x82000000
kernel will be successfully loaded and kernel mounts the filesystem(busybox) you
will get terminal with symbol like this ' /# '
/# ls
appmout etc sbin usr
bin lib proc sys
dev linuxrc root tmp
Contents of SD card:
For booting BBB using Ramdisk, it should contains following contents:
# ramdisk.gz (use created ramdisk.gz)
# uImage
# am335x-boneblack.dtb
For Kernel image (uImage) and am335x-boneblack.dtb:
$ git clone https://github.com/beagleboard/linux.git
$ cd linux
$ git remote -v
origin https://github.com/beagleboard/linux.git (fetch)
origin https://github.com/beagleboard/linux.git (push)
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bb.org_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage dtbs
LOADADDR=0x80008000
3
Initrd
Creation of Busybox executable:
First download busybox code from, https://busybox.net/downloads/
Cross compile busybox for ARM platform
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
Enable the following features:
Busybox settings ---> Build Options --->
[*] Build Busybox as a static binary(no shared libs).
() cross compiler prefix option --> enter “arm-linux-gnueabi-”.
Save and exit configuration.
Building busybox by entering the following command:
$ make
You will get a busybox binary, which is ARM executable and statically linked.
Creation of init file:
Inside ramdisk directory, create a file with init and give executable permissions to it,
and copy the following contents:
#!/bin/busybox sh
/bin/busybox ­­install ­s
mount ­t proc none /proc
mount ­t sysfs none /sys
echo /sbin/mdev > /proc/sys/kernel/hotplug
/sbin/mdev ­s
mknod /dev/ttyO0 c 5 0
mount ­t ubifs ubi0:rootfs /appmount
exec /bin/sh
$ chmod 777 init
The busybox executable and init file should be placed inside “bin” which is present in
“mnt”.
4

More Related Content

What's hot

Forcefully unmount a linux disk partition
Forcefully unmount a linux disk partitionForcefully unmount a linux disk partition
Forcefully unmount a linux disk partitionMuqthiyar Pasha
 
How to mount ntfs in linux
How to mount ntfs in linuxHow to mount ntfs in linux
How to mount ntfs in linuxsiraza5
 
How to Diagnose Problems Quickly on Linux Servers
How to Diagnose Problems Quickly on Linux ServersHow to Diagnose Problems Quickly on Linux Servers
How to Diagnose Problems Quickly on Linux ServersRichard Cunningham
 
Hello, Worldまで3ヶ月 Golangでファミコンエミュレータ実装 #gocon fukuoka 2019
Hello, Worldまで3ヶ月 Golangでファミコンエミュレータ実装 #gocon fukuoka 2019Hello, Worldまで3ヶ月 Golangでファミコンエミュレータ実装 #gocon fukuoka 2019
Hello, Worldまで3ヶ月 Golangでファミコンエミュレータ実装 #gocon fukuoka 2019ichikaway
 
Recipe of a linux Live CD (archived)
Recipe of a linux Live CD (archived)Recipe of a linux Live CD (archived)
Recipe of a linux Live CD (archived)Bud Siddhisena
 
ゼロから始めるファミコンエミュレータ生活 PHPerKaigi2019
ゼロから始めるファミコンエミュレータ生活 PHPerKaigi2019ゼロから始めるファミコンエミュレータ生活 PHPerKaigi2019
ゼロから始めるファミコンエミュレータ生活 PHPerKaigi2019ichikaway
 
Linux lv ms step by step
Linux lv ms step by stepLinux lv ms step by step
Linux lv ms step by stepsudakarman
 
Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)Sian Lerk Lau
 
Disk suit 4 setup and installation
Disk suit 4 setup and installationDisk suit 4 setup and installation
Disk suit 4 setup and installationppratish
 
5508183 (patavee)csc100
5508183 (patavee)csc1005508183 (patavee)csc100
5508183 (patavee)csc100maximic1
 
How to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by IvanHow to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by IvanIvan Silva
 

What's hot (19)

Mac os x mount ntfs
Mac os x mount ntfsMac os x mount ntfs
Mac os x mount ntfs
 
Forcefully unmount a linux disk partition
Forcefully unmount a linux disk partitionForcefully unmount a linux disk partition
Forcefully unmount a linux disk partition
 
Log
LogLog
Log
 
2.Accessing the Pi
2.Accessing the Pi2.Accessing the Pi
2.Accessing the Pi
 
Fedora Linux
Fedora LinuxFedora Linux
Fedora Linux
 
How to mount ntfs in linux
How to mount ntfs in linuxHow to mount ntfs in linux
How to mount ntfs in linux
 
How to Diagnose Problems Quickly on Linux Servers
How to Diagnose Problems Quickly on Linux ServersHow to Diagnose Problems Quickly on Linux Servers
How to Diagnose Problems Quickly on Linux Servers
 
Booy Up
Booy UpBooy Up
Booy Up
 
Hello, Worldまで3ヶ月 Golangでファミコンエミュレータ実装 #gocon fukuoka 2019
Hello, Worldまで3ヶ月 Golangでファミコンエミュレータ実装 #gocon fukuoka 2019Hello, Worldまで3ヶ月 Golangでファミコンエミュレータ実装 #gocon fukuoka 2019
Hello, Worldまで3ヶ月 Golangでファミコンエミュレータ実装 #gocon fukuoka 2019
 
Recipe of a linux Live CD (archived)
Recipe of a linux Live CD (archived)Recipe of a linux Live CD (archived)
Recipe of a linux Live CD (archived)
 
ゼロから始めるファミコンエミュレータ生活 PHPerKaigi2019
ゼロから始めるファミコンエミュレータ生活 PHPerKaigi2019ゼロから始めるファミコンエミュレータ生活 PHPerKaigi2019
ゼロから始めるファミコンエミュレータ生活 PHPerKaigi2019
 
Linux lv ms step by step
Linux lv ms step by stepLinux lv ms step by step
Linux lv ms step by step
 
Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)
 
Disk suit 4 setup and installation
Disk suit 4 setup and installationDisk suit 4 setup and installation
Disk suit 4 setup and installation
 
5508183 (patavee)csc100
5508183 (patavee)csc1005508183 (patavee)csc100
5508183 (patavee)csc100
 
Parallel computing
Parallel computingParallel computing
Parallel computing
 
Log
LogLog
Log
 
How to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by IvanHow to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by Ivan
 
Barios crosober
Barios crosoberBarios crosober
Barios crosober
 

Similar to Ramdisk

Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_BootingRashila Rr
 
Setup sd card for ubuntu on pandaboard
Setup sd card for ubuntu on pandaboardSetup sd card for ubuntu on pandaboard
Setup sd card for ubuntu on pandaboardSagar Patel
 
Connect dell equallogic storage to linux instance
Connect dell equallogic storage to linux instanceConnect dell equallogic storage to linux instance
Connect dell equallogic storage to linux instanceSaeed Siddik
 
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014EneaSoftware
 
建構嵌入式Linux系統於SD Card
建構嵌入式Linux系統於SD Card建構嵌入式Linux系統於SD Card
建構嵌入式Linux系統於SD Card艾鍗科技
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry PiLloydMoore
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Macpaul Lin
 
First Responder Course - Session 10 - Static Evidence Collection [2004]
First Responder Course - Session 10 - Static Evidence Collection [2004]First Responder Course - Session 10 - Static Evidence Collection [2004]
First Responder Course - Session 10 - Static Evidence Collection [2004]Phil Huggins FBCS CITP
 
Andresen 8 21 02
Andresen 8 21 02Andresen 8 21 02
Andresen 8 21 02FNian
 
Network external hard drive
Network external hard driveNetwork external hard drive
Network external hard drivessuser1eca7d
 

Similar to Ramdisk (20)

RamDisk
RamDiskRamDisk
RamDisk
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
Real time systems
Real time systemsReal time systems
Real time systems
 
Setup sd card for ubuntu on pandaboard
Setup sd card for ubuntu on pandaboardSetup sd card for ubuntu on pandaboard
Setup sd card for ubuntu on pandaboard
 
Connect dell equallogic storage to linux instance
Connect dell equallogic storage to linux instanceConnect dell equallogic storage to linux instance
Connect dell equallogic storage to linux instance
 
Xen time machine
Xen time machineXen time machine
Xen time machine
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
 
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
 
建構嵌入式Linux系統於SD Card
建構嵌入式Linux系統於SD Card建構嵌入式Linux系統於SD Card
建構嵌入式Linux系統於SD Card
 
How to build and load linux to embedded system
How to build and load linux to embedded systemHow to build and load linux to embedded system
How to build and load linux to embedded system
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry Pi
 
Tinydns and dnscache
Tinydns and dnscacheTinydns and dnscache
Tinydns and dnscache
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
 
First Responder Course - Session 10 - Static Evidence Collection [2004]
First Responder Course - Session 10 - Static Evidence Collection [2004]First Responder Course - Session 10 - Static Evidence Collection [2004]
First Responder Course - Session 10 - Static Evidence Collection [2004]
 
Andresen 8 21 02
Andresen 8 21 02Andresen 8 21 02
Andresen 8 21 02
 
Metasploitable
MetasploitableMetasploitable
Metasploitable
 
UNIT 2 P5
UNIT 2 P5UNIT 2 P5
UNIT 2 P5
 
Basic Linux kernel
Basic Linux kernelBasic Linux kernel
Basic Linux kernel
 
Putting some "logic" in LVM.
Putting some "logic" in LVM.Putting some "logic" in LVM.
Putting some "logic" in LVM.
 
Network external hard drive
Network external hard driveNetwork external hard drive
Network external hard drive
 

Ramdisk

  • 1. Initrd Creation of Initrd: To create an (initially empty) initrd use the following steps: note: you can change the count to your required file system size. e.g: count = 16384 you will get a 16MB ramdisk. $ mkdir Ramdisk $ cd Ramdisk $ sudo dd if = /dev/zero of=/dev/ram0 bs=1k count=16834 $ sudo mke2fs -vm0 /dev/ram0 16384 $ sudo tune2fs -c 0 /dev/ram0 $ sudo dd if=/dev/ram0 bs=1k count=16384 | gzip -v9 > ramdisk.gz $ ls ramdisk.gz Now we have a (empty) gzipped ramdisk image with (extracted) size of 16384. Filling Initrd: To fill empty ramdisk created above with all files needed for ramdisk, mount the image and fill it. Content would be e.g: Busybox and/or other applications and/or libraries. $ sudo mkdir mnt $ gunzip ramdisk.gz $ ls ramdisk $ sudo mount -o loop ramdisk mnt/ $ ls mnt ramdisk Now create below files in 'mnt' directory: bin, dev, etc, lib, proc, root , sbin, sys, appmount, tmp, usr, usr/bin, usr/sbin. After creating files in 'mnt' directory, copy the busybox executable and init file in mnt/bin/. Note : contents of sd card, creation of busybox executable and init file is described later in this document. 1
  • 2. Initrd $ cd mnt $ sudo mkdir bin $ sudo mkdir dev $ sudo mkdir etc $ sudo mkdir lib $ sudo mkdir proc $ sudo mkdir root $ sudo mkdir sbin $ sudo mkdir sys $ sudo mkdir appmount $ sudo mkdir tmp $ sudo mkdir usr $ sudo mkdir -p usr/bin $ sudo mkdir -p usr/sbin $ ls appmount bin dev etc lib proc root sbin sys tmp usr Now copy the busybox executable and init file in bin, $ cp <busybox directory path>/busybox bin/busybox $ cp <init file created directory path>/init bin/init $ cd bin $ ls init busybox $ cd .. $ sudo umount mnt $ gzip -v9 ramdisk $ ls mnt ramdisk.gz Now copy this ramdisk.gz to sd card in boot partition, $ cp ramdisk.gz /media/boot Using this ramdisk.gz, we are going to boot beaglebone black through sd card. 2
  • 3. Initrd Booting BBB using Ramdisk: Insert micro SD card, by holding the user boot button power up the board, Press the space bar for booting u-boot. U­boot# setenv bootargs console=tty00, 115200n8 root=/dev/ram0 rw ramdisk_size=16384 initrd=0x81000000, 16M rootfstype=ext2 u­boot# fatload mmc 0:1 0x81000000 ramdisk.gz u­boot# fatload mmc 0:1 0x80200000 uImage u­boot# fatload mmc 0:1 0x82000000 am335x-boneblack.dtb u­boot# bootm 0x80200000 – 0x82000000 kernel will be successfully loaded and kernel mounts the filesystem(busybox) you will get terminal with symbol like this ' /# ' /# ls appmout etc sbin usr bin lib proc sys dev linuxrc root tmp Contents of SD card: For booting BBB using Ramdisk, it should contains following contents: # ramdisk.gz (use created ramdisk.gz) # uImage # am335x-boneblack.dtb For Kernel image (uImage) and am335x-boneblack.dtb: $ git clone https://github.com/beagleboard/linux.git $ cd linux $ git remote -v origin https://github.com/beagleboard/linux.git (fetch) origin https://github.com/beagleboard/linux.git (push) $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bb.org_defconfig $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage dtbs LOADADDR=0x80008000 3
  • 4. Initrd Creation of Busybox executable: First download busybox code from, https://busybox.net/downloads/ Cross compile busybox for ARM platform $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig Enable the following features: Busybox settings ---> Build Options ---> [*] Build Busybox as a static binary(no shared libs). () cross compiler prefix option --> enter “arm-linux-gnueabi-”. Save and exit configuration. Building busybox by entering the following command: $ make You will get a busybox binary, which is ARM executable and statically linked. Creation of init file: Inside ramdisk directory, create a file with init and give executable permissions to it, and copy the following contents: #!/bin/busybox sh /bin/busybox ­­install ­s mount ­t proc none /proc mount ­t sysfs none /sys echo /sbin/mdev > /proc/sys/kernel/hotplug /sbin/mdev ­s mknod /dev/ttyO0 c 5 0 mount ­t ubifs ubi0:rootfs /appmount exec /bin/sh $ chmod 777 init The busybox executable and init file should be placed inside “bin” which is present in “mnt”. 4