On Sat, Dec 22, 2001 at 09:57:23AM -0000, Pichai Raghavan wrote: > When we look at the ramdisk implementation(rd.c) we see > that all ramdisk buffers are made immune against buffer > cache flushing; this means that they will be alive as > long as kernel is alive. Even on doing a close of > ramdisk device these buffers are not destroyed. Only place they are destroyed are when ramdisk is made a > module and module is removed; but since we do not want > ramdisk as module this does not work for us. > > Why does close of ramdisk not invalidate all the > buffers? Suppose you want to build a mini root filesystem for an embedded linux system: mke2fs /dev/ram0 mount -t ext2 /dev/ram0 /mnt [populate /mnt as a mini root filesystem with busybox, tinylogin, etc] umount /dev/ram0 dd if=/dev/ram0 of=rootfs bs=1k gzip -9 rootfs Now guess what happens when the ramdisk was destroyed after the umount... > WHy is the special treatment given only when > ramdisk is made as a module? Because it is good (no, *necessary*) practice that a module frees all memory it allocated. If you want to free the memory of a ramdisk, there is an ioctl() for that: int fd; if((fd = open("/dev/ram", O_RDWR)) < 0) { perror("open"); exit(-1); } ioctl(fd, BLKFLSBUF); close(fd); Erik -- J.A.K. (Erik) Mouw, Information and Communication Theory Group, Faculty of Information Technology and Systems, Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2783635 Fax: +31-15-2781843 Email: J.A.K.Mouw@its.tudelft.nl WWW: http://www-ict.its.tudelft.nl/~erik/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ IRC Channel: irc.openprojects.net / #kernelnewbies Web Page: http://www.kernelnewbies.org/