HOWTO: Booting Sabayon LiveDVD Image from a USB Device with Grub
*Grub method for booting a thumbdrive requires that you be able to possibly edit your grub.conf when moving from one system to the next. If you require being able to seemlessly move from one computer to the next please use the extlinux how-to in the how-to list.*
- 1 Introduction
- 2 Requirements
- 3 Procedure
- 4 Problems and Troubleshooting:
- 5 References:
Based on my searches, there seem to be two main methods for booting USB devices: Grub and Syslinux (perhaps lilo is a third).
This method uses grub. The advantages of grub are that it is becoming the standard linux boot method, and it will let you use a variety of file systems (where syslinux is restricted to vfat). If you were trying to build an installed linux system on a USB thumb drive, you would probably use grub so that you could use one of the typical linux file systems such as ext2, ext3, reiserfs, etc.
Syslinux actually seems to be more widely used for setting up USB bootable systems. Syslinux' big advantage is that it can be set up from within Windows, and, for the other USB capable distros I looked at, it seemed pretty easy to set up. I'm not 100% sure why I had problems with syslinux and Sabayon's LiveDVD, and I may still go back and put together a method that works for syslinux also.
You need a computer that boots from your USB.
You need at least a 4 Gig Stick for the DVD (the Pod version of Sabayon should require much less).
Make sure there is no data you need to save on the USB drive used for this method.
This procedure includes steps for formatting and partitioning devices, and has the potential to irretrievably damage part or all of your hard disk if you apply this method to the wrong device. Be very careful you are sure which device you are affecting, especially in Sabayon where both hard disks and USB drives are /dev/sdx# devices.
I will refer to USB devices as 'sdu'; whereas it is probably sdb or sdc in most systems. If you cut and paste these steps, you will need to edit the device.
Prep a USB Stick to be Bootable
The method assumes you have a blank USB drive available for manipulation. These steps may not be necessary, but you are on your own to adapt the procedure to an already formatted and used USB drive.
Also this method is based on ext2. I'm sure vfat is more interesting to people since it allows their thumb drive to be compatible with Windows. I'll update this procedure for vfat later, assuming I don't run into any problems.
So the first step is use fdisk on an USB drive to create a bootable partition. Most USB drives do not ship with a bootable partition, so at a minimum, you'll need to use fdisk to make it bootable. However, this procedure is written so as to wipe the drive clean.
# fdisk /dev/sdu
Now delete the existing partition or partitions until the partition table is empty.
Create a new partition 'n', 'p', '1', '<enter><enter>'.
Make sure the partition type is '83' for linux (otherwise adjust the type with 't').
Make the partition bootable: 'a', '1'.
Write the results and quit: 'w'.
Note: I had an issue with fdisk inconsistently seeing more that 1024 cylinders on my thumb drive. I found I could delete the partition table, write and exit, then restart fdisk, and it would see 1024 cylinders.
Format the USB Stick
Format the USB with the ext2 filesystem (you should be able to substitute your own choice of file system here since we are using grub, but I have tested this procedure with ext2).
# mke2fs /dev/sdu1
Mount the Iso Image and USB device
# cd /<some-work-area> # mkdir isofs # mkdir usbdev # mount -o loop /<path-to-iso-image>/Sabayon-Linux-x86-3.5.iso isofs/ # mount /dev/sdu1 usbdev
If you only have the actual DVD, and no longer have the image file, just mount the DVD at isofs instead.
Copy the DVD Files Over
Since the DVD is slightly over 4 Gig, you'll need to leave something out if you only have a 4 Gig drive. The following commands omit copying the games.squashfs file, which is not used anyways the way this procedure is written.
# cd isofs/ # cp -a isolinux GEEXBOX boot README.txt livecd livecd.squashfs ../usbdev/
Copy Grub Directory and Files Over
If you are in a working linux environment with grub already installed, you can use your installed grub.
# cd ../usbdev/ # cp -a /boot/grub boot/
Alternatively, grub is also available on the DVD image, but you will need to mount the LiveDVD squash image. Also, to use the steps listed below, you will need to create your squashfs mount point in the same subdirectory you created your isofs and usbdev mount points.
# mkdir squashfs # mount -o loop isofs/livecd.squashfs squashfs/ # cp -a squashfs/boot/grub usbdev/boot/
Generate an Appropriate grub.conf File
These steps describe how to install Grub 1. This is for releases < Sabayon 5.2
Things got a little confusing in this step. Notice that I have identified the root device as '(hd0,0)'. This may be an issue specific to my hardware, but when grub boots a USB device, it then sees the USB device as the first device.
However, in the very next line, you see me refer to the USB partition as 'sdb1' for the chroot parameter. On my hardware, it seems the the kernel sees the hardware order differently than grub.
One of the shortcomings of this method is that the cdroot parameter must be exactly where the kernel expects to find it after booting, or the boot will fail. You may need to play around with these settings on your hardware.
Here is an example of the grub.conf I have in my USB drive's /boot/grub/ directory:
# grub.conf # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You do not have a /boot partition. This means that # all kernel and initrd paths are relative to /, eg. # root (hd0,1) # # Video Mode Table # | 640x480 800x600 1024x768 1280x1024 # ----+------------------------------------- # 256 | 0x301 0x303 0x305 0x307 # 32k | 0x310 0x313 0x316 0x319 # 64k | 0x311 0x314 0x317 0x31A # 16M | 0x312 0x315 0x318 0x31B # default=0 timeout=6 # Comment out splash during development phase of USB boot method # # splash=silent,theme:sabayon # - or - # splashimage=(hd0,0)/boot/grub/splash.xpm.gz title Sabayon Linux x86 DVD/USB (cdroot sdb1) root (hd0,0) kernel /boot/sabayon root=/dev/ram0 aufs init=/linuxrc cdroot=/dev/sdb1 \ looptype=squashfs max_loop=64 loop=/livecd.squashfs vga=0x318 \ CONSOLE=/dev/tty1 verbose scandelay -- initrd /boot/sabayon.igz
Apply Grub to the USB Drive
These steps describe how to install Grub 1. This is for releases < Sabayon 5.2
Be careful to apply grub to the correct device. You don't want to overwrite your existing grub or other boot entry on your hard disk.
In this example, I'm using the grub command line interface. The grub command line method allows you to use tabbed completion for you entries, which can assist you in determining how grub sees your system.
For instance, if I enter 'root (hd<tab>' or 'setup (hd<tab>', I get:
Possible disks are: hd0 hd1
...with hd1 being the USB in my case.
# grub GNU GRUB version 0.97 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> root (hd1,0) Filesystem type is ext2fs, partition type 0x83 grub> setup (hd1) Checking if "/boot/grub/stage1" exists... no Checking if "/grub/stage1" exists... yes Checking if "/grub/stage2" exists... yes Checking if "/grub/e2fs_stage1_5" exists... yes Running "embed /grub/e2fs_stage1_5 (hd1)"... 16 sectors are embedded. succeeded Running "install /grub/stage1 (hd1) (hd1)1+16 p (hd1,0)/grub/stage2 /grub/menu .lst"... succeeded Done. grub> quit
Reboot to Your USB Drive
At this point, you should have a bootable USB device. Give it a try!
Problems and Troubleshooting:
Forum Discussion: 
HOWTO: Run 3.5 Loop Without Burning The Image: 
BootUsb - Debian Wiki: