Portable USB Gentoo

From Gentoo Linux Wiki

(Redirected from HOWTO Portable USB Gentoo)
Jump to: navigation, search

Contents

[edit] 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.

[edit] 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 handle swap partition.
  • How to make ROOT partition parameter in GRUB and fstab portable.
  • A portable kernel.

[edit] 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.

[edit] 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.

[edit] 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.

[edit] 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.

[edit] Preparing SWAP file

Tip: After Gentoo Handbook 6.a

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

[edit] 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

[edit] Active SWAP

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

swapon /mnt/SWAP

[edit] 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.

[edit] 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.

Personal tools