Tuesday 27 November 2012

Multi-boot USB Stick

Some time ago I discovered MultiSystem, which easily let's you create a USB stick with a number of different distributions (some basic instructions, for example, at http://www.linux-magazine.com/Online/Blogs/Productivity-Sauce/Create-a-Multi-boot-USB-Stick-with-MultiSystem).

The program is quite nice as it is (though the GUI is a little bit awkward), but I wanted to have a couple of things done differently, so the resulting USB stick could be more suited to my needs. Mainly two things:


  1. Allow persistent mode for several of the distros (by default you can only get persistent mode for one of them).
  2. Allow the usage of some of the space of the pendrive as a common storage area for all distributions.


In order to get it done I first installed MultiSystem:

sudo sh -c 'echo "deb http://liveusb.info/multisystem/depot all main" >> /etc/apt/sources.list'
wget -q http://liveusb.info/multisystem/depot/multisystem.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install multisystem


Then, using the MultiSystem GUI I installed Xubuntu 12.10 and Linux Mint 14 in the pendrive. Then I chose one of them and using MultiSystem added the persistent mode. This will create the appropriate entry in the grug.cfg file in the pendrive, and it will also create a file, casper-rw. I delete the created casper-rw file and created my own one as ext3 (the one created with MultiSystem is ext2), instructions from http://blog.evolya.fr/public/appli/tuto-qemu/How_to_create_a_larger_casper-rw_loop_block_file___USB_Pen_Drive_Linux.htm:


dd if=/dev/zero of=casper-rw bs=1M count=1024
mkfs.ext3 -F casper-rw
Copy the new casper-rw file to the pendrive


But instead of leaving the casper-rw file in the root directory of the pendrive, I put it in the directory:

/persistent/xubuntu/

After that I modified the grub.cfg in the pendrive (/boot/grub/grub.cfg) so that it will look for that particular casper-rw file, and a different username and hostname will be used (the relevant options are persistent-path, hostname, username and userfullname, instructions taken from http://www.linuxcertif.com/man/7/casper/):

linux (loop)/casper/vmlinuz root=UUID=4088-F6F9 debian-installer/language=en keyboard-configuration/layoutcode=es  iso-scan/filename=/xubuntu-12.10-desktop-amd64.iso boot=casper showmounts persistent persistent-path=/persistent/xubuntu/ hostname=nomada username=angelv userfullname=AngeldeVicente file=/cdrom/preseed/xubuntu.seed noprompt quiet splash --

With that we have the way open to repeat the procedure for Linux Mint, another casper-rw will be created, which we get rid of and follow the steps above to create a personalized casper-rw file for that particular distro.

When booting a computer from the resulting USB stick, the GRUB options window looks like the following (there are two options for Xubuntu and two for Linux Mint: one of them will ignore the persistent (casper-rw) file and will just boot the clean liveCD version; the second one will use the persistent file, so that we can install some new software, change some settings, etc. and they will survive reboots):



As for the common storage for all the distributions, that was simply done with gparted, so that I resized the fat32 partition to leave space (10GB) for another partition (ext3), which can be mounted from the live USB distros, and used as a common space for documents, etc.

As an example, here it is the Linux Mint (with persistent option) desktop, in which the "common" partition is the ext3 partition created in the USB stick itself for common storage across the different distros: 






This is not an issue for me yet, but at some point I will probably make a lot of changes to the different distros. In order to merge the changes with the original LiveCD distribution, I will try to follow the instructions at http://this.is.thoughtcrime.org.nz/multi-boot-bt5-from-usb-with-grub2

EDIT (21/12/2012): After a few successful installations, I found that one of the persistence files was getting small, so I looked for information on resizing the casper-rw file. For adding to the file, this works OK:


dd if=/dev/zero bs=1M count=500 >> casper-rw
resize2fs casper-rw

For decreasing the size of the casper-rw, we probably should go something like:

dd if=/dev/zero of=newfile bs=1M count=number of blocks
mkfs.ext3 -F
newfile

mount -o loop oldfile /mnt/mountold
mount -o loop newfile /mnt/mountnew


5 comments:

Aaron's stuff said...

Thanks, I can't find it on there website. All I find is something to buy like thumb drive that are all ready to use.

angelv said...

Hi, I assume you mean that you cannot find how to download MultiSystem in their webpage? True, it is a bit difficult to follow that page, but if you read my post a little bit more, you have detailed instructions on how to install it. Cheers,

ovasilis74 said...

Hi angelv, great tutorial, explains many of my queries about a "multi-casper-MultiSystem"!
If someone wants the easiest way to start using MultiSystem, without typing or copy/paste in the CLI, can use this link
http://www.pendrivelinux.com/multiboot-create-a-multiboot-usb-from-linux/
This webpage hosts many other booting-tools! That's where I first installed MultiSystem from...

Now please tell me, could you update the Xubuntu 12.10 or the Linux Mint 14 itself (ex. from Linux 3.2.0-54-generic to Linux 3.2.0-55-generic)? I ask bacause every time I had made a persistent install in my MultiSystem USB, when I accepted the kernel to be updated at first boot through the Update-Manager, after restart the boot was crashing... and I was just deleting the persistend... Of course I had always left the ext2 casper due to preserve the USB drive (I use ext2 even for my normal Xubuntu12.04 installation in a 32GB minipci-e SSD on my DellMini9 because I think that does less read/writes than ext3/4, like Fat/NTFS). If your kernel updates without problems, is it because of the ext3 casper?

As for the "common" partition, I suppose that it would be more useful to format it as exFat (https://launchpad.net/~relan/+archive/exfat for Ubuntu, Xubuntu etc. http://code.google.com/p/exfat/ for other Linux distributions), so other less ...open operatin systems can read it. BTW if MultiSystem could be alternatively use an exFat formated USB drive, we could boot larger .iso images, but I don't know if the author had reasons for not providinging that.

Thank you for all the enlightening information,
Vasilis

angelv said...

Hi Vasilis,

I'm not sure about upgrading the distros themselves. I have installed new versions of some of the packages through, for example, synaptic, without issues, but the kernel itself I don't think I have ever updated it in one of the USB stick distributions.

Sorry,
Ángel

Anonymous said...

How would you go about having debian and kali persistent?

When you make one of these distros persistent with Multisystem it naturally gives a live-rw and not casper-rw.

What would I do different in this process?

I am new to this and was hoping you could help.