I’m looking out for the best solution to resolve this problem : having some of my qube VMs, or at least their data, on an external USB hard drive.
I already managed to follow the Secondary storage documentation page on another machine with an internal HDD. But, as far as I understand, it’s not possible with an external HDD without security risks, because this drive should be attached to dom0.
My current solution is to create a normal AppVM in dom0, attach the corresponding logical volume to the AppVM and link some directories to it. My external HDD is encrypted and contains a LVM thin pool with logical volumes. I’m able to decrypt it in an AppVM dedicated to this task called disks-manager. So, I can attach the drive to my test-automount AppVM on qvm-start:
qvm-start test-automount --hddisk=disks-manager:dm-1
This is my /rw/config/rc.local inside test-automount:
if [ ! -b /dev/xvdi ]; then
shutdown now
fi
mkdir -p /mnt/vm-external-data
mount /dev/xvdi /mnt/vm-external-data
if [ ! -h /home/user/Music ]; then
rmdir /home/user/Music
ln -s /mnt/vm-external-data/home/user/Music /home/user
fi
It’s okay but think I can look for some better solution because I can have a lot of different directories to link … I’m not sure if doing this is safe:
rm -r /home/user
ln -s /mnt/vm-external-data/home/user /home/user
Of course, I tried to play with bind-dirs and /etc/fstab. This is the content of my /etc/fstab:
/dev/mapper/dmroot / ext4 defaults,discard,noatime 1 1
/dev/xvdb /rw auto noauto,defaults,discard,nosuid,nodev 1 2
/dev/xvdi /mnt/vm-external-data auto defaults,discard,nosuid,nodev 0 2
/mnt/vm-external-data/home /home none noauto,bind,defaults,nosuid,nodev 0 0
/rw/usrlocal /usr/local none noauto,bind,defaults 0 0
# ... [default AppVM lines here] ...
/dev/xvdj /mnt/removable auto noauto,user,rw 0 0
I only edited the 3rd, 4th and last line, but without success. findmnt doesn’t output errors or warnings and mount -a ignore everything I added in /etc/fstab …
There is a lot of topics about this on this forum but I can’t find a good solution. Is there something I’m missing ? Any ideas to improve my rc.local, get fstab to work or anything else ?