Vm on physical disks

186 views
Skip to first unread message

Outback Dingo

unread,
Sep 24, 2015, 11:43:00 AM9/24/15
to qubes...@googlegroups.com
Im curious if there is ever a plan for adding a vm on a physical drive instead of a sparse file

Thanks

Vít Šesták

unread,
Sep 25, 2015, 1:41:28 PM9/25/15
to qubes-devel
This is possible for HVMs or StandaloneVMs. (I am not sure which of them have support for this, as they are strongly correlated for me.)

For standard template-based PVMs, this is possible using a symlink hack. This hack has some drawbacks, e.g. backups are not supported, cloning is not supported and there are some issues with DVM if it is used for root of template of DVM.

Some dicsussion related to block-devices as VM images: https://groups.google.com/forum/#!topic/qubes-users/xneub6PMX4M  (There are some LVM-specific things, but it is mostly generic.)

Regards,
Vít Šesták 'v6ak'

Eric Shelton

unread,
Oct 3, 2015, 11:43:05 AM10/3/15
to qubes-devel
This is simple with a custom config file.  First, create an appvm via Qubes Manager - for this example, the name of the appvm is 'my-vm'.  Then, go to the corresponding folder in /var/lib/qubes/appvms/ - in this example, /var/lib/qubes/appvms/my-vm/.  Then, make a copy of the .conf file for the appvm - for example, 'cp my-vm.conf edited.conf'.  Then, edit the new .conf file (XML format) to specify the block device you want to use, generally by replacing root.img with the desired block device.  For example:

    <disk type='block' device='disk'>
      <driver name='phy'/>
      <source dev='/var/lib/qubes/appvms/my-vm/root.img'/>
      <target dev='xvda' bus='xen'/>
    </disk>

becomes

    <disk type='block' device='disk'>
      <driver name='phy'/>
      <source dev='/dev/sdb'/>
      <target dev='xvda' bus='xen'/>
    </disk>

Or, maybe you just want to add a second drive.  If so, you would duplicate the 'disk' section, but specify 'xvdb', giving you:

    <disk type='block' device='disk'>
      <driver name='phy'/>
      <source dev='/var/lib/qubes/appvms/my-vm/root.img'/>
      <target dev='xvda' bus='xen'/>
    </disk>

    <disk type='block' device='disk'>
      <driver name='phy'/>
      <source dev='/dev/sdb'/>
      <target dev='xvdb' bus='xen'/>
    </disk>

I have not tried this for a PV domain, but it should work.  I am not 100% sure of this - but for some HVM operating systems that do not have PV disk driver support, they may be happier with 'hda' instead of 'xvda'.

Then, to start the domain, you run 'qvm-start my-vm --custom-config=/var/lib/qubes/appvms/my-vm/edited.conf'.

It may be possible to permanently set a custom config via qvm-prefs, but I have not explored that idea yet.

I have been successfully using the above technique for creating a bootable USB on another machine, and booting by specifying the block device for the USB.  It should work just fine for an ordinary hard drive too.  Depending on the OS, you could take a primary drive out of a laptop or desktop machine, and boot it up inside a Qubes appvm.

Best of luck,
Eric
Reply all
Reply to author
Forward
0 new messages