linux 新版本硬盘顺序会发生变化,因此改为使用UUID做为分区标识。
如: sda/sdb/sdc, 增加一块硬盘后原sdb可能会变成sde
一、uuid 与挂载点
1、使用blkid命令获取UUID
#blkid
/dev/sda1: SEC_TYPE="msdos" UUID="F159-EA55" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="ed7d2e13-8197-4226-8fdc-47d4aa64aebb"
/dev/sda2: LABEL="boot" UUID="f7755604-99f2-4d94-ab1a-47b14def7e26" TYPE="xfs" PARTUUID="627c028f-bf10-4705-b465-d5118d8ee67d"
/dev/sda3: UUID="Bs0vJv-cena-E9eO-2WcM-iJNQ-26Mr-fGG1pr" TYPE="LVM2_member" PARTUUID="18c50ff9-0e0d-40ac-8e2a-4f7f768347ed"
/dev/mapper/cl-root: UUID="b2f57437-ba99-4a2d-9c82-a41037aa0e38" TYPE="xfs"
/dev/mapper/cl-swap: UUID="2930b30d-3039-442d-a210-da1d7775652e" TYPE="swap"
/dev/mapper/cl-data: LABEL="data" UUID="cfc65b4e-0ca4-4b48-934e-5f668a4fb3b5" TYPE="xfs"
查看/dev目录获取UUID
#ll /dev/disk/by-uuid/
lrwxrwxrwx 1 root root 10 11月 25 19:56 2930b30d-3039-442d-a210-da1d7775652e -> ../../dm-1
lrwxrwxrwx 1 root root 10 11月 25 19:56 b2f57437-ba99-4a2d-9c82-a41037aa0e38 -> ../../dm-0
lrwxrwxrwx 1 root root 10 11月 25 19:56 cfc65b4e-0ca4-4b48-934e-5f668a4fb3b5 -> ../../dm-2
lrwxrwxrwx 1 root root 10 11月 25 19:56 F159-EA55 -> ../../sda1
lrwxrwxrwx 1 root root 10 11月 25 19:56 f7755604-99f2-4d94-ab1a-47b14def7e26 -> ../../sda2
修改/etc/fstab文件,使用uuid
# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Sep 8 16:38:29 2014
#
# 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
#
/dev/mapper/cl-root / xfs defaults 1 1
UUID=f7755604-99f2-4d94-ab1a-47b14def7e26 /boot xfs defaults 1 2
UUID=F159-EA55 /boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/cl-data /data xfs defaults,noatime,nobarrier 1 2
/dev/mapper/cl-swap swap swap defaults 0 0
...