Segfault > IT > How-To's > Sabayon on a USB-stick

(have as well a look at "How to install Gentoo linux on a USB-stick")


 

Introduction

I initially installed Gentoo on my EeePC as I was already using it for all my other PCs.
Everything worked fine, but after a while I realized that updating/upgrading the system was just taking a lot of time as the CPU (Intel Atom) is not very powerful and compiling all packages was taking ages.

To avoid the long compilation times I therefore thought about using a precompiled distribution like Ubuntu, Debian, Fedora, etc... and tried out Ubuntu, but it was quite slow and it didn't convince me.
Then I saw that Sabayon was based on Gentoo and I came to the conclusion that that was probably the best choice for me which allowded me to have Gentoo's flexibility, huge package repository and lifetime upgrades without the overhead of the big Ubuntu packages.

I therefore wanted to install Sabayon, but as the EeePC does not have a CD- or DVD-drive I couldn't directly use the CD-images that were made available by the project but had to fiddle around with it on my own.

It's not a too complicated process to make a bootable USB-stick using the CD image as a base - there are only 3 steps to follow.
But be sure to especially choose the correct sd-drive. If you screw up with this and you repartition your "real" drive you will lose all the informations stored on it!

In the PC that I am using I have a normal HDD which is called in my case sda which I won't touch at all, and the USB-stick that I will use is recognized as sdb. Make sure to adapt this to your own setup. To perform the setup I am using another PC which has already Gentoo installed on it.

As usual, as both you and me are both mindless IT geeks, I am not responsible for anything that you might damage by following this guide.


 

Step 1 - Partitioning

First of all, make sure to use a USB-stick that is bootable.
I have here a USB-stick of "Hama" which does not support booting from it at all, even if the BIOS of your PC sees it and you give the command to boot from it - so don't get mad if things do not work and try with a different USB-stick.

Connect your USB-stick and after a few seconds it should be identified - in by case as sdb, but in your case it might be different - look at the output of dmesg.

Using fdisk create on the USB-stick a single primary partition of type linux and make it bootable:

mypc ~ # fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xce215549.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sdb: 4194 MB, 4194303488 bytes
130 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 8060 * 512 = 4126720 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xce215549

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p

Disk /dev/sdb: 4194 MB, 4194303488 bytes
130 heads, 62 sectors/track, 1016 cylinders, total 8191999 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xce215549

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-8191998, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-8191998, default 8191998):
Using default value 8191998

Command (m for help): p

Disk /dev/sdb: 4194 MB, 4194303488 bytes
130 heads, 62 sectors/track, 1016 cylinders, total 8191999 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xce215549

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     8191998     4094975+  83  Linux

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/sdb: 4194 MB, 4194303488 bytes
130 heads, 62 sectors/track, 1016 cylinders, total 8191999 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xce215549

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048     8191998     4094975+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

The partition has been created so now we can format it:

mypc ~ # mkfs.ext3 /dev/sdb1


 

Step 2 - Installing Grub (and preparing for the last step)

Extract and re-insert your USB-stick, just to be sure that the partition that you created during the previous step is recognized correctly.

Mount the partition to any empty local directory - in my case I mount it under "/mnt/usbstick":

mount -v -o noatime /dev/sdb1 /mnt/memstick

Install grub:

mypc # grub-install --no-floppy --root-directory=/mnt/memstick /dev/sdb
Installation finished. No error reported.
This is the contents of the device map /mnt/memstick/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(fd0)   /dev/fd0
(hd0)   /dev/sda
(hd1)   /dev/sdb

Eventually delete the line containing (fd0) as nowadays almost nobody uses anymore a floppy/disc drive. After doing this you should see that under /mnt/[usbstick-or_your_other_directory] the new directory boot is visible and under that one there should be another one called grub. If you're using a distribution other than Gentoo the results might be similar but I don't give any guarantees.

Now go to the Sabayon homepage and download a CD image.
For my EeePC I downloaded the file "Sabayon_Linux_5.5_x86_XFCE.iso" (it's a 32bit version of the OS) from this mirror.
Once you have the file of the CD image mount it locally...

mount -v -o loop,ro Sabayon_Linux_5.5_x86_XFCE.iso /mnt/cdimage

...and then copy its whole contents to the USB-stick:

rsync -avx /mnt/cdimage/* /mnt/memstick/


 

Step 3 - Setting up Grub

You now have a formatted USB-stick containing all the files that you need.
What's still outstanding is to create a Grub configuration so that the Kernel & Co. can be loaded during the boot process.

To do this edit (or create the file if it does not exist) under /mnt/memstick/boot/grub/grub.conf (in my case I have in that directory a symlink named "menu.lst" pointing to that "grub.conf"-file) as follows:

default 0
timeout 20

title=Sabayon x32 liveCD xfce
root (hd0,0)
kernel /boot/sabayon root=/dev/ram0 cdroot=/dev/sdb1 aufs init=/linuxrc <...CONTINUES ON SAME LINE
...> looptype=squashfs max_loop=64 loop=/livecd.squashfs console=tty1 verbose scandelay --
initrd /boot/sabayon.igz

title=Sabayon x32 graphical installer
root (hd0,0)
kernel /boot/sabayon root=/dev/ram0 cdroot=/dev/sdb1 aufs init=/linuxrc looptype=squashfs max_loop=64 loop=/livecd.squashfs console=tty1 verbose scandelay installer-gui
initrd /boot/sabayon.igz

title=Sabayon x32 text installer
root (hd0,0)
kernel /boot/sabayon root=/dev/ram0 cdroot=/dev/sdb1 aufs init=/linuxrc looptype=squashfs max_loop=64 loop=/livecd.squashfs console=tty1 verbose scandelay installer-text gentoo=nox nox --
initrd /boot/sabayon.igz

These values should work if the PC that you'll use to boot the USB-stick has an internal HDD and nothing else.

  • When your PC boots it will let you select if to boot from the internal HDD or from the USB-stick. When you select the USB-stick the bios will pass to Grub the USB-stick which will then be seen by Grub as the first HDD (therefore "hd0") and as you have only one partition on it containing everything including the root fs you use as well the partition 0 => therefore it becomes root (hd0,0).
  • "/boot/sabayon", "/livecd.squashfs" and "/boot/sabayon.igz" are all files that you should find just below the top-level directory where you mounted your USB-stick. Change the names in this config file if they change in future versions.
  • "cdroot=/dev/sdb1" may sound a little bit contradictory with the "hd0,0" mentioned before. But the thing is probably that after that the kernel of the USB-stick has booted, it will see first the internal HDD which will become "sda", while the USB-stick will be seen only a bit later, which will then become "sdb". Therefore "sdb1" is the partition on the USB-stick here you previously copied all the files.
  • The other values are derived from the contents of "/mnt/cdimage/isolinux/isolinux.cfg".

That's it.
If you now unmount everything your should be able to boot with the USB-stick. Well, at least, it worked for me.


 

References