307 lines
12 KiB
Markdown
307 lines
12 KiB
Markdown
## Réparation du bordel de deneb
|
|
|
|
### installation de Emacs (!!)
|
|
```
|
|
br@deneb:~$ sudo apt-get install emacs-nox
|
|
```
|
|
|
|
Tu pourras le virer après.
|
|
|
|
### État des lieux
|
|
|
|
```
|
|
br@deneb:~$ lsblk.sh
|
|
NAME TYPE FSTYPE MOUNTPOINT PARTLABEL LABEL SIZE RO UUID PARTUUID
|
|
sda disk 465.8G 0
|
|
├─sda1 part ext4 / 28.6G 0 33059c17-761e-4c5f-ab9d-035976e0bfc6 b827da31-01
|
|
├─sda2 part 1K 0 b827da31-02
|
|
├─sda5 part swap [SWAP] 1.9G 0 e6be26ca-411c-43e4-aa11-ae03af96720c b827da31-05
|
|
└─sda6 part ext4 /export 435.2G 0 91e5624c-de87-49ac-97b9-2f0fa618609f b827da31-06
|
|
sdb disk 149.1G 0
|
|
├─sdb1 part 1K 0 6facf23c-01
|
|
├─sdb5 part ext4 /systemXena 18.6G 0 346332fb-c6a6-4772-ac7c-91e3adf5c790 6facf23c-05
|
|
├─sdb6 part swap [SWAP] 2.3G 0 67bbbe64-e52f-44ee-b9ea-d8881247ffb5 6facf23c-06
|
|
└─sdb7 part ext4 /backup-damia 128.1G 0 6d2994d9-2209-4360-b27d-b73f06d86c87 6facf23c-07
|
|
sr0 rom 1024M 0
|
|
```
|
|
|
|
### Nommage des disques (labels)
|
|
Ajout d'un label pour les partitions du premier disque, avec le suffixe "1" (root1, export1, swap1) :
|
|
|
|
```
|
|
br@deneb:~$ sudo e2label /dev/sda1 root1
|
|
br@deneb:~$ sudo swaplabel -L swap1 /dev/sda5
|
|
br@deneb:~$ sudo e2label /dev/sda6 export1
|
|
```
|
|
|
|
Ajout d'un label pour les partitions du second disque ("Xena"), avec le suffixe "2" :
|
|
|
|
```
|
|
br@deneb:~$ sudo e2label /dev/sdb7 export2
|
|
br@deneb:~$ sudo e2label /dev/sdb5 root2
|
|
br@deneb:~$ sudo swaplabel -L swap2 /dev/sdb6
|
|
```
|
|
|
|
Nouvelle situation :
|
|
|
|
```
|
|
br@deneb:~$ !lsb
|
|
lsblk.sh
|
|
NAME TYPE FSTYPE MOUNTPOINT PARTLABEL LABEL SIZE RO UUID PARTUUID
|
|
sda disk 465.8G 0
|
|
├─sda1 part ext4 / root1 28.6G 0 33059c17-761e-4c5f-ab9d-035976e0bfc6 b827da31-01
|
|
├─sda2 part 1K 0 b827da31-02
|
|
├─sda5 part swap [SWAP] swap1 1.9G 0 e6be26ca-411c-43e4-aa11-ae03af96720c b827da31-05
|
|
└─sda6 part ext4 /export export1 435.2G 0 91e5624c-de87-49ac-97b9-2f0fa618609f b827da31-06
|
|
sdb disk 149.1G 0
|
|
├─sdb1 part 1K 0 6facf23c-01
|
|
├─sdb5 part ext4 /systemXena root2 18.6G 0 346332fb-c6a6-4772-ac7c-91e3adf5c790 6facf23c-05
|
|
├─sdb6 part swap [SWAP] swap2 2.3G 0 67bbbe64-e52f-44ee-b9ea-d8881247ffb5 6facf23c-06
|
|
└─sdb7 part ext4 /backup-damia export2 128.1G 0 6d2994d9-2209-4360-b27d-b73f06d86c87 6facf23c-07
|
|
sr0 rom 1024M 0
|
|
```
|
|
|
|
### Correction du fstab du second disque
|
|
On ne pas monter ici les partitions du premier disque, on verra ,ca plus tard avec l'`automounter` (`autofs`).
|
|
|
|
```
|
|
br@deneb:~/.emacs.d$ sudo emacs /systemXena/etc/fstab
|
|
br@deneb:~/.emacs.d$ cat /systemXena/etc/fstab
|
|
# /etc/fstab: static file system information.
|
|
#
|
|
# Use 'blkid' to print the universally unique identifier for a
|
|
# device; this may be used with UUID= as a more robust way to name devices
|
|
# that works even if disks are added and removed. See fstab(5).
|
|
#
|
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
LABEL=root2 / ext4 errors=remount-ro 0 1
|
|
LABEL=export2 /export ext4 defaults 0 2
|
|
|
|
# swap was on /dev/sda2 during installation
|
|
LABEL=swap2 none swap nofail,sw,pri=0 0 0
|
|
LABEL=swap1 none swap nofail,sw,pri=0 0 0
|
|
```
|
|
|
|
### Ajustement de /home sur le second disque (Xena)
|
|
On déplace `/systemXena/home` dans `/backup-damia` (le futur `/export`).
|
|
```
|
|
br@deneb:/backup-damia$ sudo mv /systemXena/home/ /backup-damia/
|
|
```
|
|
Et on fait pointer `/systemXena/home` vers `./export/home` :
|
|
|
|
```
|
|
br@deneb:~$ cd /systemXena/
|
|
br@deneb:/systemXena$ ln -s ./export/home
|
|
br@deneb:/systemXena$ ls -l home
|
|
lrwxrwxrwx 1 root root 13 Jun 21 22:45 home -> ./export/home
|
|
```
|
|
|
|
Maintenant, on devrait pouvoir booter sur Xena.
|
|
|
|
### autofs
|
|
|
|
#### Installation
|
|
```
|
|
$ sudo apt-get install autofs
|
|
```
|
|
|
|
#### Setup
|
|
Nous allons utiliser les labels pour monter automatiquement les partitions locales, si on essaie d'y accéder. Les partitions seront automatiquement démontées 1 minute après le dernier accès.
|
|
|
|
##### /etc/auto.master
|
|
Fichier `/etc/auto.master`. C'est le fichier principal. On vire tout ce qui existe, et on ajoute la ligne :
|
|
|
|
```
|
|
/mnt/hd /etc/auto.hd --timeout 60 --ghost
|
|
```
|
|
Ça veut dire que l'automounter sera actif sur `/mnt/hd`, contrôlé par la configuration décrite dans `/etc/auto.hd`. On précise aussi le timeout de démontage (60 secondes), et l'option `--ghost` qui permettra de voir les répertoires possibles dans `/mnt/hd`, même s'ils ne sont pas montés. L'option `--ghost` n'aura aucun effet ici,car nous utilisons une map indirecte dans /etc/auto.hd.
|
|
|
|
##### /etc/auto.hd
|
|
On y met :
|
|
```
|
|
* -fstype=auto,defaults :LABEL=&
|
|
```
|
|
On dit que pour tous les point de montage `*` (dans /mnt/hd), on effectue un montage avec les options par défaut, et que la source du montage est une partition de label indentique à `*`. Par exemple, si une partition a pour label `root1`, elle sera montée dans `/mnt/hd/root1`.
|
|
|
|
Puisque nous utilisons `*` pour cette map, l'option `--ghost` n'aura aucun effet.
|
|
|
|
##### Redémarrage de autofs
|
|
|
|
```
|
|
br@deneb:/mnt$ sudo systemctl restart autofs
|
|
```
|
|
Voilà. C'est fini.
|
|
|
|
Testons:
|
|
|
|
```
|
|
br@deneb:~$ cd /mnt
|
|
|
|
br@deneb:/mnt$ ls -l hd
|
|
total 0
|
|
|
|
br@deneb:/mnt$ ls hd/root2
|
|
bin/ export/ initrd.img.old@ mnt/ sbin/ tmp/
|
|
boot/ export1/ lib/ opt/ snap/ usr/
|
|
cdrom/ export2/ lib64/ proc/ srv/ var/
|
|
dev/ home@ lost+found/ root/ sys/ vmlinuz@
|
|
etc/ initrd.img@ media/ run/ system1Xenal/ vmlinuz.old@
|
|
|
|
br@deneb:/mnt$ ls -l hd
|
|
total 0
|
|
drwxr-xr-x 2 root root 0 Jun 22 10:26 root2/
|
|
|
|
br@deneb:/mnt$ df.sh
|
|
Filesystem 1K-blocks Used Available Use% Mounted on
|
|
/dev/sda1 29396988 19004928 8875724 69% /
|
|
/dev/sdb7 132076960 101520 125243256 1% /backup-damia
|
|
/dev/sdb5 19091584 5477272 12621444 31% /systemXena
|
|
/dev/sda6 448172912 316800084 108537220 75% /export
|
|
/dev/sdb5 19091584 5477272 12621444 31% /mnt/hd/root2
|
|
|
|
br@deneb:/mnt$ sleep 60
|
|
|
|
br@deneb:/mnt$ df.sh
|
|
Filesystem 1K-blocks Used Available Use% Mounted on
|
|
/dev/sda1 29396988 19004928 8875724 69% /
|
|
/dev/sdb7 132076960 101520 125243256 1% /backup-damia
|
|
/dev/sdb5 19091584 5477272 12621444 31% /systemXena
|
|
/dev/sda6 448172912 316800108 108537196 75% /export
|
|
```
|
|
##### Création de liens dans /mnt pour faciliter l'accès aux partitions :
|
|
```
|
|
br@deneb:/mnt$ for i in {root,export}{1,2}; do
|
|
> sudo ln -s hd/$i
|
|
> done
|
|
```
|
|
|
|
##### Nettoyage du fstab
|
|
On vire les montages en dur, hormis `/`, `/export`, et les partitions de swap. On en profite pour remplacer `UUID=` par `LABEL=`.
|
|
|
|
```
|
|
br@deneb:/mnt$ sudo emacs /etc/fstab
|
|
br@deneb:/mnt$ cat /etc/fstab
|
|
# /etc/fstab: static file system information.
|
|
#
|
|
# Use 'blkid' to print the universally unique identifier for a
|
|
# device; this may be used with UUID= as a more robust way to name devices
|
|
# that works even if disks are added and removed. See fstab(5).
|
|
#
|
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
# / was on /dev/sda1 during installation
|
|
LABEL=root1 / ext4 errors=remount-ro 0 1
|
|
# /export was on /dev/sda6 during installation
|
|
label=export1 /export ext4 defaults 0 2
|
|
|
|
# swap was on /dev/sda5 during installation
|
|
LABEL=swap1 none swap nofail,sw,pri=0 0 0
|
|
# swap was on /dev/sdb6 during installation
|
|
LABEL=swap2 none swap nofail,sw,pri=0 0 0
|
|
|
|
# / correspond a /dev/sdb partition recevant le systeme de secours - ligne ajoutee pour ne pas utiliser le repertoire media
|
|
# UUID=346332fb-c6a6-4772-ac7c-91e3adf5c790 /systemXena ext4 defaults
|
|
# /export was on /dev/sdb7 during installation
|
|
#UUID=6d2994d9-2209-4360-b27d-b73f06d86c87 /backup-damia ext4 defaults 0 2
|
|
```
|
|
|
|
### Préparation de la duplication de disque sda -> sdb
|
|
Il faut que nous ayons un fstab prêt à l'emploi sur le disque source (`sda`).
|
|
|
|
```
|
|
|
|
/dev/sda6 448172912 316800108 108537196 75% /export
|
|
```
|
|
|
|
##### Création de liens dans /mnt pour faciliter l'accès aux partitions
|
|
```
|
|
br@deneb:/mnt$ for i in {root,export}{1,2}; do
|
|
> sudo ln -s hd/$i
|
|
> done
|
|
br@deneb:/mnt$ ls -l
|
|
total 0
|
|
lrwxrwxrwx 1 root root 10 Jun 22 10:33 export1 -> hd/export1/
|
|
lrwxrwxrwx 1 root root 10 Jun 22 10:33 export2 -> hd/export2/
|
|
drwxr-xr-x 6 root root 0 Jun 22 10:33 hd/
|
|
lrwxrwxrwx 1 root root 8 Jun 22 10:33 root1 -> hd/root1/
|
|
lrwxrwxrwx 1 root root 8 Jun 22 10:33 root2 -> hd/root2/
|
|
```
|
|
|
|
##### Nettoyage du fstab, et préparation de la duplication de disque sda -> sdb
|
|
On vire les montages en dur, hormis `/`, `/export`, et les partitions de swap. On en profite pour remplacer `UUID=` par `LABEL=`.
|
|
|
|
Il faut que nous ayons un fstab prêt à l'emploi sur le disque source (`sda`), que nous activerons lors de la copie sur sdb
|
|
|
|
```
|
|
br@deneb:/mnt$ sudo emacs /etc/fstab
|
|
br@deneb:/mnt$ cat /etc/fstab
|
|
# /etc/fstab: static file system information.
|
|
#
|
|
# Use 'blkid' to print the universally unique identifier for a
|
|
# device; this may be used with UUID= as a more robust way to name devices
|
|
# that works even if disks are added and removed. See fstab(5).
|
|
#
|
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
|
|
############ Une seule de ces deux sections doit être active
|
|
|
|
########## boot sur le second disque
|
|
LABEL=root1 / ext4 errors=remount-ro 0 1
|
|
LABEL=export1 /export ext4 defaults 0 2
|
|
|
|
########## boot sur le second disque
|
|
#LABEL=root2 / ext4 errors=remount-ro 0 1
|
|
#LABEL=export2 /export ext4 defaults 0 2
|
|
|
|
# swap
|
|
LABEL=swap1 none swap nofail,sw,pri=0 0 0
|
|
LABEL=swap2 none swap nofail,sw,pri=0 0 0
|
|
```
|
|
|
|
Maintenant on prépare un fstab utilisable quand on boote sur `sdb` dans le /etc de sda.
|
|
```
|
|
br@deneb:/mnt$ cd /etc
|
|
br@deneb:/etc$ sudo ln fstab fstab.root1
|
|
br@deneb:/etc$ sudo cp fstab fstab.root2
|
|
br@deneb:/etc$ sudo emacs fstab.root2
|
|
br@deneb:/etc$ cat fstab.root2
|
|
# /etc/fstab: static file system information.
|
|
#
|
|
# Use 'blkid' to print the universally unique identifier for a
|
|
# device; this may be used with UUID= as a more robust way to name devices
|
|
# that works even if disks are added and removed. See fstab(5).
|
|
#
|
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
|
|
############ Une seule de ces deux sections doit être active
|
|
|
|
########## boot sur le second disque
|
|
#LABEL=root1 / ext4 errors=remount-ro 0 1
|
|
#LABEL=export1 /export ext4 defaults 0 2
|
|
|
|
########## boot sur le second disque
|
|
LABEL=root2 / ext4 errors=remount-ro 0 1
|
|
LABEL=export2 /export ext4 defaults 0 2
|
|
|
|
# swap
|
|
LABEL=swap2 none swap nofail,sw,pri=0 0 0
|
|
LABEL=swap1 none swap nofail,sw,pri=0 0 0
|
|
|
|
br@deneb:/etc$ diff fstab.root{1,2}
|
|
12,13c12,13
|
|
< LABEL=root1 / ext4 errors=remount-ro 0 1
|
|
< LABEL=export1 /export ext4 defaults 0 2
|
|
---
|
|
> #LABEL=root1 / ext4 errors=remount-ro 0 1
|
|
> #LABEL=export1 /export ext4 defaults 0 2
|
|
16,17c16,17
|
|
< #LABEL=root2 / ext4 errors=remount-ro 0 1
|
|
< #LABEL=export2 /export ext4 defaults 0 2
|
|
---
|
|
> LABEL=root2 / ext4 errors=remount-ro 0 1
|
|
> LABEL=export2 /export ext4 defaults 0 2
|
|
20d19
|
|
< LABEL=swap1 none swap nofail,sw,pri=0 0 0
|
|
21a21
|
|
> LABEL=swap1 none swap nofail,sw,pri=0 0 0
|
|
```
|