Contents
Rigenerare fstab
ToDo translation in progress
Per mostrare una partizione appena creata (ad esempio sda6 o sdb7) che non appare in fstab o si vuole montare, digitare come utente il seguente comando in una console:
ls -l /dev/disk/by-uuid
Verrà mostrato un output come questo:
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 348ea9e6-7879-4332-8d7a-915507574a80 -> ../../sda4 lrwxrwxrwx 1 root root 10 2007-05-27 23:42 610aaaeb-a65e-4269-9714-b26a1388a106 -> ../../sda2 lrwxrwxrwx 1 root root 10 2007-05-27 23:42 857c5e63-c9be-4080-b4c2-72d606435051 -> ../../sda5 lrwxrwxrwx 1 root root 10 2007-05-27 23:42 a83b8ede-a9df-4df6-bfc7-02b8b7a5f1f2 -> ../../sda1 lrwxrwxrwx 1 root root 10 2007-05-27 23:42 ad662d33-6934-459c-a128-bdf0393e0f44 -> ../../sda6
In questo esempio ad662d33-6934-459c-a128-bdf0393e0f44 è la voce mancante, il passo successivo è inserire l'UUID della partizione in /etc/fstab. Usare un editor di testo (come kate o kwrite) con privilegi di root:
# <device file system> <mount point> <type> <options> <dump> <pass> UUID=ad662d33-6934-459c-a128-bdf0393e0f44 /media/sda6 ext3 auto,users,exec 0 2
Nota: il nome del punto di montaggio (in fstab) deve essere una directory esistente.
Descrizione: UUID, etichettare partizioni e fstab
La denominazione persistente del device a blocchi è stata resa possibile dall'introduzione di udev con alcuni vantaggi rispetto a quella basata sul bus.
Nel frattempo che le distribuzioni Linux e udev sono in evoluzione e il rilevamento dell'hardware è sempre più affidabile, ci sono anche una serie di nuovi problemi e modifiche:
- Avendo più di un controller sata, scsi o ide e l'ordine in cui vengono aggiunti è casuale, questo può portare a nomi di dispositivo come hdX e hdY a cambiare in modo casuale ad ogni avvio; lo stesso vale per sdX e sdY. La denominazione persistente permette di non preoccuparsene più.
- Con l'introduzione della nuova gestione dei pata da parte di libata, tutti i device ide hdX diventeranno in futuro sdX. Anche qui, con la denominazione persistente non si noterà nemmeno.
- Le macchine con controller sia sata che ide sono oggigiorno comuni, con le modifiche di libata menzionate prima il primo problema che diverrà sempre più frequente è che entrambi verranno identificati come sdX.
- Quando si tratta di udev e multipath, le grosse macchine con CPU veloci e adattatori Fibre Channel, switch FC con carico a latenza variabile e archiviazione di dati, controller SCSI, schede di reta ad alte prestazioni, possono avere problemi di asincronia con un ordine di rilevamento e assegnazione dei nomi dei device in fase di avvio quasi imprevedibile.
Ci sono altre ragioni ma queste sono al momento, e nel prossimo futuro, le più critiche; ecco perché Debian incoraggia a modificare la configurazione usando il sistema della denominazione persistente.
I quattro sistemi differenti per la denominazione persistente
Denominazione persistente per UUID
UUID sta per Universally Unique Identifier ed è un meccanismo per fornire ad ogni filesystem (non le partizioni) un identificativo univoco, è progettato affinché le collisioni siano improbabili. Tutti i filesystem Linux (incluso lo swap, nonostante non sia assegnato in modo predefinito usando l'installatore debian) supportano UUID; FAT e NTFS no, ma vengono comunque elencati con un identificatore:
$ /bin/ls -lF /dev/disk/by-uuid/
total 0 lrwxrwxrwx 1 root root 10 Oct 16 10:27 2d781b26-0285-421a-b9d0-d4a0d3b55680 -> ../../sda1 lrwxrwxrwx 1 root root 10 Oct 16 10:27 31f8eb0d-612b-4805-835e-0e6d8b8c5591 -> ../../sda7 lrwxrwxrwx 1 root root 10 Oct 16 10:27 3FC2-3DDB -> ../../sda6 lrwxrwxrwx 1 root root 10 Oct 16 10:27 5090093f-e023-4a93-b2b6-8a9568dd23dc -> ../../sda2 lrwxrwxrwx 1 root root 10 Oct 16 10:27 912c7844-5430-4eea-b55c-e23f8959a8ee -> ../../sda5 lrwxrwxrwx 1 root root 10 Oct 16 10:27 B0DC1977DC193954 -> ../../sdb1 lrwxrwxrwx 1 root root 10 Oct 16 10:27 bae98338-ec29-4beb-aacf-107e44599b2e -> ../../sdb2
Come si può vedere, le partizioni fat e ntfs hanno nomi più corti (sda6 e sdb1), ma sono comunque presenti con un uuid.
Purtroppo sulle grosse macchine potrebbero accadere delle race condition e l'UUID del filesystem potrebbe essere assegnato più volte a device differenti, Linux potrebbe sceglierne uno (in modo casuale) che trova al momento del rilevamento di udev. Ad esempio potrebbe rilevare lo stesso UUID di /dev/sda1 e /dev/dm-1, quindi grub selezionerebbe /dev/dm-1 mentre /etc/fstab usa /dev/sda1, con la conseguenza di non terminare l'avvio a causa del "dispositivo occupato".
Come trovare l'UUID del device
~# blkid /dev/sda1: UUID="87f2b245-6ab3-4021-bf07-d069b4d387a1" TYPE="ext3" /dev/sda2: TYPE="swap" /dev/sda3: UUID="a6f7a63f-71ac-4361-b49a-39d62b06f18a" TYPE="ext3"
Si può notare che la partizione di swap non ha un UUID, l'installatore di Debian Lenny usa una versione di partman che non ne attribuisce uno, lo si può ottenere con mkswap.
Come assegnare un UUID alla partizione di swap
Disattivare in l'attuale swap:
~# swapoff /dev/sda2
Ricrearla ottenendo l'UUID, riattivarla e verificare il risultato:
~# mkswap /dev/sda2
Setting up swapspace version 1, size = 1998737 kB
no label, UUID=7cdfeb21-613b-4588-abb5-9d4049854e9a
corp-bsa-exp-nuvem01:~# blkid
/dev/sda1: UUID="87f2b245-6ab3-4021-bf07-d069b4d387a1" TYPE="ext3"
/dev/sda2: TYPE="swap" UUID="7cdfeb21-613b-4588-abb5-9d4049854e9a"
/dev/sda3: UUID="a6f7a63f-71ac-4361-b49a-39d62b06f18a" TYPE="ext3"
~# swapon /dev/sda2
~# free
total used free shared buffers cached
Mem: 33017956 298700 32719256 0 17060 148668
-/+ buffers/cache: 132972 32884984
Swap: 1951888 0 1951888
Denominazione persistente per etichetta
Quasi ogni tipo di filesystem può avere un'etichetta, tutte le partizioni che ne hanno una sono elencate nella directory /dev/disk/by-label:
$ ls -lF /dev/disk/by-label
lrwxrwxrwx 1 root root 10 Oct 16 10:27 data -> ../../sdb2 lrwxrwxrwx 1 root root 10 Oct 16 10:27 data2 -> ../../sda2 lrwxrwxrwx 1 root root 10 Oct 16 10:27 fat -> ../../sda6 lrwxrwxrwx 1 root root 10 Oct 16 10:27 home -> ../../sda7 lrwxrwxrwx 1 root root 10 Oct 16 10:27 root -> ../../sda1 lrwxrwxrwx 1 root root 10 Oct 16 10:27 swap -> ../../sda5 lrwxrwxrwx 1 root root 10 Oct 16 10:27 windows -> ../../sdb1
Anche se le etichette possono avere nomi riconoscibili, è necessario prestare la massima attenzione ad evitare conflitti.
Si possono modificare le etichette dei filesystems con questi comandi:
* swap: mkswap -L <etichetta> /dev/XXX
* ext2/ext3: e2label /dev/XXX <etichetta>
* reiserfs: reiserfstune -l <etichetta> /dev/XXX
* jfs: jfs_tune -L <etichetta> /dev/XXX
* xfs: xfs_admin -L <etichetta> /dev/XXX
* fat/vfat: in Linux non c'è nessuno strumento per cambiare etichetta, si usi {{{mkdosfs -n <etichetta> <altre opzioni>durante la creazione del filesystem* ntfs: ntfslabel /dev/XXX <etichetta> o modificarla da Windows }}}
Attenzione: le etichette devono essere univoche, sono applicabili allo stesso modo a penne e hard disk USB o firewire; per le partizioni UN*X il sistema con etichetta o UUID è preferibile a quello di /dev/disk/by-*/ .
Denominazione persistente per id
by-id crea un nome univoco in base al numero seriale hardware, sono destinati a rimanere immutati ad una certa configurazione hardware.
~# ls -lh /dev/disk/by-id/ total 0 lrwxrwxrwx 1 root root 10 2010-10-20 13:52 dm-name-grupo1-lvstripe1 -> ../../dm-8 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-name-mpath0 -> ../../dm-0 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-name-mpath1 -> ../../dm-1 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-name-mpath2 -> ../../dm-2 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-name-mpath3 -> ../../dm-3 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-name-mpath4 -> ../../dm-4 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-name-mpath5 -> ../../dm-5 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-name-mpath6 -> ../../dm-6 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-name-mpath7 -> ../../dm-7 lrwxrwxrwx 1 root root 10 2010-10-20 13:52 dm-uuid-LVM-OaDwNcuwdzuuZYAcrbeKNdYsE237BKX2YIEdUN5CsSgeU7WNn5dhtiQPBP9uHU25 -> ../../dm-8 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-uuid-mpath-36005076308ffc36c000000000000000c -> ../../dm-0 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-uuid-mpath-36005076308ffc36c000000000000000d -> ../../dm-1 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-uuid-mpath-36005076308ffc36c000000000000000e -> ../../dm-2 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-uuid-mpath-36005076308ffc36c000000000000000f -> ../../dm-3 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-uuid-mpath-36005076308ffc36c0000000000000112 -> ../../dm-4 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-uuid-mpath-36005076308ffc36c0000000000000113 -> ../../dm-5 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-uuid-mpath-36005076308ffc36c0000000000000114 -> ../../dm-6 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 dm-uuid-mpath-36005076308ffc36c0000000000000115 -> ../../dm-7 lrwxrwxrwx 1 root root 9 2010-10-20 13:51 scsi-360026b9038e49f001270c8b707980d5c -> ../../sda lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-360026b9038e49f001270c8b707980d5c-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-360026b9038e49f001270c8b707980d5c-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-360026b9038e49f001270c8b707980d5c-part3 -> ../../sda3 lrwxrwxrwx 1 root root 9 2010-10-20 13:51 scsi-36005076308ffc36c000000000000000c -> ../../sdr lrwxrwxrwx 1 root root 9 2010-10-20 13:51 scsi-36005076308ffc36c000000000000000d -> ../../sdc lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-36005076308ffc36c000000000000000e -> ../../sdab lrwxrwxrwx 1 root root 9 2010-10-20 13:51 scsi-36005076308ffc36c000000000000000f -> ../../sdu lrwxrwxrwx 1 root root 9 2010-10-20 13:51 scsi-36005076308ffc36c0000000000000112 -> ../../sdn lrwxrwxrwx 1 root root 9 2010-10-20 13:51 scsi-36005076308ffc36c0000000000000113 -> ../../sdo lrwxrwxrwx 1 root root 9 2010-10-20 13:51 scsi-36005076308ffc36c0000000000000114 -> ../../sdp lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-36005076308ffc36c0000000000000115 -> ../../sdag lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-mpath0 -> ../../dm-0 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-mpath1 -> ../../dm-1 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-mpath2 -> ../../dm-2 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-mpath3 -> ../../dm-3 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-mpath4 -> ../../dm-4 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-mpath5 -> ../../dm-5 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-mpath6 -> ../../dm-6 lrwxrwxrwx 1 root root 10 2010-10-20 13:51 scsi-mpath7 -> ../../dm-7
Denominazione persistente per percorso
by-path crea un nome univoco in base al percorso fisico più corto (secondo sysfs), contengono stringhe che indicano a quale sottosistema appartengono, non sono adatte a risolvere i problemi discussi all'inizio di questo articolo e non verranno approfondite.
Abilitare la denominazione persistente
Having chosen which naming method you'd like to use, let's now enable persistent naming for your system:
In fstab
Enabling persistent naming in /etc/fstab is easy; just replace the device name in the first column by the new persistent name. In my example I would replace /dev/sda7 by one of the following:
/dev/disk/by-label/home or /dev/disk/by-uuid/31f8eb0d-612b-4805-835e-0e6d8b8c5591
Do so for all the partitions in your fstab file.
Instead of giving the device explicitly, one may indicate the filesystem that is to be mounted by its UUID or volume label, writing LABEL=<label> or UUID=<uuid>, for example:
LABEL=Boot
or
UUID=3e6be9de-8139-11d1-9106-a43f08d823a6
Persistent Naming in the boot manager
To use persistent names in your boot manager, all of the following prerequisites have to be met:
- You are using a mkinitcpio initramfs image
- You have udev enabled in /etc/mkinitcpio.conf
- When your initramfs image was generated, version 101-3 or greater of klibc-udev was installed (persistent naming is broken in any earlier version). If you are updating klibc-udev from an earlier version and want to use persistent naming, regenerate your initramfs image before you reboot.
In the above example, /dev/sda1 is the root partition. In the grub menu.lst file, the kernel line looks like this:
kernel /boot/vmlinuz26 root=/dev/sda1 vga=0x318 ro
Depending on which naming scheme you prefer, change it to one of the following:
kernel /boot/vmlinuz26 root=/dev/disk/by-label/root vga=0x318 ro
or
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/2d781b26-0285-421a-b9d0-d4a0d3b55680 vga=0x318 ro
There is an alternative way to use the label embedded in the filesystem. For example if (as above) the filesystem in /dev/sda1 is labelled "root", you would give this line to grub:
kernel /boot/vmlinuz26 root=LABEL=root vga=0x318 ro
Make a backup:
corp-bsa-exp-nuvem02:~# cp /boot/grub/menu.lst /boot/grub/menu.lst.old1
Use the /dev/disk/by-id and edit /boot/grub/menu.lst
## AFM 22oct2010 ## kopt=root=/dev/sda3 ro # kopt=root=/dev/disk/by-id/scsi-360026b9038e754001270c9de079bca7c-part3 ro rootdelay=15 nodmraid
Update menu.lst using the same script of kernel packages:
:~# update-grub Searching for GRUB installation directory ... found: /boot/grub Searching for default file ... found: /boot/grub/default Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst Searching for splash image ... none found, skipping ... Found kernel: /vmlinuz-2.6.26-1-amd64 Updating /boot/grub/menu.lst ... done :~#
