Gnome Boxes, create, resize, rename and backup

How to create a gnome box

Last updated 2019-06-21

  1.  You need to install gnome_boxes.
  2. You need the iso for the OS you are going to install.  Download the iso and save it.
  3. Do you have enough disk space for the new gnome-box?

MS Windows 10  URL

Fedora  URL

3. Bring up gnome boxes. Click on “new”.

4. It will ask for the  URL or path. Give it the path and continue.

5. Follow instructions. Just like any other install.

6. Follow instructions in How to backup a gnome Box so that this box will be in the backup schedule.

6A. In gnome_boxes, right click on the properties and type over the name to rename the gnome box so you have a XML file with the short name and gnome-boxes displays the correct fqdn.

6B. In a terminal: cd .local/share/gnome-boxes/images

6C. virsh dumpxml whatever_the_current_box_name >Name.xml

6D. cp whatever_the_current_box_name >fqdn

Now the actual image has the fully qualified domain name.

6E. Use your editor to change Name.xml contents. Change all occurance of the current box name to fqdn.

6F in gnome boxes delete the box. (This deletes the image and deletes the box name from gnome-boxes.

6G Finally, in a command window, type

virsh define name.xml

How to resize a gnome box

list the directory where gnome images are kept and find the path and name of the image. Make sure gnome-boxes is stopped and closed.

ls ~/.local/share/gnome-boxes/images

Lets say you want to add 20 gigabytes to a box whose image name is crashy-5. Now issue the following command in a terminal window:

qemu-img resize ~/.local/share/gnome-boxes/images/crashy-5  +20G

done.

How to clone a gnome box

To clone my box called crashy,I bring up gnome-boxes, Then I right click on the box name, left click on clone. It takes a few minutes, but that is all. The new box will be named crashy-2.

How to rename a gnome box

Backup the box first. (see below). This is done in two parts.

1. Rename the box i n gnome-boxes so that the name displayed to you is the one you want. Lets rename crashy-2 to mswindow10.

open gnome-boxes

right click on crashy-2

scroll to properties, left click

enter name mswindow10 in the box. This changes the display name in gnome-boxes.  Use the fully quaified domain name here.

close gnome boxes

2. To change the name of the image, you must do the following (with gnome-boxes stopped and closed.)

cd ~/.local/share/gnome-boxes/images

cp crashy-2.domain mswindow10.domain

cp crashy-2.xml mswindow10xml

Open gnome boxes, right click on the old crashy-2 box and then click delete.

rm crashy-2.domain (gnome boxes should have already deleted it.)

rm crashy-2.xml

edit mswindow10.xml and change all locations where crashy-2 exists to mswindow10. Check the xml file for errors, parameters, number of cpu’s etc.

virsh define mswindow10.xml

At the end of the above command, your gnome-box will be up and running under the new name.

How to backup a gnome box

create a file in your bin directory named backup-boxes.sh

add the following lines:

!/bin/bash
#===================================================
# backup a gnome boxes machine (aka domain)
#===================================================
date

n1=”.local/share/gnome-boxes/images/”
n2=$1

nnn=”$n1$n2″
echo “Backing up $nnn”

if [ -f $nnn ]; then
virsh dumpxml $1 >$1.xml
tar cvzf $HOME/Boxes/$1-$2.tgz $1.xml .local/share/gnome-boxes/images/$1 .config/libvirt/* .config/gnome-boxes/*
rm $1.xml
else
echo “err— no such box. Must specify the box name.”
exit 1;
fi

date

chmod +x bin/backup-boxes.sh

Add a line to your normal nightly backup script for each box. /home/wlperry/bin/backup-boxes.sh crashy.williamperry.com $NOW

Make sure that all gnome-boxes are stopped and gnome-boxes is closed.

This will create a backup of crashy in the dir /home/wlperry/Boxes/

How to recover a gnome box from backup

copy both the xml and box image to:

~/.local/share/gnome-boxes/images/

virsh define <box name>.xml

ie.,

cd ~/.local/share/gnome-boxes/images/

virsh define crash-2.xml

Up in the country.