I have a configuration bash script that run on a usb disk on the guest for configuring a new installed OS.
The script has access to parameters in a config file :
DISK UUID : given by VB when creating the VM
MAC ADRESS : set when creating the VM
SWAP DISK UUID : given during OS installation
I would like this script to get the disk uuid, the mac address and the swap uuid to verify that the script will apply to the expected machine.
I could not find a way to read the disk uuid from the guest.
Any help is welcome.
get disk uuid on a running vm
-
- Posts: 95
- Joined: 3. May 2013, 18:25
- Primary OS: openSUSE
- VBox Version: PUEL
- Guest OSses: WIN 7, WIN 10
- Location: South west of france
Re: get disk uuid on a running vm
Hello.
Is there any body here ?
Any help is welcome
Is there any body here ?
Any help is welcome
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: get disk uuid on a running vm
Looks like we missed this one, but I don't personally know how to solve it.
This sounds like the sort of thing that would run in a physical Linux PC, too. If you can get the solution for how you'd read a physical PC's UUIDs, MAC address, etc, then the same solution should work in a VM.jcdole wrote:a configuration bash script
-
- Volunteer
- Posts: 5678
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: get disk uuid on a running vm
In general, there are two different types of disk UUIDs, the VirtualBox virtual disk image UUIDs and the Linux filesystem 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 filesystems use UUIDs to differentiate between different partitions of disk drives. 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.
Your "SWAP DISK UUID" is probably meant to be a Linux filesystem UUID and only known inside the guest OS.
Your "DISK UUID" is probably meant to be a VirtualBox virtual disk image UUID and only known inside the host OS. Inside the guest OS, you may be interested in the Volume Serial Number of the virtual hard disk, which is derived from its UUID. See /dev/disk/by-id or sudo hdparm -I /dev/sda<n> | grep Serial as possible starting points.
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 filesystems use UUIDs to differentiate between different partitions of disk drives. 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.
Your "SWAP DISK UUID" is probably meant to be a Linux filesystem UUID and only known inside the guest OS.
Your "DISK UUID" is probably meant to be a VirtualBox virtual disk image UUID and only known inside the host OS. Inside the guest OS, you may be interested in the Volume Serial Number of the virtual hard disk, which is derived from its UUID. See /dev/disk/by-id or sudo hdparm -I /dev/sda<n> | grep Serial as possible starting points.
-
- Posts: 95
- Joined: 3. May 2013, 18:25
- Primary OS: openSUSE
- VBox Version: PUEL
- Guest OSses: WIN 7, WIN 10
- Location: South west of france
Re: get disk uuid on a running vm
Thank you for your answer.
On a vm the part uuid return by blkid is the same as the uuid of the vdi file.
Is this normal, a coincidence, or there was a problem at some point :
compared to :
Any comment is welcome.
On a vm the part uuid return by blkid is the same as the uuid of the vdi file.
Is this normal, a coincidence, or there was a problem at some point :
Code: Select all
VBoxManage showhdinfo ./*.vdi
UUID: 289e455f-4c8a-4eca-88b5-2756e1d2cfe3
Parent UUID: base
State: locked write
Type: normal (base)
Location: /virtual_LINUX_1/LEAP_15.3_VM_1_INITIAL/VDI/LEAP_15.3_VM_1_INITIAL.vdi
Storage format: VDI
Format variant: dynamic default
Capacity: 81920 MBytes
Size on disk: 7983 MBytes
Encryption: disabled
Property: AllocationBlockSize=1048576
In use by VMs: LEAP_15.3_VM_1_INITIAL (UUID: 7e10741c-1d16-4bc7-b4f7-27718ec660b7)
Code: Select all
blkid /dev/sda3
/dev/sda3: LABEL="LNX_SLASH_VM" UUID="289e455f-4c8a-4eca-88b5-2756e1d2cfe3" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="cc1b900c-ad36-4465-baa2-13c7a09fb11c"
-
- Volunteer
- Posts: 5678
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: get disk uuid on a running vm
Good questions. Please provide the output of the whole ls -lR /dev/disk tree from inside the guest, and the output of sudo hdparm -I /dev/sda3. Are you sure that you didn't set the UUID yourself (for example by using your script)?