2015년 1월 5일 월요일

Using a Virtualbox VM stored on a shared partition in several different OS'es

  On my notebook I use at work, I have one shared 250 GB btrfs partition that stores all my RHEL, CentOS, Debian/Ubuntu, etc installation .iso images as well as Virtualbox VM .vdi files The remaining space on the 500 GB disk is divided up into separate /boot partitions for various Linux distros while system partitions for each distro reside within LUKS containers containing separate LVM partitions (1 PV, 1 VG, and several logical volumes within the VG for mounting / /home /var and swap).

Since all the Virtualbox .vdi virtual disk images reside on the shared 250 GB partition, within each OS (i.e. Win7, Ubuntu, Arch...) we can import .vdi files into Virtualbox using VBoxManager thereby enabling us to use the VM's from multiple OS'es.

There are some caveats, however. If you want to use the VM's on multiple OS'es, you must not keep any save states; after finishing up your session, be sure to do a proper shutdown of the VM. This is of particular importance for WinXP or Win7 VM's. In the case of XP, I had a saved state residing on CentOS 7, but then I tried to load the VM from Arch which totally corrupted the image making booting no longer possible. In the case of a Win7 VM, even if there are no save states, on the first boot from a new host OS Win7 will restart itself to apply new configurations for the "new" host.

Another issue is that MAC addresses for existing network interfaces are randomized when an existing VM is imported into Virtualbox residing on a different host. This was problematic for me because my CentOS 6.5 VM serves as a PXE installation server. Within the VM there is a single network interface eth0 (note the host OS may have a different name for the wired network interface, i.e. enp1s0 etc) with the following MAC address:


The original MAC for our network interface is 08:00:27:3C:8A:03 but when we imported the CentOS 6.5 VM into Virtualbox on an Archlinux host, Virtualbox randomized the MAC address to another value.

When I started the CentOS 6.5 VM, I noticed that eth0 failed to come up and returned an error, "interface eth0 does not exist", and network interface eth1 was generated by the OS instead. This was problematic because my dhcp server config and PXE install scripts all assume that the network interface is on eth0.

Solution

I shut down the VM and, taking note of the original MAC above, simply replaced the randomized MAC address with 08:00:27:3C:8A:03 in the VBoxManager administration interface. Upon starting the VM once more, eth0 came up at boot without any problems.

댓글 없음:

댓글 쓰기