Mount Live CD in User Session

I always wondered if it was possible to copy the contents of the Ubuntu Linux live cd filesystem without booting in it. A quick search and some playing with the system revealed that it is possible to do so using the following hack.

Requirements for this hack:

1> Ubuntu / Kubuntu Live CD

The CD contains the file system in SquashFS format. I found this by the fact that the file ‘cd/casper/filesystem.squashfs’ is the heaviest file on the CD (about 683 Mb on Ubuntu Hardy Heron AMD 64 Live CD). SquashFS is a highly compressed read-only filesystem for Linux. It uses zlib compression to compress both files, inodes and directories.

2> About 2 Gb hard disk space.

As we’ll be copying the contents of the Live CD as well as the filesystem onto the HD.

3> squashfs-tools

This is a set of tools required for mounting this file system in the User Session. More information about this package can be found here.

>> You can install it by simply typing the following in the terminal:

$ sudo apt-get install squashfs-tools

>> Or open Synaptic Package Manager, and search for ’squashfs’. You should find ’squashfs-tools’ in the list. Install it using synaptic.

Once the tools are installed, we go back to the terminal. We’ll be creating 2 temporary directories named ’sfstemp’ and ’sfsmount’ using the following commands:

$ mkdir ~/sfstemp$ mkdir ~/sfsmount

Copy the entire contents from the Live CD to the ’sfstemp’ directory.

Now we’ll load the squashfs-tools and mount the filesystem onto the other directory ’sfsmount’:

$ sudo modprobe squashfs

$ sudo mount -t squashfs -o loop sfstemp/casper/filesystem.squashfs ~/sfsmount

This will mount the Live CD filesystem into the folder ’sfsmoun’t. You can open the folder using any file manager (eg. nautilus, konqueror, dolphin) and view its contents. These contents will be same as the contents of the Live CD File System.

Cool, Now we have the filesystem on our HD. But what can we do with it? This is very useful while installing applications from the Live CD. Check out this post for more info.

Thank you for reading this post. Your comments, pingbacks, ratings, reviews and any other contributions are greatly appreciated.

Leave a Reply