Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have an unique situation where I need to change UUID of usb flash drive to previous UUID. I formatted it and obviously number changed...

I've ubuntu server setup with 1TB hdd, and 4GB usb flash drive to boot from. Grub on hdd is configured for UUID which changed when I formated usb drive and reinstalled ubuntu server. I've no external monitor, so I attach usb to laptop and install server there... than I move it to server hardware.

As I mentioned my problem is that I need usb to go back to previous UUID, otherwise server won't boot. And I cannot get external monitor till monday! :)

I know I need these files changed afterwards:

The files for which UUID is most critical:

/boot/grub/menu.lst

/etc/fstab

/etc/initramfs-tools/conf.d/resume

But I cannot find anywhere on the net info about customizing UUID.

Anyone?

share|improve this question

4 Answers 4

up vote 9 down vote accepted

If you used ext for it:

tune2fs /dev/{device} -U {uuid}

From man tune2fs

-U UUID

Set the universally unique identifier (UUID) of the filesystem to UUID. The format of the UUID is a series of hex digits separated by hyphens, like this: c1b9d5a2-f162-11cf-9ece-0020afc76f16. The UUID parameter may also be one of the following:

clear  clear the filesystem UUID
random generate a new randomly-generated UUID
time   generate a new time-based UUID

The UUID may be used by mount(8), fsck(8), and /etc/fstab(5) (and possibly others) by specifying UUID=uuid instead of a block special device name like /dev/hda1.

share|improve this answer
    
That worked! But I cannot find: /etc/initramfs-tools/conf.d/resume I found that /boot/grub/menu.lst had been converted to /boot/grub/grub.cfg –  Sandro Dzneladze May 5 '12 at 14:32
    
I have a /etc/initramfs-tools/conf.d/resume on my system. And grub.cfg is indeed the new menu.lst (I think that one came into play with the new grub2. –  Rinzwind May 5 '12 at 14:35

I realize this is kind of an old question, but I found there was a new change, and this was what google snooped up for me, so I'll post the answer I found here.

when I tried to change my root filesystem's uuid (to a well known beginning and a serial number suffix) on new 14.04 ubuntu, I found to my horror tune2fs reported back: I can't do that to mounted file systems. I depend on being able to use a template image with a well known uuid, and change each install to a serialized uuid. I found the problem wasn't insurmountable.

There's a flag that needs to be disabled, to allow mounted-uuid changes with the new tune2fs. this is what my process looked like:

root@ubuntu1404:~# blkid
/dev/sda1: UUID="2ec827b0-72be-4c73-b58a-102a37aa24a3" TYPE="ext4"
root@ubuntu1404:~# uuid="deafcafe-abba-daba-deca-fc0ffee05065"
root@ubuntu1404:~# root_disk=$(df /|grep /|cut -d' ' -f1)
root@ubuntu1404:~# echo $root_disk
/dev/sda1
root@ubuntu1404:~# tune2fs -U $uuid $root_disk
tune2fs 1.42.9 (4-Feb-2014)
The UUID may only be changed when the filesystem is unmounted.
root@ubuntu1404:~# tune2fs -O ^uninit_bg $root_disk
tune2fs 1.42.9 (4-Feb-2014)
root@ubuntu1404:~# tune2fs -U $uuid $root_disk
tune2fs 1.42.9 (4-Feb-2014)
root@ubuntu1404:~# tune2fs -O +uninit_bg $root_disk
tune2fs 1.42.9 (4-Feb-2014)
root@ubuntu1404:~# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       7.3G  3.9G  3.0G  58% /
root@ubuntu1404:~# blkid
/dev/sda1: UUID="deafcafe-abba-daba-deca-fc0ffee05065" TYPE="ext4"
root@ubuntu1404:~#
share|improve this answer
    
Thanks. Could be helpful in future, but I'm still on 12.04 :) –  Sandro Dzneladze May 1 at 20:05

comprehensive info:

how-to-retrieve-and-change-partitions-universally-unique-identifier-uuid-on-linux

share|improve this answer
1  
Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Peachy Sep 27 '12 at 22:30

For xfs see man xfs_admin

xfs_admin -U {uuid} {device}

{uuid} can be 'generate' to just get a new uuid.

For reiserfs see man tunefs.reiserfs

tunefs.reiserfs -i {uuid} {device}

For btrfs it seems the uuid is used thoughout the file systems so every node have to be updated. There is no safe way to do that yet.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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