Setting disk UUIDs

After setting up mounting by UUID as described here, I realized I had a problem.

I wanted to swap disks out (that is, have multiple versions of my backup drive). However, since the drives are being mounted by UUID, I wanted to have only one entry in /etc/fstab for all my “backup” drives.

It appears that dd would work, but that seemed inelegant, especially if future drives are different sizes. So I did a bit of searching and found the discussion here.

In short, I could use

sudo tune2fs /dev/sdb1 -U new-uuid-number

to set the UUID of a file system to whatever I want.

After I’d done that, I couldn’t figure out how to refresh the UUID in /dev/disk/by-uuid/ – even after ejecting and re-inserting the SATA disk, the old UUID still showed up. I ended up rebooting (sigh) and now I can swap drives out with abandon. I probably should have specified the UUID when I did the mkfs. This looks like this bug.

I haven’t tried it, but I would guess having two disks with the same UUID in the machine at the same time would be a Bad Thing.

In retrospect, it would probably have been better if I’d used disk labels instead of UUIDs.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: