0

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.

0

4 Answers 4

3

The following has been successfully tested with VirtualBox 6.1.32 and Tails 5.1.

Step 1: Prepare disk image

  1. Download the USB image of Tails from the project's website

  2. Convert the downloaded image to VDI format:

    $ VBoxManage convertfromraw Tails-amd64-5.1.img Tails.vdi --format vdi

    (NOTE: the .img file is no longer required after this and may be deleted)

  3. Resize the VDI to make room for the persistent volume:

    $ VBoxManage modifyhd Tails.vdi --resize 16384

    (NOTE: use 8000 MB + <desired-size-of-persistent-volume-in-MB> as resize value)

Step 2: Set up virtual machine

  1. Follow the instructions provided on the project's website to set up a new VM for Tails

  2. Change the following settings of the newly created VM:

    • System -> Motherboard -> Extended Features -> ☑ Enable EFI (special OSes only)

      (NOTE: required to be able to boot from USB storage)

    • Storage -> Add new storage controller (leftmost icon at the bottom) -> USB

    • Storage -> Controller: USB -> Add new storage attachment (third icon from the left at the bottom) -> Hard Disk -> Select VDI image created in Step 1

  3. Set VM resolution (optional):

    $ VBoxManage setextradata <vm-name> VBoxInternal2/EfiGraphicsResolution <resolution>

    (NOTE: supply <resolution> in format 'WIDTHxHEIGHT', e.g. '1600x900')

Step 3: Boot virtual machine, set up persistent volume

  1. Start the virtual machine

  2. From the boot menu, select Tails (External Hard Disk)

    (NOTE: refer to this answer on how to permanently modify the boot menu if desired)

  3. Once Tails has booted up, select Applications -> Tails -> Configure persistent volume to set up the persistent volume

Screenshots:

Enable EFI for USB boot

Add USB storage / image

Select correct boot menu entry

Set up persistent volume

2

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

2

Not enough "reputation" to vote or comment on @Maxxim's answer, this is an addition (feel free to pls. integrate into your answer, Maxxim):

After taking Maxxims approach one has to manually select 3rd boot option every.single.boot. IMO better is to edit grub.cfg from a rootshell:

mount -o remount -w /lib/live/mount/medium/
find /lib/live/mount/medium/EFI/debian/ -name "grub*.cfg" | xargs sed -i 's/ live-media=removable//g'
mount -o remount -r /lib/live/mount/medium/

Afterwards Tails starts w/o interaction.

1
  • I added a link to your answer to mine. Thank you!
    – Fonic
    Jun 9, 2022 at 10:29
1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .