[4.1.6] How to attach LVM LV to a VM

Discussions related to using VirtualBox on Linux hosts.
Post Reply
alun
Posts: 9
Joined: 11. Nov 2011, 07:05
Primary OS: openSUSE
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7, Win2K3, Win2K8, openSUSE (varoius: for services and testing)

[4.1.6] How to attach LVM LV to a VM

Post by alun »

Using VirtualBox 4.1.6

I am trying to attach a dedicated LV for data to a VM.

I managed so far to create the VMDK as being root, other users results in access denied failure.

Code: Select all

VBoxManage internalcommands createrawvmdk -filename /guests/Suse\ non-GUI/testlv.vmdk -rawdisk /dev/mapper/host-test--lv
RAW host disk access VMDK file /guests/Suse non-GUI/testlv.vmdk created successfully.
As the VM user I failing to attached the created VMDK.

Code: Select all

VBoxManage storageattach Suse\ non-GUI --storagectl "SATA Controller" --port 1 --device 1 --type hdd --medium /guests/Suse\ non-GUI/testlv.vmdk
VBoxManage: error: The medium '/guests/Suse non-GUI/testlv.vmdk' can't be used as the requested device type
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component Medium, interface IMedium, callee nsISupports
Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, AccessMode_ReadWrite, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 210 of file VBoxManageDisk.cpp
VBoxManage: error: Invalid UUID or filename "/guests/Suse non-GUI/testlv.vmdk"
What am I doing wrong?
alun
Posts: 9
Joined: 11. Nov 2011, 07:05
Primary OS: openSUSE
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7, Win2K3, Win2K8, openSUSE (varoius: for services and testing)

Re: [4.1.6] How to attach LVM LV to a VM

Post by alun »

Have a working solution to get around the no support for LVM LV as raw storage for a VM.

The solutions involve making use of Shared Folders.

Create the LV and mount it somewhere on the host filesystem. Changed ownership of the mount directory to root:users with 0770. The important part is the value for the users group, the rest is ignored.

Install Guest Additions in the guest VM, and restart the VM.
On the VM Settings, go to Shared Folders to create permanent auto-mount shared folder. The shared folder appears in /media with prefix sf_.
Ensure guest VM users are part of the vboxsf group in guest VM.

This way you still can use LVM LVs for your guest VM.

Thanx to #vbox irc user "technologov" for helping me to find this solution.
Post Reply