6

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?

  • 1
    Do you want to change the UUID of the filesystem, or the UUID of the encrypted volume? – Gilles Jan 25 '16 at 23:55
  • As stated, the /dev/sda1 UUID – Hacktivista Jan 26 '16 at 1:05
8

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"
  • That's /dev/mapper/root but if I run tune2fs on that "device" it will not change the /dev/sda1 device – Hacktivista Jan 26 '16 at 1:30
  • @Hacktivista Added some info. – Hauke Laging Jan 26 '16 at 1:52
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.