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

  • This part I needed to compress a partition of an SSD drive on a machine with less free space than the said partition I don't understand! – George Udosen Oct 28 '17 at 7:08
  • @George dev/sdd1 was the partition I wanted to backup. It was on an external SSD. The machine I did this on had only 70 GB free and dev/sdd1 was 100 GB. So I had to compress while making the image. Makes sense? – Majid Fouladpour Oct 28 '17 at 7:19
  • You might want to just mount the compressed image – Xen2050 Dec 29 '17 at 0:43
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/

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.