[BusyBox] ramdisk howto

Simon Poole simon.armlinux at themalago.net
Tue Sep 28 09:23:47 UTC 2004


Joshua Jackson wrote:
>>--- Steve Iribarne <steve.iribarne at dilithiumnetworks.com> wrote:
>>
>>>Don't use ext2 file system with flash.  Use ext3 and mount it
>>>with sync
>>>option.  It will save your flash from getting corrupted.
>>>
>>>-stv
> 
> Keep in mind that ext3 will chew up a default of 8MB of your flash for the 
> journal. If you are using really little flash drives, this can become a 
> problem.
> 

This does not need to be the case.  man mke2fs (I'm using v1.34). 
Minimum journal size is 1MB.

Note that nowadays mke2fs seems to be very good at working out sensible 
defaults for the journal based on your partition size.  E.g. I use the 
following to create an ext3 partition on an 8MB CF partition, with no 
problems:

mke2fs -j -m 0 /dev/sda1

I actually even use the same command on a 2MB partition used for my 
sysconfig directory, with no issues.  Granted, half the space is used 
for a journal, but I benefit from the improved reliability.

The other advantage of ext3 is a vastly quicker fsck, so a much faster 
boot time.

Obviously you have to weigh up your disk space requirements against the 
journal overhead.

> With my commercial firewall solution, I use ext2 on the flash drive and only 
> mount it in read-write when a configuration change needs to be stored to the 
> device. This is a similiar technique to that used in a lot of embedded 
> devices... as long as you don't cut power during a disk write, you should be 
> fine.

This is a good technique. ext3 improves it further.

> Another trick I use with both Coyote Linux and Wolverine is to use a ramdrive 
> type of tmpfs. This creates a ramdrive that is automatically exanded and 
> collapsed as storage space is used and freed. Coyote Linux uses the 
> initrd-dyn kernel patch (which allows the initrd to be stored in a .tgz and 
> decompressed directly to tmpfs during boot) whereas Wolverine uses a tiny 
> (2MB) initrd which bootstraps the rest of the system which is decompresses 
> from a .tgz into a tmpfs ramdrive. With Wolverine the system does a pivot 
> root to switch to the tmpfs ramdrive and then de-allocates the initrd.
> 
> While this all seems like a lot of work, it allows for a ramdrive 
> configuration that only uses slightly more RAM than is needed to hold the 
> files. I've managed to pack a busybox based system with a full glibc, apache 
> + php (for web administration), IPSEC, PTPP, UPnP, graphical network statics, 
> SNMP, DynDNS, and various other goodies in a 14Mb tmpfs ramdrive.

Nice trick!

--
Simon Poole
www.appliancestudio.com



More information about the busybox mailing list