You are on page 1of 2

What is Ramdisk ? Ramdisk Demystified From The Perspective of Embedded System by cawan (cawan[at]ieee.org, chuiyewleong[at]hotmail.

com) on 10/11/2012 From embedded system point of view, ramdisk is an image file to be copied into a specific logical address in a flash chip. So, when the system boot up, the bootloader can duplicate the portion of flash space with the content of image file into RAM. From that onwards, the kernel portion will be decompressed on the fly in RAM and being executed once the decompression process completed. On the other hand, the file system portion will stay in RAM as is where is basis. In most of the times, it is represented in rootfs format, which is a special instance of ramfs or tmpfs. Refer to the following link for further description about rootfs, ramfs, and tmpfs. http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt Well, the file system is already in the RAM now, and it is in the format of rootfs. So, what the kernel need to do now is to mount onto it and start to make use of it. Let us verify it. tango3[~]# mount rootfs on / type rootfs (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw) tmpfs on /tmp type tmpfs (rw) /dev/sigmblockg on /app type squashfs (ro) /dev/sigmblockh on /run type ext3 (rw,data=ordered) tango3[~]# Nice, the file system is mounted to root in the format of rootfs, with read and write (rw) permission. However, any content being updated or altered is volatile. In other words, any altered file in rootfs will be reverted to original state after reboot. Yes, it should be, because the everything is in the RAM, which is volatile. Let verify. tango3[~]# cat /etc/passwd root:x:0:0:root:/root:/bin/sh daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:100:sync:/bin:/bin/sync mail:x:8:8:mail:/var/spool/mail:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh operator:x:37:37:Operator:/var:/bin/sh sshd:x:103:99:Operator:/var:/bin/sh nobody:x:99:99:nobody:/home:/bin/sh default:x:1000:1000:Default non-root user:/home/default:/bin/sh tango3[~]# echo cawan > /etc/passwd tango3[~]# cat /etc/passwd cawan tango3[~]# We reboot the system now. After reboot, we will check the content of /etc/passwd again. tango3[~]# cat /etc/passwd

root:x:0:0:root:/root:/bin/sh daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:100:sync:/bin:/bin/sync mail:x:8:8:mail:/var/spool/mail:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh operator:x:37:37:Operator:/var:/bin/sh sshd:x:103:99:Operator:/var:/bin/sh nobody:x:99:99:nobody:/home:/bin/sh default:x:1000:1000:Default non-root user:/home/default:/bin/sh tango3[~]# Yes, it has been reverted. In additional, as side topic, the partition /dev/sigmblockg of flash chip has been mounted onto /app in the format of squashfs, with read only (ro) permission, where the squashfs itself is a read only file system with high compression rate. Besides, the partition /dev/sigmblockh is also in flash chip. However, it is mounted on /run in the format of ext3, with read and write permission. As a file system format with read and write support, the ext3 partition allows data to be altered or modified and keep in intact after reboot. An important point to take note here, the so called read only file system of squashfs on /app only means the file system itself is read only, but not the case of partition /dev/sigmblockg. From the angle of device file, the partition /dev/sigmblockg is still free to write by any appropriate shell command. Let's verify. tango3[~]# echo cawan > /app/cawan -sh: /app/cawan: Read-only file system tango3[~]# Yes, /app is really a read on squashfs file system. How about /run ? tango3[~]# echo cawan > /run/cawan tango3[~]# cat /run/cawan cawan tango3[~]# As expected, /run is writable. Let's reboot the system now, the /run/cawan should be still there after reboot. tango3[~]# cat /run/cawan cawan tango3[~]# Nice, the /run/cawan is still there as expected. So, the concept of ramdisk should be clear now.