Installing Arch Linux on a USB key (Italiano)

From ArchWiki
Revision as of 22:46, 9 March 2011 by Lorenzog (Talk | contribs) (Grab CD)

Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Tango-preferences-desktop-locale.pngThis article or section needs to be translated.Tango-preferences-desktop-locale.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Installing Arch Linux on a USB key (Italiano)#)
Nota: Questo articolo è in fase di traduzione. Seguite per ora le istruzioni della versione inglese.

Questa pagina spiega come effettuare una normale installazione di Arch su una chiave USB (o flash drive). Il risultato sarà un sistema che verrà aggiornato durante il normale utilizzo. Considerare anche l'alternativa di Putting installation media on a USB key.

Procurarsi una chiave USB sufficientemente grande

Per l'installazione di KDE e di numerose applicazioni sono raccomandati almeno 3 GiB. GNOME e Xfce4, con un tipico insieme di pacchetti per il desktop (GIMP, Pidgin, OpenOffice, Firefox, flashplugin) possono essere installati su una chiave da 2 GiB, lasciando un piccola quantità di spazio per i dati utente.

Ottenere il CD

Un cd di Arch Linux può essere usato per installare Arch sulla chiave USB, avviando il sistema da CD e installando usando il metodo normale. Oppure, se si dispone di un altro computer con Linux (non è necessario che sia Arch), è possibile seguire le istruzioni di install from existing linux, e saltare direttamente alla parte di configurazione.


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.


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

  • It is best to manually partition the drive, as the auto partition may not work, and will create unnecessary partitions.
  • 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 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 it asks you whether you want USB boot support, choose yes.


  • Make sure that /etc/fstab includes the correct partition information for /, and for any other partitions on the USB key. Keep in mind the setup of the target machine when putting in the device names, as they may be different from the machine you are using for the installation. Example: if the installation machine has one hard drive, your USB key will likely be sdb. The target machine, however, may have no hard drives, in which case your USB key will likely be sda.
  • menu.lst, the Grub configuration file, should be edited to (loosely) match the following, replacing sda1 with the partition of the key on the target machine (note that, as grub is installed on the USB key, the key will always be hd0,0).
root (hd0,0)
kernel /boot/vmlinuz26 root=/dev/sda1 ro vga=773
initrd /boot/kernel26.img
  • Regenerate the initrd image, kernel26.img. Edit /etc/mkinitcpio.conf, changing the hooks to include (at a minimum): "base udev ide usb filesystems" (Note: if using the 7.2 CD, and installing from the CD, you will have mkinitrd instead of mkinitcpio. During the configuration, you will be asked to edit mkinitrd.conf; simply change REMOVE_USB=1 to REMOVE_USB=0 and ignore the following command). Then rebuild the image by issuing:
# mkinitcpio -k 2.6.25-ARCH -c /etc/mkinitcpio.conf -g /boot/kernel26.img.

Note: The kernel version (-k) must be the kernel version in the USB key, not the live cd's kernel version.


USB Support

Should you see that the /arch/setup correctly installed a system on to your USB drive but it stills failed to boot from it by complaining that it could not find the root file system even though it had been specified with UUIDs, then you are most likely missing support for USB. In this case, boot back into your Arch Setup CD/USB media and do the following:

  • chroot into the arch installation contained on the usb drive (don't forget the boot partition, if any)
  • Edit /etc/mkinitcpio.conf, and add "usb" to the "HOOKS=" line after udev:
HOOKS="base udev usb autodetect pata scsi sata filesystems"
  • Regenerate the initrd image by running:
# mkinitcpio -p kernel26

Using UUID

Instead of using literal partition names, you can also use the UUID of your partition. This way is much better and more manageable in a setup where the USB drive is meant to boot at multiple PC's than using the partition literal names (/dev/sdb1). Run:

# blkid

to find out which one points to the regular device node (ie, /dev/sdb1) that is your key.

Now you can place this device node (in the form UUID=7bf1d942-7b8c-4fb7-b55a-d3c40895906d) into /etc/fstab in place of the regular node (ie, /dev/sdb1). Edit also your kernel line in menu.lst, so it will contain something like:

kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/7bf1d942-7b8c-4fb7-b55a-d3c40895906d ro vga=733

Note: The files may contain UUIDs already. Also note that you specifying "root (hdX,X) is also not required when using UUIDs.

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:

# (0) Arch Linux
title  Arch Linux (first drive)
root   (hd0,0)
kernel /boot/vmlinuz26 root=/dev/sda1 ro
initrd /boot/kernel26.img

As well as

# (1) Arch Linux
title  Arch Linux (second drive)
root   (hd0,0)
kernel /boot/vmlinuz26 root=/dev/sdb1 ro
initrd /boot/kernel26.img

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)
  • Find unique information pertaining to your usb key. I chose `SYSFS{model}=="DataTraveler 2.0"`
  • Make a new file: /etc/udev/udev.rules/10-my-usb-key.rules and insert: KERNEL=="sd**", SYSFS{product}=="DataTraveler 2.0", SYMLINK+="WHATEVERYOUWANTOTCALLIT%n" (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.
  • If so, edit /etc/fstab, replacing your old sdx with the new symlinks.

Optimizing for the lifespan of flash memory

See Also