https://wiki.archlinux.org/api.php?action=feedcontributions&user=TypoFixer&feedformat=atomArchWiki - User contributions [en]2024-03-28T12:23:21ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Install_Arch_Linux_on_a_removable_medium&diff=247911Install Arch Linux on a removable medium2013-02-19T18:05:41Z<p>TypoFixer: /* Preparation */</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Installing Arch Linux on a USB key]]<br />
[[it:Installing Arch Linux on a USB key]]<br />
[[zh-CN:Installing Arch Linux on a USB key]]<br />
{{Article summary start}}<br />
{{Article summary text|Guide to installing, configuring and using a full-featured Arch Linux system on a USB flash drive.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Beginners' Guide}}<br />
{{Article summary wiki|Installation Guide}}<br />
{{Article summary wiki|General Recommendations}}<br />
{{Article summary wiki|General Troubleshooting}}<br />
{{Article summary end}}<br />
<br />
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.<br />
<br />
== Preparation ==<br />
{{Note|At least 2 GiB of storage space is recommended. A modest set of packages will fit, leaving a little free space for storage.}}<br />
There are various ways of installing Arch on a USB stick, the simplest being from within Arch itself:<br />
<br />
* 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.<br />
{{Warning|If you mistakingly format /dev/sda, you are likely to go about deleting everything on your hard drive.}}<br />
* 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.<br />
* 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.<br />
<br />
== Installation ==<br />
Follow the [https://wiki.archlinux.org/index.php/Installation_Guide Installation Guide] as you normally would, with these exceptions:<br />
<br />
* 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.<br />
* 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.<br />
* 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.<br />
<br />
== Configuration ==<br />
* 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:<br />
<br />
To get the proper UUIDs for your partitions issue '''blkid'''<br />
<br />
* menu.lst, the Grub configuration file, should be edited to (loosely) match the following:<br />
<br />
{{Note|When grub is installed on the USB key, the key will always be hd0,0}}<br />
<br />
{{Note|It seems that current versions of GRUB2 will automatically default to using uuid. The following directions are for GRUB legacy}}<br />
<br />
With the static /dev/sdaX:<br />
<br />
root (hd0,0)<br />
kernel /boot/vmlinuz-linux root=/dev/sda1 ro<br />
initrd /boot/initramfs-linux.img<br />
<br />
When using label your menu.lst should look like this:<br />
<br />
root (hd0,0)<br />
kernel /boot/vmlinuz-linux root=/dev/disk/by-label/'''Arch''' ro<br />
initrd /boot/initramfs-linux.img<br />
<br />
And for UUID, it should be like this:<br />
<br />
root (hd0,0)<br />
kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/3a9f8929-627b-4667-9db4-388c4eaaf9fa ro<br />
initrd /boot/initramfs-linux.img<br />
<br />
== Tips ==<br />
<br />
=== Painless boot on different machines without using UUID ===<br />
<br />
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:<br />
<br />
# (0) Arch Linux<br />
title Arch Linux (first drive)<br />
root (hd0,0)<br />
kernel /boot/vmlinuz-linux root=/dev/sda1 ro<br />
initrd /boot/initramfs-linux.img<br />
<br />
As well as<br />
<br />
# (1) Arch Linux<br />
title Arch Linux (second drive)<br />
root (hd0,0)<br />
kernel /boot/vmlinuz-linux root=/dev/sdb1 ro<br />
initrd /boot/initramfs-linux.img<br />
<br />
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.<br />
<br />
* Run {{ic|udevinfo -p /sys/block/sdx/ -a}} (where sdx is the device name of your usb key)<br />
* Find unique information pertaining to your usb key. I chose {{ic|1=SYSFS{model}=="DataTraveler 2.0"}} <br />
* Make a new file: {{ic|/etc/udev/udev.rules/10-my-usb-key.rules}} and insert: <br />
:{{bc|1= KERNEL=="sd**", SYSFS{product}=="DataTraveler 2.0", SYMLINK+="WHATEVERYOUWANTOTCALLIT%n"}}<br />
:({{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.<br />
* Run {{ic|/etc/start-udev uevents}} and make sure the symlinks appears in {{ic|/dev}}. <br />
* If so, edit {{ic|/etc/fstab}}, replacing your old sdx with the new symlinks.<br />
<br />
=== Optimizing for the lifespan of flash memory ===<br />
* 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.<br />
<br />
== See Also ==<br />
* [[Official Arch Linux Install Guide]]<br />
* [[Installing Arch Linux from VirtualBox]]<br />
* [[Solid State Drives]]</div>TypoFixer