{{Article summary text|Guide to installing, configuring and using a full-featured Arch Linux system on a USB flash drive.}}

+

{{Article summary heading|Related}}

+

{{Article summary wiki|Beginners' Guide}}

+

{{Article summary wiki|Installation Guide}}

+

{{Article summary wiki|General Recommendations}}

+

{{Article summary wiki|General Troubleshooting}}

+

{{Article summary end}}

−

This page discusses how to perform a regular Arch installation onto a USB key (or "flash drive"). The result will be a system that will be updated through normal use. Consider whether you're instead interested in [[Putting installation media on a USB key]].

+

This page explains how to perform a regular Arch installation onto a USB key (or "flash drive"). In contrast to having a LiveUSB as covered in [[USB Installation Media]], the result will be a persistent installation identical to normal installation to HDD, but on a USB flash drive.

−

== Grab a big enough USB key ==

+

== Preparation ==

−

If installing KDE and a large amount of applications, 3 GiB is the recommended minimum. GNOME and Xfce4, along with a typical set of packages for a desktop (GIMP, Pidgin, OpenOffice, Firefox, flashplugin) can be installed on a 2 GiB stick, leaving a small amount of room for user data.

+

{{Note|At least 2 GiB of storage space is recommended. A modest set of packages will fit, leaving a little free space for storage.}}

+

There are various ways of installing Arch on a USB stick, the simplest being from within Arch itself:

−

== Grab CD ==

+

* If you are already running Arch, simply install {{Pkg|arch-install-scripts}} and proceed with the [https://wiki.archlinux.org/index.php/Installation_Guide Installation Guide] just like you would from the iso, but you will not be using /dev/sda. Use {{ic|lsblk}} to get the /dev/sd* name of your USB key prior to installation.

−

An Arch Linux CD can be used to install Arch onto the USB key, via booting the CD and installing using the regular method. Or, if you have another linux computer available (it needs not be Arch), you can follow the instructions to [[Install_from_Existing_Linux|install from existing linux]], and then skip to the configuration section.

+

{{Warning|If you mistakingly format /dev/sda, you are likely to go about deleting everyting on your hard drive.}}

−

+

* An Arch Linux CD/USB can be used to install Arch onto the USB key, via booting the CD/USB and following the [https://wiki.archlinux.org/index.php/Installation_Guide Installation Guide]. If booting from a Live USB, the installation will have to be made on a different USB stick.

−

== Boot ==

+

* Or, if you have another linux computer available (it need not be Arch), you can follow the instructions to [[Install_from_Existing_Linux|install from existing linux]], and then skip to the configuration section.

−

It may be necessary to boot with the arch-noscsi kernel, if the usb-storage module gives errors when loaded with the standard kernel. After the system has booted, modprobe sd_mod and usb_storage (There are reports that the 7.2 CD contains no sd_mod; simply omit loading this module, as you can safely proceed without it). The USB key will appear in a few moments, after the device has settled. dmesg will show a device scan once the device has settled:

−

−

usbcore: registered new interface driver usb-storage

−

usb-storage: device found at 4

−

usb-storage: waiting for device to settle before scanning

−

USB Mass Storage support registered.

−

scsi 6:0:0:0: Direct-Access Generic STORAGE DEVICE 9407 PQ: 0 ANSI: 0

−

sd 6:0:0:0: [sdc] 3994624 512-byte hardware sectors (2045 MB)

−

sd 6:0:0:0: [sdc] Write Protect is off

−

sd 6:0:0:0: [sdc] Mode Sense: 03 00 00 00

−

sd 6:0:0:0: [sdc] Assuming drive cache: write through

−

sd 6:0:0:0: [sdc] 3994624 512-byte hardware sectors (2045 MB)

−

sd 6:0:0:0: [sdc] Write Protect is off

−

sd 6:0:0:0: [sdc] Mode Sense: 03 00 00 00

−

sd 6:0:0:0: [sdc] Assuming drive cache: write through

−

sdc: sdc1

−

sd 6:0:0:0: [sdc] Attached SCSI removable disk

−

sd 6:0:0:0: Attached scsi generic sg3 type 0

−

usb-storage: device scan complete

−

−

It is the sdX: sdXY line that is important, as it shows the device name (in this case, sdc) and the partitions available on it (in this case, one, sdc1), if any.

== Installation ==

== Installation ==

+

Follow the [https://wiki.archlinux.org/index.php/Installation_Guide Installation Guide] as you normally would, with these exceptions:

−

Launch the installer (/arch/setup). The setup process can be done normally, with only a few pointers:

+

* If cfdisk fails with "Partition ends in the final partial cylinder" fatal error, the only way to proceed is to kill all partitions on the drive. Open another terminal ({{keypress|Alt+F2}}), type {{ic|fdisk /dev/sdX}} (where {{ic|sdX}} is your usb drive), print partition table (p), check that it's ok, delete it (d) and write changes (w). Now return to cfdisk.

−

+

* It is highly recommended to review the [https://wiki.archlinux.org/index.php/SSD#Tips_for_Minimizing_SSD_Read.2FWrites Tips for Minimizing SSD Read/Writes] on the [[SSD]] wiki article prior to selecting a filesystem. To sum up, ext4 without a journal should be fine. Recognize that flash has a limited number of writes, and a journaling file system will take some of these as the journal is updated. For this same reason, it is best to forgo a swap partition. Note that this does not affect installing onto a USB hard drive.

−

* It is best to manually partition the drive, as the auto partition may not work, and will create unnecessary partitions.

+

* Before creating the initial RAM disk {{ic|# mkinitcpio -p linux}}, in {{ic|/etc/mkinitcpio.conf}} add the {{ic|block}} hook to the hooks array right after udev. This is necessary for appropriate module loading in early userspace.

−

* If cfdisk fails with "Partition ends in the final partial cylinder" fatal error, the only way to proceed is to kill all partitions on the drive. Open another terminal (Alt+F2), type fdisk /dev/sdX (where sdX is your usb drive), print partition table (p), check that it's ok, delete it (d) and write changes (w). Now return to cfdisk.

−

* It is highly recommended to review the [http://wiki.archlinux.org/index.php/SSD#Tips_for_Minimizing_SSD_Read.2FWrites Tips for Minimizing SSD Read/Writes] on the [[SSD]] wiki article prior to selecting a filesystem. To sum up, ext4 with a journal should be fine. Recognize that flash has a limited number of writes, and a journaling file system will take some of these as the journal is updated. For this same reason, it is best to forgo a swap partition. Note that this does not affect installing onto a USB hard drive.

−

* When editing the '''/etc/mkinitcpio.conf''', add the '''usb''' hook to the hooks array right after udev hook. This necessary module loading in early userspace.

== Configuration ==

== Configuration ==

−

* Make sure that /etc/fstab includes the correct partition information for /, and for any other partitions on the USB key. If the usb key is to be booted on several machines, it is quite likely that devices and number of available hard disks vary. So it is advised to use UUID or label:

+

* Make sure that {{ic|/etc/fstab}} includes the correct partition information for {{ic|/}}, and for any other partitions on the USB key. If the usb key is to be booted on several machines, it is quite likely that devices and number of available hard disks vary. So it is advised to use UUID or label:

To get the proper UUIDs for your partitions issue '''blkid'''

To get the proper UUIDs for your partitions issue '''blkid'''

−

* menu.lst, the Grub configuration file, should be edited to (loosely) match the following,

+

* menu.lst, the Grub configuration file, should be edited to (loosely) match the following:

{{Note|When grub is installed on the USB key, the key will always be hd0,0}}

{{Note|When grub is installed on the USB key, the key will always be hd0,0}}

+

+

{{Note|It seems that current versions of GRUB2 will automatically default to using uuid. The following directions are for GRUB legacy}}

With the static /dev/sdaX:

With the static /dev/sdaX:

Line 72:

Line 62:

=== Painless boot on different machines without using UUID ===

=== Painless boot on different machines without using UUID ===

+

When using the USB key on various target machines, it is helpful to have multiple entries in GRUB, for machines with different setups. For example, the GRUB configuration could contain:

When using the USB key on various target machines, it is helpful to have multiple entries in GRUB, for machines with different setups. For example, the GRUB configuration could contain:

Line 88:

Line 79:

initrd /boot/initramfs-linux.img

initrd /boot/initramfs-linux.img

−

And so forth, giving you the option to select a configuration for a wider variety of machines. However, changing the <code>root=</code> option in GRUB does not change /etc/fstab and you must do something (in our example using udev symlink), so the root partition will always be mounted correctly.

+

And so forth, giving you the option to select a configuration for a wider variety of machines. However, changing the {{ic|1=root=}} option in GRUB does not change {{ic|/etc/fstab}} and you must do something (in our example using udev symlink), so the root partition will always be mounted correctly.

−

* Run <code>udevinfo -p /sys/block/sdx/ -a</code> (where sdx is the device name of your usb key)

+

* Run {{ic|udevinfo -p /sys/block/sdx/ -a}} (where sdx is the device name of your usb key)

* Make a new file: /etc/udev/udev.rules/10-my-usb-key.rules and insert: <code>KERNEL=="sd**", SYSFS{product}=="DataTraveler 2.0", SYMLINK+="WHATEVERYOUWANTOTCALLIT%n"</code> (<code>KERNEL=="sd**"</code> is because the kernel - 2.6.16 here - names all usb devices sd as it uses the scsi sub-system and you want to look at every sd device and apply the setting to every partition), with <code>SYSFS{model}==</code> being the unique identifier collected from udevinfo.

+

* Make a new file: {{ic|/etc/udev/udev.rules/10-my-usb-key.rules}} and insert:

−

* Run <code>/etc/start-udev uevents</code> and make sure the symlinks appears in /dev.

* If so, edit /etc/fstab, replacing your old sdx with the new symlinks.

+

:({{ic|1=KERNEL=="sd**"}} is because the kernel - 2.6.16 here - names all usb devices sd as it uses the scsi sub-system and you want to look at every sd device and apply the setting to every partition), with {{ic|1=SYSFS{model}==}} being the unique identifier collected from udevinfo.

+

* Run {{ic|/etc/start-udev uevents}} and make sure the symlinks appears in {{ic|/dev}}.

+

* If so, edit {{ic|/etc/fstab}}, replacing your old sdx with the new symlinks.

=== Optimizing for the lifespan of flash memory ===

=== Optimizing for the lifespan of flash memory ===

−

* Again, it is highly recommended to review the [http://wiki.archlinux.org/index.php/SSD#Tips_for_Minimizing_SSD_Read.2FWrites Tips for Minimizing SSD Read/Writes] on the [[SSD]] wiki article.

+

* Again, it is highly recommended to review the [[SSD#Tips_for_Minimizing_SSD_Read.2FWrites |Tips for Minimizing SSD Read/Writes]] on the [[SSD]] wiki article.

This page explains how to perform a regular Arch installation onto a USB key (or "flash drive"). In contrast to having a LiveUSB as covered in USB Installation Media, the result will be a persistent installation identical to normal installation to HDD, but on a USB flash drive.

Contents

Preparation

Note: At least 2 GiB of storage space is recommended. A modest set of packages will fit, leaving a little free space for storage.

There are various ways of installing Arch on a USB stick, the simplest being from within Arch itself:

If you are already running Arch, simply install arch-install-scripts and proceed with the Installation Guide just like you would from the iso, but you will not be using /dev/sda. Use lsblk to get the /dev/sd* name of your USB key prior to installation.

Warning: If you mistakingly format /dev/sda, you are likely to go about deleting everyting on your hard drive.

An Arch Linux CD/USB can be used to install Arch onto the USB key, via booting the CD/USB and following the Installation Guide. If booting from a Live USB, the installation will have to be made on a different USB stick.

Or, if you have another linux computer available (it need not be Arch), you can follow the instructions to install from existing linux, and then skip to the configuration section.

Installation

If cfdisk fails with "Partition ends in the final partial cylinder" fatal error, the only way to proceed is to kill all partitions on the drive. Open another terminal (Template:Keypress), type fdisk /dev/sdX (where sdX is your usb drive), print partition table (p), check that it's ok, delete it (d) and write changes (w). Now return to cfdisk.

It is highly recommended to review the Tips for Minimizing SSD Read/Writes on the SSD wiki article prior to selecting a filesystem. To sum up, ext4 without a journal should be fine. Recognize that flash has a limited number of writes, and a journaling file system will take some of these as the journal is updated. For this same reason, it is best to forgo a swap partition. Note that this does not affect installing onto a USB hard drive.

Before creating the initial RAM disk # mkinitcpio -p linux, in /etc/mkinitcpio.conf add the block hook to the hooks array right after udev. This is necessary for appropriate module loading in early userspace.

Configuration

Make sure that /etc/fstab includes the correct partition information for /, and for any other partitions on the USB key. If the usb key is to be booted on several machines, it is quite likely that devices and number of available hard disks vary. So it is advised to use UUID or label:

To get the proper UUIDs for your partitions issue blkid

menu.lst, the Grub configuration file, should be edited to (loosely) match the following:

Note: When grub is installed on the USB key, the key will always be hd0,0

Note: It seems that current versions of GRUB2 will automatically default to using uuid. The following directions are for GRUB legacy

And so forth, giving you the option to select a configuration for a wider variety of machines. However, changing the root= option in GRUB does not change /etc/fstab and you must do something (in our example using udev symlink), so the root partition will always be mounted correctly.

Run udevinfo -p /sys/block/sdx/ -a (where sdx is the device name of your usb key)

(KERNEL=="sd**" is because the kernel - 2.6.16 here - names all usb devices sd as it uses the scsi sub-system and you want to look at every sd device and apply the setting to every partition), with SYSFS{model}== being the unique identifier collected from udevinfo.

Run /etc/start-udev uevents and make sure the symlinks appears in /dev.