8

I'm trying to change a partition's UUID, the problem is that I'm trying to change an encrypted volume. So I can't use the usual method described here. Since it throws the following error:

tune2fs: Bad magic number in super-block while trying to open /dev/sda1
Couldn't find valid filesystem superblock.

So let's suppose this is my blkid:

/dev/sda1: UUID="adc4277c-0057-4455-a25e-94dec062571c" TYPE="crypto_LUKS" PARTUUID="23487624-01"
/dev/sda2: UUID="9f16a55e-954b-4947-87ce-b0055c6ac953" TYPE="crypto_LUKS" PARTUUID="23487624-02"
/dev/mapper/root: LABEL="root" UUID="6d1b1654-016b-4dc6-8330-3c242b2c538b" TYPE="ext4"
/dev/mapper/home: LABEL="home" UUID="9c48b8fe-36a6-4958-af26-d15a2a89878b" TYPE="ext4"

What I want to change in this example is the /dev/sda1 UUID. How can I achieve this?

2 Answers2

13

For changing the file system UUID you have to decrypt /dev/sda1 and then run tune2fs on the decrypted device mapper device.

sda1 itself does not have a UUID thus it cannot be changed.

The LUKS volume within sda1 does have a UUID (which is of limited use because you probably cannot use it for mounting), though. It can be changed with

cryptsetup luksUUID /dev/sda1 --uuid "$newuuid"
Hauke Laging
  • 90,279
4

To change the UUID of the LUKS volume, use cryptsetup luksUUID --uuid=<the new UUID> /dev/sda1.

Wyzard
  • 2,404