Categories

Categories

Archives

Using cloop in FreeBSD

There are lots of Linux distributions that have a ‘Live CD’ that allow you to rescue your system or try before you bu… install.

Let’s take a look at Knoppix. It is one of the most popular Live CD’s. In the CD structure of Knoppix there is a file that contains the root file system (rootfs). That file is a cloop image file. Each block is compressed individually which allows decompression on the fly or at a specific point in the file.

This allows a rootfs to be about 1 GB in actual size but compressed it will fit into about 700 MB.

When a system boots from this CD [image], a kernel loads the cloop device and then opens the rootfs cloop file. Viola! The root file system is loaded into a ramdisk and is accessible as if it was an installed distribution.

This is great for Linux – not so great for FreeBSD. There are many Linux only or FreeBSD only file types and differences that make using the two systems on the same network very difficult.

I prefer FreeBSD because of its sheer solidness. It’s like comparing a car that uses a gasoline engine (Linux) versus a diesel engine (BSD). Linux is the new hot-ness; fast, sleek, portable, adaptable, pump-n-go. FreeBSD is like the 80s era of cars; cast aside because they aren’t sexy, requires the right glow plugs, needs patience, but it will run on any thing that has enough compression and it will go forever.

By default, FreeBSD lacks the ability to mount cloop images. Luckily, Klaus Knopper wrote a FreeBSD module that allows mounting of a cloop image. This allows someone that uses FreeBSD to modify a cloop image with out needing a Linux box.

To install the cloop module for FreeBSD, build and install the cloop-utils.

# cd /usr/ports/sysutils/cloop-utils/
# make && make install

Now to mount the cloop image.

In this example I am using Damn Small Linux tftpboot.

# unzip dsl-1.5-tftpboot.zip

Unzips the PXE Damn Small Linux release

# gunzip minirt24.gz

Gunzips the root file system

# mdconfig –a –t vnode –f minirt24

Creates a virtual device from the minirt24

# mount –t ext2fs /dev/md0 /mnt/dsl

Mounts the ext2 file system inside the minirt24 file that was created from mdconfig as /dev/md0

#kldload geom_uzip

Loads the cloop device so FreeBSD can rw cloop files

# mdconfig –a –t vnode –f /mnt/dsl/cdrom/KNOPPIX/KNOPPIX

Creates a virtual device from the KNOPIX root file system inside minirt24

# mount –t cd9660 /dev/md1.uzip /dev/dslcdrom

Mounts the cloop device from md1 using the geom._uzip device

Now you should have access to the cloop ‘KNOPPIX’ root file system in /mnt/dslcdrom. Follow the steps in reverse to close and re-zip the files I my case, it allows me to update any part of the rootfs from the PXE server which is not Linux.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.