10

While reading through the kernel documentation on ramdisk in ramfs-rootfs-initramfs.txt i was having a doubt like the ramdisk explained there is same as the initrd features described in the post at the-difference-between-initrd-and-initramfs.

Could someone clarify me on this??

And if it is the same, i read that there are many disadvantages for it, but still in my fedora PC, i see

initrd-2.6.29.4-167.fc11.i686.PAE.img

in my boot folder. Is it different from the initrd mentioned above??

UPDATE_EDIT :
In of the articles I even saw a command like
# update-initramfs -u all
update-initramfs: Generating /boot/initrd.img-2.6.18-5-amd64

So how is this initramfs linked to initrd.img ?

Navaneeth Sen
  • 9,369
  • 17
  • 58
  • 65

1 Answers1

13

A ramdisk is a set of blocks that gets copied to an allocated chunk of memory, then treated as a block device. A normal filesystem is created on the ramdisk. The initrd (initial ramdisk) is a ramdisk that is mounted during bootup.

The initramfs is something different. It's a cpio archive of files that is loaded during bootup. The kernel loads the contents into a virtual filesystem it calls rootfs. Unlike a ramdisk, deleting files directly frees memory, and there's no extra filesystem and block layer involved.

Both methods result in files being available to the kernel at boot time before any devices have been loaded, and so in practice you can achieve similar results with both. Older systems use initrd (it was created before initramfs) but modern systems should all be using initramfs. You may still see the word initrd in reference to something that is really an initramfs; it's just naming for compatibility's sake.

ephemient
  • 15,640
  • 5
  • 49
  • 39
  • Thanks ephemient, I would like to know what you meant by "ramdisk is a set of blocks". How is this treated as a block device once it has been copied? – Navaneeth Sen Dec 08 '10 at 06:35
  • @Sen: There is a `rd` module (later renamed to `brd`, and may be built into the kernel), which allocates a bunch of memory, creates a block device, and maps requests to/from the block device into read/writes in memory. – ephemient Dec 08 '10 at 06:40
  • Can you give me some more idea about this rd / brd module? – Navaneeth Sen Dec 08 '10 at 07:10
  • i would also like to know that if i have created a ramdisk image by following these steps : mke2fs -vm0 /dev/ram 4096; mount -t ext2 /dev/ram /mnt; cd /mnt; cp /bin, /sbin, /etc, /dev ... files in mnt; cd ../; umount /mnt; dd if=/dev/ram bs=1k count=4096 of=ext2ramdisk; How will i boot this ext2ramdisk in my device? Just loading it to the ram, will that work? – Navaneeth Sen Dec 08 '10 at 07:13
  • @Sen: The bootloader is responsible for loading both the kernel and the init(rd|ramfs) into RAM; see your bootloader's documentation. But even if you're building it by hand (why??) you should use `find /bin /sbin /etc /dev ... | cpio -o | gzip -c > initramfs` instead of initrd. – ephemient Dec 08 '10 at 16:18