4

I needed to compress a partition of an SSD drive on a machine with less free space than the said partition. I searched, found and executed the following command:

root@host1:~/# dd if=/dev/sdd1 | gzip -c  > /tmp/ubuntu.image
226510848+0 records in
226510848+0 records out
115973554176 bytes (116 GB, 108 GiB) copied, 3716.19 s, 31.2 MB/s

Now, on another machine I cannot extract the file. Trying context menu "Extract Here" I get:

Could not open "ubuntu.image"
Archive type not supported.

When I try the following command the cursor disappears for 1-2 seconds but then I get the prompt back without the file being extracted or showing any errors:

me@host2:/media/me/ntfs$ tar -xvzf ubuntu.image
me@host2:/media/me/ntfs$

file command prints this:

me@host2:/media/me/ntfs$ file ubuntu.image 
ubuntu.image: gzip compressed data, last modified: Fri Oct 27 13:02:10 2017, from Unix

So what is wrong? How could I mount this image on host2?
Host1 and Host2 are both Ubuntu 16.04

Xen2050
  • 8,705
Majid Fouladpour
  • 182
  • 1
  • 13

1 Answers1

7

Tar is for extracting tar balls :)

It is a gzipped image, but it does not have the familiar .gz suffix, commonly used for gzipped files. This is not a big deal; the data is there.

If you try to use gunzip directly, it will complain, as it does not use the default suffix. There's many ways to solve this:

  1. Rename the file to ubuntu.image.gz (mv ubuntu.image ubuntu.image.gz) and uncompress it with gunzip ubuntu.image.gz.
  2. Use zcat ubuntu.image > ubuntu_uncompress.image
  3. Use gunzip -S .image ubuntu.image. This will yield a uncompressed file named ubuntu.

I'd stick with renaming the file. Also note that the unpacked file will be the same size as the partition originally was.

Once you have the uncompressed image, you can mount it with sudo mount -o loop ubuntu.image /mnt/

vidarlo
  • 22,691