How to change UUID in virtual box inside a linux vdi file?

Discussions related to using VirtualBox on Linux hosts.
Post Reply
theonlydeveloper
Posts: 1
Joined: 18. Feb 2020, 09:24

How to change UUID in virtual box inside a linux vdi file?

Post by theonlydeveloper »

Hello @all,

i need to setup some VMs with Linux and each VM should represent an unique one (MAC,UUID,CPUID).
In Windows its easy - i setup a VM and then i clone this VM with new MAC and use the VolumeID to change it.

But Linux is it not so easy.
I setup my VM and the first one is unique.
The i clone the VM and got a copy of the first one.

I run to check BLKID:

Code: Select all

/dev/sda1: UUID="MyUUID" TYPE="ext4" PARTUUID=MyPartUUID"
In front of the running vm this partition is also my boot partition, i could not change the UUID of the running system.
So i attach gparted live iso and boot from it.

I change there the UUID but then if i try to startup Linux again the old UUID is not found anny more from VirtualBox.

Code: Select all

/dev/sda1: UUID="MyNewUUID" TYPE="ext4" PARTUUID=myPartUUID"
So the question is, how i could setup the MyNewUUID for the VDI file so that Virtualbox could load the VDI file?

I read a lot of posts regarding that stuff but the `"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands sethduuid "c:\vm\Linuxvm.vdi"` seems to generate only a path related UUID or?

Actually i think the only way is to setup everytime a new VM or?
Thanks a lot for you help!
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: How to change UUID in virtual box inside a linux vdi file?

Post by mpack »

Cloning on a Linux host and on a Windows host uses exactly the same source code. There's no way "VBoxManage" produces different results on those hosts.

The only people using "sethduuid" are those wanting to kludge the disk UUID for some reason, usually because they deleted a middle element of a snapshot chain and desperately hope that filling in the hole will make the guest OS not notice the damage caused by missing data.

OTOH, the behaviour you want is the default behaviour - all UUIDs and MACs change by default. You have to set explicit command line switches to keep them.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: How to change UUID in virtual box inside a linux vdi file?

Post by fth0 »

You are confusing two very distinct types of UUIDs here, the VirtualBox virtual disk images UUIDs and the Linux file system UUIDs:

VirtualBox uses UUIDs to differentiate between different virtual disk images (e.g. VDI files, base images, snapshots). If you clone a virtual disk image or a whole VM, the cloned virtual disk image either gets new UUID(s) or not, depending on the dialog settings or commands used. If you want to use two virtual disk images in the same VirtualBox installation, these UUIDs must be different.

Linux file systems use UUIDs to differentiate between different partitions of disk drives. AFAIK, VirtualBox doesn't know where and how those UUIDs are handled by the Linux OS (e.g. references in /etc/fstab), and doesn't change those UUIDs when cloning a virtual disk file.

From my point of view, your previous questions don't make sense. What do you want to achieve? Do you need different Linux file system UUIDs (why?) or only different VirtualBox virtual disk images UUIDs?
Post Reply