Hi Folks,

   Given recent discussions on compression in the ramdisk to
reduce runtime memory hogging, I was toying with the idea of
adding lofi-style compression to the ramdisk module with the
addition of copy-on-write to be able to support writes unlike
compressed lofi.

I have now have a working ramdisk module that supports
lofi-style compression. It is capable of doing a per-segment
copy-on-write. That is if a write happens, the affected segment
is uncompressed and written to a new allocated memory block.
All subsequent access to the same segment happens from that
memory block.

The modified module binary, source code and diffs are in this
tarball:
http://www.belenix.org/binfiles/cramdisk.tar.gz
You will notice that most of the code is copied from lofi. These
changes are against B104.

The following steps are needed in order to use this:
- Extract the tar and copy all the binaries to their respective
  places (usr/sbin/ramdiskadm, kernel/drv/ramdisk,
  kernel/drv/amd64/ramdisk)

- Now uncompress an existing livecd bootroot image and lofi compress
  it:
  gunzip x86.microroot.gz
  lofiadm -C gzip-9 -s 64k x86.microroot

- Create a ramdisk slightly larger than the livecd bootroot size
  ramdiskadm -a test1 <size>
  /dev/ramdisk/test1
- Dump the x86.microroot into the ramdisk
  dd if=x86.microroo of=/dev/ramdisk/test1

- Invoke a new ioctl to tell the ramdisk driver to re-initialize the ramdisk:
  ramdiskadm -s /dev/rramdisk/test1
  (rramdisk points to the raw device)

- Now mount the filesystem read-write:
  mount -F ufs /dev/ramdisk/test1 /mnt
  and play around.

Now this is just half the story. The ramdisk module is not loaded till
much later during boot when the kernel figures out that the boot
ramdisk is it's root device. The boot code before that accesses the
ramdisk via a minimal ramdisk reading support in krtld/bootrd.c

I have made changes in bootrd.c and also added a few lines into
boot time minimal filesystem support in usr/src/common/fs.

These changes are necessary for a compressed ramdisk approach
to work. These get compiled into platform/i86pc/kernel/unix. So
I have built packages and need to build a livecd image to test the
stuff. This will take a while.

Using a compressed ramdisk provides greater space savings since
both data and filesystem metada are compressed. Since the
compression is at the block device level it is transparent to
filesystems.

Regards,
Moinak.
-- 
================================
http://www.belenix.org/
http://moinakg.wordpress.com/

Reply via email to