Create your own save-your-ass multi-boot USB stick

I don’t have to convince you that carry around a couple of Linux distros can mean the difference between life and death. Well, of course I’m being a little bit melodramatic here, but it’s really nice to have the ability to quickly run a memory test on a machine that insists to misbehave, or even backup important stuff when you are on the go.

For me, some tools and distros are particularly useful:

  • Clonezilla. Very nice disk/partition cloning tool. It takes some time for beginners to get used to it, but it’s worth the effort. This tool saved my life more than once.
  • GParted. Great tool for disk partitioning.
  • Linux Mint. Very easy to use Ubuntu-based Linux distro. I particularly like the Live-DVD edition, which includes useful software like VLC, OpenOffice and Java.
  • Ubuntu. One of the most popular Linux distros nowadays.
  • Memtest86+. Memory testing tool bundled in most Linux distros. Indispensable.

Now, instead of burning one CD/DVD for each one of these tools, we’re going to use one multi-boot USB stick.

Preparing the flash drive

The first step is to install a bootloader on the USB stick, so we can choose which distro/tool to load when booting from it. Lucky for me that my Linux distro of choice, Ubuntu, already comes with Grub2 pre-installed. This particular version of Grub is required since it allows us to mount and boot .ISO images.

Once you have Grub2 installed, plug in your USB stick and make sure that its main partition is bootable and is formated with FAT32 (vfat).

Then, run this command to install Grub2 on the stick:

$ sudo grub-install --no-floppy --root-directory=/media/USB_STICK /dev/sdX

Remember to make root-directory point to the path where the flash drive is mounted, and change /dev/sdX to the actual device. Please double-check the parameters to avoid messing with the wrong disk!

Configuring Grub2

It’s time to download the .ISO images for one or more of the aforementioned distros and put them all inside the directory /boot/iso/ inside flash drive. Then, create the file /boot/grub/grub.cfg with the following content:

menuentry "Linux Mint 9 x86" {
  set isofile="/boot/iso/linuxmint-9-gnome-dvd-i386.iso"
  loopback loop $isofile
  linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noeject noprompt --
  initrd (loop)/casper/initrd.lz
}
 
menuentry "Ubuntu 10.04 Desktop x86" {
  set isofile="/boot/iso/ubuntu-10.04-desktop-i386.iso"
  loopback loop $isofile
  linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noeject noprompt --
  initrd (loop)/casper/initrd.lz
}
 
menuentry "Clonezilla Live 1.2.5-17 x86" {
  set isofile="/boot/iso/clonezilla-live-1.2.5-17-i686.iso"
  loopback loop $isofile 
  linux (loop)/live/vmlinuz boot=live union=aufs nolocales noprompt ip=frommedia toram=filesystem.squashfs findiso=$isofile 
  initrd (loop)/live/initrd.img
}
 
menuentry "GParted Live 0.5.2-9 x86" {
  set isofile="/boot/iso/gparted-live-0.5.2-9.iso"
  loopback loop $isofile 
  linux (loop)/live/vmlinuz boot=live union=aufs nolocales noprompt ip=frommedia toram=filesystem.squashfs findiso=$isofile 
  initrd (loop)/live/initrd.img
}
 
menuentry "Memory test (memtest86+)" {
  linux16 /boot/iso/memtest86+.bin
}

Don’t forget to change each isofile variable to match the downloaded images.

Caveat

This stuff is new, and there are only a few distros that can be booted that way. If you want to try this with other distros than the ones listed here, you’d probably need to Google for the right Kernel options to use.

Sobre Daniel Martins

Fundador da Destaquenet, ele é graduado em Sistemas de Informação e desenvolve softwares como hobby e profissão desde 2000. Especializado na plataforma Java, ele utiliza a tecnologia há vários anos, sendo programador e desenvolvedor web certificado pela Sun Microsystems, recentemente adquirida pela Oracle. Também se interessa por assuntos ligados à cultura open source, metodologias ágeis, engenharia de software, frameworks e linguagens dinâmicas tais como Python, Ruby e Smalltalk.
Esta entrada foi publicada em English, Tutorials e marcada com a tag , , , , , , , , , , , , , , , , , . Adicione o link permanente aos seus favoritos.

9 respostas a Create your own save-your-ass multi-boot USB stick

  1. Pingback: Tweets that mention Create your own save-your-ass multi-boot USB stick | Destaqueblog -- Topsy.com

  2. Riccardo disse:

    Nice tutorial thanks; how big should the USB key be? I guess around 2-4 GB (mostly for Mint and Ubuntu)

  3. @Riccardo: Ubuntu and Mint are very similar distributions; I think Mint is more useful since it comes with more software. In this case, Ubuntu is kind of optional. Then, any USB key larger than 2GB should be enough. (although mine is a 16GB one)

  4. Pingback: Linux Training – Linux Installation Help – Linux Live CDs And Linux Installation CDs – Pros and Cons

  5. Paul Scheibner disse:

    Thanks for posting this.

  6. Avi disse:

    I tried to do the same with Ubuntu 10.10 amd64 but it fails to boot.
    Any idea what needs to be done for Ubuntu 10.10?

  7. @Avi: That’s odd. I installed the new Ubuntu (amd64 as well) on my laptop using the same config as Ubuntu 10.04, and everything worked fine. What error(s) do you get?

  8. Avi disse:

    All is well now. It was a damaged ISO file.

    When I booted, the kernel was loading and then I’d receive a bunch of errors about attempting to access beyond end of device.

    I wish Ubuntu had displayed the md5sum of the ISO when downloading it. The first time it just started the download.

    The second mirror did display the md5sum and then I figured out the problem.

Deixe um Comentário

O seu endereço de email não será publicado Campos obrigatórios são marcados *

*

Você pode usar estas tags e atributos de HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">