Live iso(distro) without burning & partitioning

Posted in Linux, Open Source, shell scripts by sandaruwan on June 23rd, 2008

“A picture is worth a thousand words” - how about a live experience? If you digg around the internet a little bit, you’ll find hundred of distros lying around. Just like the distro’s site, explains why they are unique, and provides screenshots, most of those comes with a live CD. You’ll get a nice iso image, burn it, run it, and install it if you like.

But it’s annoying to burn a CD for each distro you are going to try. One option is to use a USB drive. Unfortunately, my USB flash drive is USB1.0 but my motherboard only allows me to boot from USB2.0 devices. Another options is to copy the files into a new partition, and install grub/syslinux on that partition - but It’s not a good idea to mess around with partitions.

After experimenting a little bit with the ISOs and grub configuration, I manage to boot the distro, from the file resides in a sub directory of root.

Note : I used following commands in Ubuntu 8.10 - the file locations might be different based on your distribution.

Puppy Linux

Puppy Linux

Puppy linux is a light weighted, very small distro, yet contains most of the important applications for the daily use. In my opinion, this is a nicely designed great distro. My network card and video card worked without giving any trouble, but the sound card failed.

This distro is specially designed aiming towards portable users, who will run the distro in either a USB or a CD. Puppy linux uses squashfs compressed files to keep it’s root file system, and the init scripts are searching for these files in all hard drives, cdroms, and usb drives. So the installation is really easy.

1. Download the image, and mount it to a directory.

sudo mount -o loop puppy-linux.iso /media/cdrom

2. Create a directory in your root partition and copy the files from iso.

sudo mkdir /puppy
sudo cp -r /media/cdrom/* /puppy/

3. Modify your grub config file(/boot/grub/menu.lst) pointing to the puppy kernel and initrd file. Here is the menu entry I added, you’ll have to change the root according to your disk configuration.

title		Puppy Linux
root		(hd0,0)
kernel		/puppy/vmlinuz
initrd		/puppy/initrd.gz
quiet

That’s it - you can reboot the computer, select Puppy Linux from grub and boot.

Good OS - gOS

gOS gOS

gOS is a distribution based on ubuntu designed for web 2.0 internet users (Latest version specially aims toward myspace users). I can’t really see a practicle advantage of using gOS, despite the fact that theming and dock is superb. Other than that, it’s just firefox bookmarks on desktop(dock).

The gOS root file system is also packed in a squashfs file, but the init scripts are different. So, the installation is bit tricky.

1. Mount the gOS image.

sudo mount -o loop gos-space.iso /media/cdrom

2. Then you’ll need the squashfs file, kernel and the initrd file.

sudo mkdir /gos
sudo cp /media/cdrom/casper/filesystem.squashfs /gos
sudo cp /media/cdrom/casper/vmlinuz /gos
sudo cp /media/cdrom/casper/initrd.gz /gos

(Note : You can also extract the squashfs file and make the process simpler, but that’ll require much more free space.)

3. When we do changes in the OS, we need those to be persistence. So, I choose to save changes on a file. Following commands will create a 500MB file, and format it as a ext3 drive.

sudo dd if=/dev/zero bs=1048576 count=500 of=/gos/filesystem.ext3
sudo mkfs.ext3 /gos/filesystem.ext3

4. Now we need to configure the init scripts to use our files for root file system. So, first extract the initrd file.

cd /tmp
cp /gos/initrd.gz ./
gunzip initrd.gz
mkdir content; cd content
cpio -i < ../initrd

Now you have the initramfs on /tmp/content

5. We need loop, squashfs, and unionfs drivers. Edit the “conf/modules” file and append following.

squashfs
loop
unionfs

6. The default init script will get the “root” kernel parameter and mount it as “/root” in initramfs. We need a script to remount our files. Create a file called gos in scripts/init-bottom and paste the following content. (gedit scripts/init-bottom/gos)

#!/bin/sh -e
# initramfs premount script for gos

PREREQ=""

# Output pre-requisites
prereqs()
{
	echo "$PREREQ"
}

case "$1" in
    prereqs)
	prereqs
	exit 0
	;;
esac

mkdir /realroot
mount --move ${rootmnt} /realroot
mkdir /sqroot
mount -o loop /realroot/gos/filesystem.squashfs /sqroot
mkdir /extroot
mount -o loop /realroot/gos/filesystem.ext3 /extroot
mount -t unionfs -o dirs=/extroot:/sqroot none ${rootmnt}

Make the file executable.

chmod a+x scripts/init-bottom/gos

7. Create a new initrd file, and replace the old file.

cd /tmp/content
find . | cpio --quiet --dereference -o -H newc | gzip > ../initrd.gz
cp /tmp/initrd.gz /gos/initrd.gz

8. Edit your grub config file(/boot/grub/menu.lst) to boot from it. You’ll need to change the devices according to your disk configuration.

title		gOS
root		(hd0,0)
kernel		/gos/vmlinuz root=/dev/sda1 rw quiet single
initrd		/gos/initrd.gz
quiet

First time we have to boot in the single user mode and configure the system.

9. Before rebooting, we need to create a fstab. To do that, we have to mount our ext3 filesystem.

mkdir /tmp/gos
sudo mount -o loop /gos/filesystem.ext3 /tmp/gos
sudo mkdir /tmp/gos/etc

10. Copy the following content into /tmp/etc/fstab. (/dev/sda5 should be your swap partition - check your /etc/fstab)

unionfs	/	unionfs rw 0 0
tmpfs	/tmp tmpfs nosuid,nodev 0 0
/dev/sda5	none            swap    sw              0       0

11. Now reboot your computer and select “gOS” from grub. It’ll boot into single user mode(called maintenance mode in ubuntu). Once you get into shell, create a user, and configure your X. There are two nice wizards, you can just follow those.

user-setup
dpkg-reconfigure xserver-xorg

12. Reboot back to your main OS and edit the grub - simply remove the “single” parameter. (You can also mount the root partition within the gOS single user mode, and change grub)

title		gOS
root		(hd0,0)
kernel		/gos/vmlinuz root=/dev/sda1 rw quiet
initrd		/gos/initrd.gz
quiet

Now, reboot and enjoy. This process is obviously bit long, and not perfect. So, if you are going to keep using that distro, I recommend you install it on a separate partition.

Related Posts

2 Responses to “Live iso(distro) without burning & partitioning”

  1. Thoughts of a coder » How to convert your live CD iso into a live USB Says:

    [...] Update: You might be interested in this post “Live iso(distro) without burning & partitioning“ [...]

    June 23rd, 2008 at 1:32 pm

  2. Oss Says:

    Excellent article.
    Is it possible to make something similar for OpenSuse?
    That is, to patch initrd to boot OpenSuse directly from iso image file?

    November 8th, 2008 at 6:23 pm

Leave a Reply