How to change the hard drive and directory of installation of Gnome Boxes Virtual Machines?

I’m using Gnome Boxes in a PC with two hard drives. I will like to install the VM of Gnome Boxe in a secondary HD.

The help of Boxes mention ~/.local/share/gnome-boxes/images/ but there is no such directory in Endless.

~/.var/app/org.gnome.Boxes/data/gnome-boxes/images rather than ~/.local/share/gnome-boxes/images/

Thanks Leandro,

I understand that beside moving the VM machine files i also should change the path in some file. so Boxes know where the VM files are.

which file i should update?

I need to edit the files using virsh, but it seems its not intsalled in endlessos. there is an alternative application to change the configuration?

Hi,
due to the nature of the Flatpak Sandbox, this is more difficult than one might think

Prepare the Drive for Usage

The first step is to partition/format/mount the 2nd Drive. I assume for this, that your 2nd Drive is called /dev/sdb (verify!).

Make yourself root

Run sudo bash then enter your password.

Partitioning

Run sgdisk --zap-all /dev/sdb to remove everything on the drive, then run gdisk /dev/sdb and create a new partition with Code 8300. Write the changes to the disk and exit.

Formatting

Run mkfs.ext4 -L scratch /dev/sdb1 to create a new Filesystem on the newly created partition and give it a name.

Automatically mount

Create a mountpoint like /var/scratch with mkdir /var/scratch. Now edit /etc/fstab and insert the following line:

LABEL=scratch /var/scratch ext4 defaults 0 0

This will make the OS mount the disk automatically at boot. Now mount the filesystem manually with mount -a

Create a personal directory on it

I strongly advise you to create a personal directory on the filesystem with the proper permisssions:

mkdir /var/scratch/myname
chown myname:users /var/scratch/myname
chmod -R 700 /var/scratch/myname

(replace myname with your actual username)

Link to it from your Home Directory

To make access to the filesystem more convenient, run:

ln -s /var/scratch/myname ~/scratch

This will create a symbolic link in your homedirectory to the filesystem on the 2nd drive

Allow Flatpak applications access to this location

Flatpak per default does not allow you to access this location. You have to manually override the permission to explicitly allow it:

flatpak override --user --filesystem=/var/scratch org.gnome.Boxes

This will allow Gnome Boxes access to the 2nd Drive

Move your Boxes

Gnome Boxes stores it’s files per default under:
~/.var/app/org.gnome.Boxes/data/gnome-boxes/images

You need to move this directory to your 2nd-Drive, e.g. to
/var/scratch/myname/images

Now the more complex part - we need to modify the configuration for two parts:

  1. The default storage location for creating new Boxes
  2. The storage location for already existing Boxes

Run:

flatpak run --command=sh org.gnome.Boxes

This will put you inside the Flatpak Sandbox for Gnome Boxes, but in a Shell. We have to use the virsh Tool to modify the necessary files, but unfortunately they rely on the Vi Editor, which is not available in the Sandbox, so we have to make a Quickhack. Run:

cp /bin/nano vi
export PATH=$PATH:.

This will copy the Nano-Editor which is available in the Sandbox to Vi and set the path to it. virsh is now happy and will let us edit the configuration files.
Run:

virsh pool-edit gnome-boxes

Modify the following line to set the default location for new images:

<path>/var/scratch/egon/Boxes</path>

Now save and exit (ctrl-X). Next, run the following command to list the names of all your currently created boxes:

virsh list --all

will give you something like:

 -    eos3.7-en   shut off
 -    win10       shut off

To edit the configuration for the Box, run: (replace the name)

virsh edit eos3.7-en

and edit the Line:

<source file='/var/scratch/egon/Boxes/eos3.7-en'/>

To point to the new location. Save and exit with Ctrl-X.

When everything has been done, you can run your Boxes again.

1 Like

[quote=“egrath, post:5, topic:12725”]
Run mkfs.ext4 -L scratch /dev/sdb1 to create a new Filesystem on the newly created partition and give it a name.

Automatically mount

Create a mountpoint like /var/scratch with mkdir /var/scratch . Now edit /etc/fstab and insert the following line:

Many thanks for the detailed explanation. 

i made all the steps.

Its all ok until  the last step Move your Boxes.
it seems that ~/.var/app/org.gnome.Boxes/data/gnome-boxes/images itś not there anymore....

may be there is something to do witth the override?

Hi, i adopted the tutorial. Wrote it yesterday without my notes and just realized that moving the boxes was a little more involved than i remembered :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.