硬盘的UUID是为系统中的存储设备提供的唯一标识字符串,不管设备是什么类型的,都需要在系统中添加新的设备,例如硬盘,如果添加错误会造成系统找不到硬盘启动失败,我们在挂在分区的过程中需要找到分区的UUID表示,写到fstab文件中,这样系统在启动的时候就能找到分区为UUID的表示,如果找不到就进不了系统页面,下面看一下如何找到分区的UUID表示。
第一种方法:
[[email protected] ~]# blkid
# blkid
/dev/vda1: UUID="1114fe9e-2309-4580-b183-d778e6d97397" TYPE="ext4"
/dev/vdb1: UUID="I8FHs4-lzBs-Yjcn-tXPo-qqhz-tmO4-K4fFwG" TYPE="LVM2_member" PARTLABEL="primary" PARTUUID="5f41def1-3bca-4f11-b85c-30530961eae0"
/dev/mapper/vg_data-lv_data: UUID="4eff369f-bbe8-4c4a-befd-be2e00dcf631" TYPE="ext4"
第二种方法:
[[email protected] ~]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
vda
└─vda1 ext4 1114fe9e-2309-4580-b183-d778e6d97397 /
vdb
└─vdb1 LVM2_member I8F
相关资源:...硬盘分区或文件系统的UUID的七种方法_查看磁盘uuid资源-CSDN文库 转自:https://blog.csdn.net/weixin_39610964/article/details/111814502查看磁盘的UUID
方法1:
root@ac810:~# blkid
/dev/sda2: UUID="4e87d18b-3223-4f9d-aa48-2bd450ad33d0" TYPE="ext4" PARTUUID="337a99de-78d8-4d7d-8f9c-c0ca59b373a8"
/dev/sda1: UUID="C095-90BB" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="57b0ee8e-072f-45ee-a93a-bc872b2ba875"
方法2:
root@ac810:~# tree /dev/disk/
/dev/disk/
├── by-id
│ ├── ata-FORESEE_128GB_SSD_MHV024Q002234 -> ../../sda
│ ├── ata-FORESEE_128GB_SSD_MHV024Q002234-part1 -> ../../sda1
│ ├── ata-FORESEE_128GB_SSD_MHV024Q002234-part2 -> ../../sda2
│ ├── wwn-0x53a5a270241e1253 -> ../../sda
│ ├── wwn-0x53a5a270241e1253-part1 -> ../../sda1
│ └── wwn-0x53a5a270241e1253-part2 -> ../../sda2
├── by-partlabel
│ └── EFI\x20System\x20Partition -> ../../sda1
├── by-partuuid
│ ├── 337a99de-78d8-4d7d-8f9c-c0ca59b373a8 -> ../../sda2
│ └── 57b0ee8e-072f-45ee-a93a-bc872b2ba875 -> ../../sda1
├── by-path
│ ├── pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0 -> ../../sda
│ ├── pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0-part1 -> ../../sda1
│ └── pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0-part2 -> ../../sda2
└── by-uuid
├── 4e87d18b-3223-4f9d-aa48-2bd450ad33d0 -> ../../sda2
└── C095-90BB -> ../../sda1
- 查看需要修改磁盘的格式化类型 TYPE;不同的类型使用的命令不一样
xfs格式的磁盘UUID修改
root@ac810:~# uuidgen | xargs xfs_admin /dev/sdc1 -U
ext2/3/4格式的磁盘UUID修改
root@ac810:~# uuidgen | xargs tune2fs /dev/sda2 -U
注意事项
不要轻易修改磁盘的UUID,尤其是系统盘的UUID,修改后需要修改对应的grub和fstab,否则系统无法加载起来
转自:https://blog.csdn.net/lemontree1945/article/details/131591035
linux中uuid挂载分区,Linux系统通过UUID挂载硬盘分区
一、查看分区表信息
1.命令:sudo blkid
Fighter:~$ sudo blkid
/dev/sda1: UUID="4C7A269D7A2683B4" TYPE="ntfs" PARTUUID="b9b1b5b6-01"
/dev/sda2: LABEL="M-fM-^\M-,M-eM-^\M-0M-gM-#M-^AM-gM-^[M-^X" UUID="666C3B416C3B0B77" TYPE="ntfs" PARTUUID="b9b1b5b6-02"
/dev/sda5: UUID="97382d3e-ac64-4b04-8714-d60502478c64" TYPE="swap" PARTUUID="b9b1b5b6-05"
/dev/sdb1: UUID="37762580-d3f0-40d0-acaa-990037c64636" TYPE="ext4" PARTUUID="0006e551-01"
/dev/sdb2: UUID="19dffa39-2886-4771-996e-62b1b3a77ceb" TYPE="swap" PARTUUID="0006e551-02"
/dev/sdb3: LABEL="work" UUID="201313e2-2ffa-424e-98ee-9f5a18cf3b8d" TYPE="ext4" PARTUUID="0006e551-03"
/dev/sdd: LABEL="SourceCode" UUID="a7b70f5c-cc52-4d81-bb85-fd1775ef675b" TYPE="ext4" PTUUID="e5941a27" PTTYPE="dos"
/dev/sdc1: LABEL="M-gM-3M-;M-gM-;M-^_M-dM-?M-^]M-gM-^UM-^Y" UUID="02D4781FD47816DF" TYPE="ntfs" PARTUUID="efc7223a-01"
/dev/sdc2: UUID="0A1CCC511CCC3989" TYPE="ntfs" PARTUUID="efc7223a-02"
/dev/sdc3: UUID="22FE200AFE1FD4BF" TYPE="ntfs" PARTUUID="efc7223a-03"
二、创建要挂载到的文件夹
三、编辑/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).
#
# # / was on /dev/sdb1 during installation
UUID=37762580-d3f0-40d0-acaa-990037c64636 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=97382d3e-ac64-4b04-8714-d60502478c64 none swap sw 0 0
# swap was on /dev/sdb2 during installation
UUID=19dffa39-2886-4771-996e-62b1b3a77ceb none swap sw 0 0
# work was on /dev/sdb3 during installation
UUID=201313e2-2ffa-424e-98ee-9f5a18cf3b8d /home/koson/Work ext4 defaults 0 2
#SourceCode was on /dev/sdd during installation
UUID=a7b70f5c-cc52-4d81-bb85-fd1775ef675b /home/koson/SourceCode ext4 defaults 0 2
转自:https://blog.csdn.net/weixin_34847632/article/details/116826282
使用文件夹路径,进行创建/etc/fstab
[root@192 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Mar 11 23:11:52 2022
#
# 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/centos-root / xfs defaults 0 0
/dev/sda1 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0