如何找到交换UUID

如何找到交换UUID

我正在组织一次突袭。sda在安装过程中使用,我只是复制了分区表,sda如下所示sdb

$ sudo sfdisk -dL /dev/sda > partition_table_sda
$ sudo sfdisk /dev/sdb < partition_table_sda

但是我注意到sda交换空间有一个 uuid,但sdb没有:

$ sudo blkid
/dev/sda5: UUID="vvvvvvvv-wwww-xxxx-yyyy-zzzzzzzzzzzz" TYPE="swap" 
/dev/sda1: UUID="vvvvvvvv-wwww-xxxx-yyyy-zzzzzzzzzzzz" TYPE="ext4" 
/dev/sdb1: UUID="vvvvvvvv-wwww-xxxx-yyyy-zzzzzzzzzzzz" TYPE="ext4"

不过分区看起来是正确的,只是缺少 uuid:

$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xzzzzzzzz

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   960002047   480000000   83  Linux
/dev/sda2       960004094   976771071     8383489    5  Extended
Partition 2 does not start on physical sector boundary.
/dev/sda5       960004096   976771071     8383488   82  Linux swap / Solaris

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xzzzzzzzz

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048   960002047   480000000   83  Linux
/dev/sdb2       960004094   976771071     8383489    5  Extended
Partition 2 does not start on physical sector boundary.
/dev/sdb5       960004096   976771071     8383488   82  Linux swap / Solaris

那么如何为交换空间分配一个 uuid 呢sdb5?或者如果它已经有一个uuid,我该如何打印出来?

答案1

你格式化交换分区了吗?一旦你分割了你的磁盘并保留了一个交换分区,你必须:

sudo mkswap /dev/sdb5

之后,输入命令时应显示交换的 UUID blkid

答案2

我使用以下命令打印任何现有的 UUID:

lsblk --output NAME,SIZE,TYPE,UUID

相关内容