How to create ramdisk file

From HyperSecurity Wiki
Jump to: navigation, search

Create the file. Replace filesize with 1024xsize:

dd if=/dev/zero of=initrdfs bs=1k count=filesize

Make a file system:

mke2fs -N 1024 initrdfs

Create a mount directory as root:

mkdir /mnt/initrdfs

Mount filesystem as root:

mount -o loop initrdfs /mnt/initrdfs

Copy needed files to /mnt/initrdfs

Umount it and compress:

umount /mnt/initrdfs
gzip -9c initrdfs > initrd.img

Now you have a functional ramdisk.

Source:

http://lists.busybox.net/pipermail/busybox/2004-September/046827.html

http://www.vanemery.com/Linux/Ramdisk/ramdisk.html