Search:  
Gentoo Wiki

Portable_USB_Gentoo

Contents

Introduction

This document describe how to install Gentoo to an external USB hard disk as a portable operating system.

It assume you have the experience that install Gentoo manually, followed the Gentoo handbook, and you know exactly what you did.

Now this article should be enough for experienced user to install a bootable Gentoo Linux System on a external USB hard disk.

But it still lack some important issues, like auto configuration for Xorg or OpenGL interface, so feel free to extend this.

If you find you could not get things work by following this guide, you could ask your question in discussion page, and I will see if I could tell you what is going wrong.

Since English is not my native language, and I did not study it hard in school, maybe there are lots of misspelling, grama error and other horrible sentence, so it is welcome to correct these things directly.

Issues

There are some issues to be solved when we tried to make Gentoo Linux as a portable operating system. The following is the list of all issues.

How to Read This

This HOWTO assume you are installing Gentoo to an external USB hard disk by following Gentoo Handbook and this HOWTO. Basically, you will just follow the Gentoo Handbook, and we will tell you when to pause and what to do.

Notation

In the very beginning of every section, we will have a tip box to tell you where you should stop and follow the process this HOWTO mentioned.


Tip: Before Gentoo Handbook x.y

This means you should follow the instruction before continue to Gentoo Handbook x.y section.


Tip: After Gentoo Handbook x.y

This means you should follow the instruction after done Gentoo Handbook x.y section.


Tip: During Gentoo Handbook x.y

This means you should follow the instruction during Gentoo Handbook x.y section, and some instruction mentioned in Gentoo Handbook should be changed.

Preparing Root Partition

Tip: During Gentoo Handbook 4.d
Note: You do not need /boot and SWAP partition in Portable USB Gentoo.

Just like the normal installation, you need prepare your disk partition first. We assume you have already create a root partition.

Remember that you do not need to create a swap partition, since we would use a swap file instead of swap partition, and we don't need /boot partition neither.

The following process, we assume your Portable USB Gentoo root partition is located at /dev/sdb1. Please change these device path according to your situation.

Create Filesystem with LABEL

After root partition is ready, we need creating a file system with disk label. Disk label is a identifier of your partition, which would not change when you use your USB hard disk from computers to computers.

You could create file system with label using the following commands.

If you decide to use ext3 filesystem:

mke2fs -L USBLinux -j /dev/sdb1

If you want use ReiserFS:

mkreiserfs -l USBLinux /dev/sdb1

Please remember the label use used here:USBLinux, we will use it later.

Now, please follow the Gentoo Handbook until section 6.a.

Preparing SWAP file

Tip: After Gentoo Handbook 6.a

After installed the basic system, we need create a swap file.

Create SWAP file

The following command will create a 1G file at /mnt/SWAP as a swap file.

dd if=/dev/zero of=/mnt/SWAP bs=1024 count=1048576
mkswap /mnt/SWAP

Active SWAP

Now, you could enable this swap file by the following command.

swapon /mnt/SWAP

Install Kernel

Tip: During Gentoo Handbook 7.d
Note: You need use genkernel

We need a generic kernel which could boot on most X86 computers and auto-detect your hardware when boot, so you need use genkernel at Gentoo Handbook Chapter 7.

You need add a --disklabel argument when you run genkernel.

genkernel --disklabel all

Now, continue the Gentoo Handkbook until chapter 8.

Filesystem Information

Tip: During Gentoo Handbook 8.a
Note: You don't need boot partition in /etc/fstab

You have to use LABEL in your /etc/fstab, so your root partition and swap file could mount on any computer, even the device path is different.

Your /etc/fstab should contain at least two lines: root partition and swap file.

These two line should look like the following:

File: /etc/fstab
LABEL=USBLinux    /          ext3    noatime    0 1
/mnt/SWAP         none       swap    sw         0 0

Now continue Gentoo Handbook until chapter 10.

Install Bootloader (GRUB)

Tip: During Gentoo Handbook 10.b

Replace the value of real_root parameter from something like /dev/XXX to LABEL=USBLinux, so the config file of Code Listing 2.4 in handbook should look like the following now:

File: /boot/grub/menu.lst
default 0
timeout 30
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title Gentoo Linux 2.6.24-r5
root (hd0,0)
kernel /boot/kernel-genkernel-x86-2.6.24-gentoo-r5 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=LABEL=USBLinux
initrd /boot/initramfs-genkernel-x86-2.6.24-gentoo-r5

# Only in case you want to dual-boot
title Windows XP
rootnoverify (hd0,5)
makeactive
chainloader +1

Of course remember change the root (hd0,0) stuff according to your disk partition plan.

Now follow the handbook to install GRUB as your bootloader, also remember you should install your GRUB on the MBR of your USB HD.

After install GRUB on your USB HD MBR, remember modify this config file and make sure you use "root (hd0,X)", because on most BIOS, if you boot from USB disk, then your USB disk will be (hd0) in GRUB.

Finalizing your Gentoo Installation

Clean UUID/LABEL Cache

Tip: Before Gentoo Handbook 10.1

We need delete blkid cache when we turn off computer. Open /etc/conf.d/local and add the following line in local_stop() function.

 rm -f /etc/blkid*

Now continue the handbook chapter 11, and you should have a bootable a Portable Gentoo Linux on external USB hard disk.

Retrieved from "http://www.gentoo-wiki.info/Portable_USB_Gentoo"

Last modified: Thu, 02 Oct 2008 10:41:00 +0000 Hits: 3,539