Sunday, March 28, 2010

Change UUID of virtual drive

I made a copy of virtual drive (by copy and pasting .vdi file). Then, I tried to mount the .vdi file in the virtual machine. It came up with some error: A hard disk with UUID {bla..bla..bla......} is already registered. So, I was unable to mount the drive.

Now, what is the solution?
Ans: Change the UUID of the virtual/image drive.

How can I change the UUID of the virutal drive?
Ans: You have to run the VBoxManage command

[Before running command, make sure that environment variable is set to the location of the virtual box commands. To set environment variable: Go to "My Computer" --> Right click --> Properties --> Advanced --> Environment Variables --> Add the location of Virtual Box to the PATH variable; In my case it is : PATH .......;C:\Program Files\Sun\VirtualBox ]

C:\ > VBoxManage internalcommands setvdiuuid disk2.vdi

[disk2.vdi is the name of my copied .vdi file]

Now, try to mount the disk2.vdi in Virtual Machine.
Have a good one!


On my second day, I found issue with SLES (Suse Linux). It keeps on complaining "VB is waiting for /dev/disks/by-id/scsi-xxxxx-part2 to appear".
After some research on blogs, found that GRUB in SLES looks for UUID of disk to boot.

I set the copied/cloned harddisk as second harddisk (primary slave) for the original SLES VM. Then I startet the original SLES VM.
In the running SLES VM I made a new directory and mounted it to the root directory of the cloned harddisk.
Then I startet (as root) the Yast partition manager and noticed the UUID of the cloned harddisk. (It is made from the UUID shown with vboxmanage list hdds, but it is not the same).
Then I edited (as root) the /boot/grub/menu.lst and the /etc/fstab : I changed the UUID everywhere the old one was (do not use capital letters instead of small letters).
Now shutdown (after unmounting the cloned root directory)
Then I disabled the cloned harddisk as second harddisk in the original VM and set it as first harddisk in the cloned VM.
Starting the cloned VM now works.


For Network cards to work you have to do
  1. rename the ifcfg-eth-id- to ifcfg-eth0 (in /etc/sysconfig/network)
  2. remove the rules file (/etc/udev/rules.d/30-
  3. edit /etc/sysconfig/network/config and change FORCE_PERSISTENT_NAMES to "no".

No comments: