Renseigner automatiquement l'UUID d'une partition dans le fichier /etc/fstab

Afficher ou sauvegarder le fichier /etc/fstab avant toute manipulation

# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Feb  8 10:04:33 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=8db4ff33-9c01-42c5-89c9-851b58ad4599 /                       xfs     defaults        0 0
UUID=d107b673-8b5a-4171-b30c-d03bd72b9e55 /boot                   xfs     defaults        0 0
UUID=3AC0-FCC8                            /boot/efi               vfat    umask=0077,shortname=winnt 0 2
UUID=fe4c581c-4b22-49d7-94a7-040600a98baa /var/log                xfs     defaults        0 0
UUID=33bb87c8-90e6-4107-9d70-0c4bd2f5b852 none                    swap    defaults        0 0
UUID=5654158c-dc3e-4c69-a5f8-64c6dc7c8b08 /home                   xfs     defaults        0 0
no-device                                 /tmpfs                  tmpfs   rw,seclabel,relatime 0 0

Afficher la liste des partitions ainsi que les UUIDs

# blkid
/dev/sda5: UUID="8db4ff33-9c01-42c5-89c9-851b58ad4599" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="85254d0d-f5c4-6245-aae7-fd870d97413c"
/dev/sda1: UUID="3AC0-FCC8" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="fc72f64e-a700-459a-ba6b-0dcaa7016747"
/dev/sda2: UUID="d107b673-8b5a-4171-b30c-d03bd72b9e55" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="736002d1-0dcf-4825-8ebd-caa436560505"
/dev/sda3: UUID="33bb87c8-90e6-4107-9d70-0c4bd2f5b852" TYPE="swap" PARTUUID="6d3ef976-e9fb-425f-b7e1-7f1ff84d51e0"
/dev/sda4: UUID="fe4c581c-4b22-49d7-94a7-040600a98baa" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="894d6ef9-cfa0-4945-a3db-fefdd0c94162"
/dev/sdb1: UUID="5654158c-dc3e-4c69-a5f8-64c6dc7c8b08" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="3a6000f2-01"
/dev/sdc1: UUID="c822d42a-a492-4e80-8b2a-e929275b955c" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="51229054-01"
/dev/sdd1: UUID="921dbe26-cc98-45bd-9445-4c87ff1f4ec0" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="d8576e95-01"

Je souhaite monter la partition /dev/sdd1 dans le dossier /mnt/207, je vais copier l'UUID de la partition directement dans le fichier /etc/fstab

# echo UUID=$(blkid -o value -s UUID /dev/sdd1) >> /etc/fstab

Reste à modifier le fichier /etc/fstab pour y ajouter les informations supplémentaires

# vim /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Feb  8 10:04:33 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=8db4ff33-9c01-42c5-89c9-851b58ad4599 /                       xfs     defaults        0 0
UUID=d107b673-8b5a-4171-b30c-d03bd72b9e55 /boot                   xfs     defaults        0 0
UUID=3AC0-FCC8                            /boot/efi               vfat    umask=0077,shortname=winnt 0 2
UUID=fe4c581c-4b22-49d7-94a7-040600a98baa /var/log                xfs     defaults        0 0
UUID=33bb87c8-90e6-4107-9d70-0c4bd2f5b852 none                    swap    defaults        0 0
UUID=5654158c-dc3e-4c69-a5f8-64c6dc7c8b08 /home                   xfs     defaults        0 0
no-device                                 /tmpfs                  tmpfs   rw,seclabel,relatime 0 0
UUID=921dbe26-cc98-45bd-9445-4c87ff1f4ec0 /mnt/207                xfs     defaults        0 0

Reste à monter la partition

# mount -a

 

Etiquettes: