Tails OS is distributed either via .iso or .img file. The only .img can have persistent storage, but only .iso can be mounted to VirtualBox and properly booted. I would like to have VirtualBox Tails machine with persistent storage and ability to install 3rd parties software.

Below is what I did. In couple of words I decided to use flash drive emulator. I'm on Ubuntu 18.04.

I built dummy_hcd.ko for my kernel and got flash drive via

$ sudo modprobe dummy_hcd
$ fallocate -l 8GiB /path/to/flash-drive-file
$ sudo modprobe g_mass_storage file=/path/to/flash-drive-file idVendor=0x1d6b idProduct=0x0104 iManufacturer=Myself iProduct=VirtualBlockDevice iSerialNumber=123

Then I expand Tails OS .img file to that drive by using dd as to usual USB flash drive via issuing following (/dev/sdd is my virtual flash drive)

$ dd if=tails-amd64-3.13.2.img of=/dev/sdd bs=16M

After that I got /dev/sdd1 partition that I can mount and see the image content. It's size is exactly equal to tails-amd64-3.13.2.img file size.

Then I created .vmdk VirtualBox file tied to /dev/sdd via

$ sudo VBoxManage internalcommands createrawvmdk -filename  ~/usb.vmdk -rawdisk /dev/sdd 

I created new virtual machine and selected this .vmdk file, and started it. Unfortunately, while booting it complaints to insufficient disk space and stop booting. I took gparted and resized this partition. gparted shows me a message where suggests to fix GPT table I accepted it. The same parted does.

Warning: Not all of the space available to /dev/sdd appears to be used, you can
fix the GPT to use all of the space (an extra 14364672 blocks) or continue with
the current setting? 
Fix/Ignore? Fix                                                           
Model: Linux File-Stor Gadget (scsi)
Disk /dev/sdd: 8590MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name   Flags
 1      1049kB  1235MB  1234MB  fat32        Tails  boot, hidden, legacy_boot, esp

And after that (it's only enough to apply GPT fix and not actually use unallocated space) I, unfortunately, get this message from kernel. I suppose that it can't find the root file system to mount and continue booting init process from this file system maybe.

enter image description here

But the shell is available and rootfs is mounted to ramdisk and can be listed.


The issue is that the disk you created is not attached to VirtualBox as a removable USB drive, which is what Tails (or, more precisely, the live-boot tool that is used by Tails) is looking for. As far as I know, it's not supported by VirtualBox to add a disk as a removable USB drive.

But since you're on Ubuntu, you can use virt-manager instead of VirtualBox to use a persistent volume in a VM: https://tails.boum.org/doc/advanced_topics/virtualization/virt-manager/index.en.html#usb_image

| improve this answer | |

AFAIK, you "cannot"(*) run Virtualbox and virt-manager simultaneously, as they will compete for the control of the hardware (I would love to be wrong on this one...). This is a showstopper if one has many VirtualBox VMs already and only want to run Tails in addition. Need to either be possible to run both, or to find a way to do this on Virtualbox. The alternative as it stands now (moving everything to virt-manager), is a much bigger question - a rather tall order.

(*)Ref. https://askubuntu.com/questions/413511/can-virtualbox-and-kvm-run-alongside-each-other

There is a tool that "sometimes" works around this limitation in Virtualbox ("cannot add a disk as a removable USB drive"); Plop Boot Manager, ref.: - https://www.howtogeek.com/97923/how-to-boot-a-vmware-virtual-machine-from-a-usb-drive/ - https://www.plop.at/en/bootmanagers.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.