Page tree
Skip to end of metadata
Go to start of metadata

Danger Zone! Please read this page carefully.

Background

With each mobile platform we supply a backup image of the hard-drive (usually on DVD) which can be used to restore the platform to it's original state.

There are two ways to restore an image, one is to boot from a live USB stick and read the image via an external DVD drive (or copy it to another USB stick).

The other way is to dis-mount the hard-drive and attach it to another PC.

Inspecting a backup

If you only want to inspect the image and/or restore specific files, there is a different option that does not require writing to a hard disk.

Generally, images of partitions can be mounted like a physical partition. Our problem here is that the image is a whole disk. The solution is to set up a loop device.

Extract the image and then set up a loop device:

gunzip /path/to/image.img.gz
udisksctl loop-setup -f /path/to/image.img

You should get a result like this:

Mapped file image.img as /dev/loop0.

Now the image is available as /dev/loop0 and the partitions as /dev/loop0pX with X being the number of the partition. Now you can mount the partitions with the mount command and work on them just like on normal disk partitions.

When you are done, remove the loop device:

udisksctl loop-delete -b /dev/loop0

Restoring a backup onto the hard-drive

The commands shown in this section can destroy your valuable data (on any connected hard-drive) if not used correctly!

To over-write the existing hard-drive with the backup image, we first have to identify the name of the hard-drive, usually it is "/dev/sdx", with the 'x' being 'a', 'b' or 'c', etc.

You can use the following command to get a list of all installed hard-drives:

sudo fdisk -l

Now you can try to find the drive which has the correct amount of GiB, as was installed in the platform.

Once the correct hard-drive is identified, you can restore the image as follows:

gzip -dc /path/to/image.gz | sudo dd status=progress of=/dev/sdx

Make sure to select the whole drive, such as "/dev/sda" or "/dev/sdb", and not an individual partition such as "/dev/sda1" or "/dev/sdb1".

The above command will over-write any existing data on the target device "/dev/sdx", ie. the entire hard-disk and all it's partitions! Make sure to select the correct hard-drive and backup any data which is still needed.

This process may take a while, eg. up to 15 minutes.

Next you may expand the home partition to it's full size again, since the backup is usually made with a much smaller partition size:

sudo apt install cloud-guest-utils
sudo growpart /dev/sdx 2		# assuming /dev/sdx2 is the home partition
sudo resize2fs /dev/sdx2
  • No labels