diff --git a/bordel-a-patrick.md b/bordel-a-patrick.md index 8f5ae2b..ea66e19 100644 --- a/bordel-a-patrick.md +++ b/bordel-a-patrick.md @@ -363,3 +363,131 @@ mkfs.ext4 -L "root$PARTCODE" "${DEVICE}2" mkswap -L "swap$PARTCODE" "${DEVICE}3" mkfs.ext4 -L "export$PARTCODE" "${DEVICE}4" ``` + +Le résultat du script ci-dessus a été : +``` +patrick@deneb:~/bin$ sudo bash format_disque2.sh +[sudo] Mot de passe de patrick : +Setting name! +partNum is 0 +Setting name! +partNum is 1 +Setting name! +partNum is 2 +Setting name! +partNum is 3 +Warning: The kernel is still using the old partition table. +The new table will be used at the next reboot or after you +run partprobe(8) or kpartx(8) +The operation has completed successfully. +/dev/sdb1 : 2 octets ont été effacés à l'index 0x00000438 (ext4) : 53 ef +mke2fs 1.45.5 (07-Jan-2020) +En train de créer un système de fichiers avec 7864320 4k blocs et 1966080 i-noeuds. +UUID de système de fichiers=8cc4aebd-8a8d-4236-9a4b-d0ece4892629 +Superblocs de secours stockés sur les blocs : +32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, +4096000 +Allocation des tables de groupe : complété +Écriture des tables d'i-noeuds : complété +Création du journal (32768 blocs) : complété +Écriture des superblocs et de l'information de comptabilité du système de +fichiers : complété +Configure l'espace d'échange (swap) en version 1, taille = 4 GiB (4294963200 octets) +LABEL=swap2, UUID=22a00dae-e72a-4d05-a630-d678661d8a7f +mke2fs 1.45.5 (07-Jan-2020) +En train de créer un système de fichiers avec 30159313 4k blocs et 7544832 i-noeuds. +UUID de système de fichiers=da2019e2-8768-4963-898f-f0834e5cd52b +Superblocs de secours stockés sur les blocs : +32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, +4096000, 7962624, 11239424, 20480000, 23887872 +Allocation des tables de groupe : complété +Écriture des tables d'i-noeuds : complété +Création du journal (131072 blocs) : complété +Écriture des superblocs et de l'information de comptabilité du système de +fichiers : complété +``` + +Et la nouvelle configuration des disques : + +``` +br@deneb:/$ 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 grub 2 1M 0 05050503-9504-4e22-9a94-56af02dbe811 +├─sdb2 part ext4 /mnt/hd/root2 ext4 root 2 root2 30G 0 8cc4aebd-8a8d-4236-9a4b-d0ece4892629 7f049ffd-31a6-4429-a10a-764647f345a4 +├─sdb3 part swap swap 2 swap2 4G 0 22a00dae-e72a-4d05-a630-d678661d8a7f 59d51ca0-010c-4d09-a98b-6081a4a12c42 +└─sdb4 part ext4 ext4 export 2 export2 115G 0 da2019e2-8768-4963-898f-f0834e5cd52b fb2f7577-d8d4-41ae-98bc-dee824fd8d7f +sr0 rom 1024M 0 +``` + +## Copie du disque sda vers sdb +Récupérer le script sur mon [serveur gitea](https://git.bodiccea.tk/bruno/Tools/src/branch/master/bash/dup-live-disk.sh) ou sur [github](https://github.com/braoult/Tools/blob/master/bash/dup-live-disk.sh). + +### Test du script en dry run +Patrick: Lancer la commande `sudo ./dup-live-disk.sh --dry-run sdb |& tee /tmp/dry-run.txt`. + +### Recopie proprement dite +Patrick: Lancer la commande `sudo dup-live-disk.sh --yes sdb` |& tee /tmp/we-go.txt. + +Output: + +``` +br@deneb:~$ cat /tmp/we-go.txt +found LABEL=root1 DEV=/dev/sda1 FSTYPE=ext4 +found LABEL=swap1 DEV=/dev/sda5 FSTYPE=swap +found LABEL=export1 DEV=/dev/sda6 FSTYPE=ext4 +rootlabel=root maybe=root2 +Found destination root label: root2 +Looking for [root2] label : DEV=/dev/sdb2 DISK=/dev/sdb FSTYPE=ext4 +Looking for [swap2] label : DEV=/dev/sdb3 DISK=/dev/sdb FSTYPE=swap +Looking for [export2] label : DEV=/dev/sdb4 DISK=/dev/sdb FSTYPE=ext4 +DEV1 DEV2 LABEL1 LABEL2 FS1 FS2 SVALID? DVALID? ROOT +/dev/sda1 /dev/sdb2 root1 root2 ext4 ext4 y y * +/dev/sda5 /dev/sdb3 swap1 swap2 swap swap n n +/dev/sda6 /dev/sdb4 export1 export2 ext4 ext4 y y +Info: Found target fstab (fstab.root2) in SRC root partition (/mnt/root1/etc). +*** Copy /mnt/root1/ to /mnt/root2 [y/n/q] ? yes +MariaDB/MySQL is inactive. +rsync -axH --filter=dir-merge .rsync-disk-copy --delete --delete-excluded /mnt/root1/ /mnt/root2 +***** rsync status=0 + +*** Link /mnt/root2/etc/fstab.root2 to /mnt/root2/etc/fstab [y/n/q] ? yes +ln -f /mnt/root2/etc/fstab.root2 /mnt/root2/etc/fstab +skipping label swap +*** Copy /mnt/export1/ to /mnt/export2 [y/n/q] ? yes +MariaDB/MySQL is inactive. +rsync -axH --filter=dir-merge .rsync-disk-copy --delete --delete-excluded /mnt/export1/ /mnt/export2 +***** rsync status=0 + +*** install grub on /dev/sdb (root label: root2) [y/n/q] ? yes +installing grub on /dev/sdb... +mount -o bind /sys /mnt/root2/sys +mount -o bind /proc /mnt/root2/proc +mount -o bind /dev /mnt/root2/dev +chroot /mnt/root2 update-grub +Sourcing file `/etc/default/grub' +Sourcing file `/etc/default/grub.d/init-select.cfg' +Création du fichier de configuration GRUB… +Image Linux trouvée : /boot/vmlinuz-5.4.0-120-generic +Image mémoire initiale trouvée : /boot/initrd.img-5.4.0-120-generic +Image Linux trouvée : /boot/vmlinuz-5.4.0-117-generic +Image mémoire initiale trouvée : /boot/initrd.img-5.4.0-117-generic +Image Linux trouvée : /boot/vmlinuz-5.4.0-77-generic +Image mémoire initiale trouvée : /boot/initrd.img-5.4.0-77-generic +Found memtest86+ image: /boot/memtest86+.elf +Found memtest86+ image: /boot/memtest86+.bin +Ubuntu 20.04.4 LTS (20.04) trouvé sur /dev/sda1 +fait +chroot /mnt/root2 grub-install /dev/sdb +Installation pour la plate-forme i386-pc. +Installation terminée, sans erreur. +umount /mnt/root2/dev +umount /mnt/root2/proc +umount /mnt/root2/sys +br@deneb:~$ +```