0

I recently backed up a disk using dd and when I tried to dd the image back to the disk, I realized that somehow the image file is bigger in size than the original disk that was created of

  • original disk 7.4 GB

  • disk image 7.8 GB

The command I used, was:

dd if=/dev/sdg of=/mnt/data/backup.img; sync

I could not mount it, nor extract it to a directory.

What was more interesting that even PhotoRec could not recover all the data from the disk image. After getting a 16 GB flash drive and dd'ing the disk image to it, everything could be 'recovered'.

The original flash drive contained an 8 GB partition formatted as vfat and it wasn't full. Since I did not format it before use, the factory default block size was used.

Why was the disk image ~400MB bigger than the original disk?

  • Please add to your question the output of ls -lh /mnt/data/backup.img and df -h /dev/sdg* – LinuxSecurityFreak Apr 15 '18 at 16:39
  • Yes, I may confuse them. Back when I learned the very basics of IT (~12 years ago), there was '1 GB=1024 MB' written in every book. Then there was another confusing book we used in school ~3 years ago, that stated '1 GiB = 1 GB = 1024 MB (Engineers also use KB MB and GB as multiples of 1000 which is the reason for the new formats. Currently there's no applicable law that would decide which format should be used in Hungary)'. And since back then I did not know what I know today, I blindly believed them. – Weylyn Savan Apr 15 '18 at 17:35
  • df -h /dev/sdg*: /dev/sdg1 7,4G 3,6G 3,9G 49%, ls -lh /mnt/backup.img: -rw-r--r-- 1 weylyn1 weylyn1 7,4G ápr 4 21:43 /mnt/backup.img dd if=.\backup.img of=./test.img status=progress; sync: 7927234560 bite (7,9 GB, 7,4 GiB) copied, 359,746 s, 22,0 MB/s – Weylyn Savan Apr 15 '18 at 17:38
  • ^^ please put that into your question where you can format it and make it take. – roaima Apr 15 '18 at 18:06
  • Your dd command is desperately inefficient. I'd suggest next time you use cat. – roaima Apr 15 '18 at 18:06
6

According to the simplest converter, I have found, 7.4 GiB equals approximately 7.9 GB.

As you haven't written any specific commands to output the actual size, this could be it.

Notes:

  • GiB = GibiByte = multiples of 1024.

  • GB = GigaByte = multiples of 1000.

  • Some applications could still confuse these units.


Snippet from the comments:

7927234560 bite (7,9 GB, 7,4 GiB) copied

As you can see for yourself, 7.4 GiB has been copied by dd.


As for your claim:

I could not mount it, nor extract it to a directory.

Well, this is because you didn't dd a partition, I mean /dev/sdg1, but the whole disk instead.


As for your claim:

If that would be the only reason, I could easily dd it back to the USB drive. Unfortunately, I couldn't because the drive ran out of space near the end of the process.

The only reason, that comes to mind at the moment is, that you may have mistakenly done this:

dd if=/mnt/data/backup.img of=/dev/sdg1

instead of:

dd if=/mnt/data/backup.img of=/dev/sdg
  • If that would be the only reason, I could easily dd it back to the USB drive. Unfortunately, I couldn't because the drive ran out of space near the end of the process.. – Weylyn Savan Apr 15 '18 at 17:42
  • @WeylynSavan Isn't that effect normal? I mean it happens normally, I don't know the exact reason, someone else might. – LinuxSecurityFreak Apr 15 '18 at 17:52
  • I dd-ed disk and images back and forth a few times and I never encountered any problem like this. In fact, there were no problems at all. – Weylyn Savan Apr 15 '18 at 17:54
  • @WeylynSavan That is not exactly my expertise, I admit, and it is entirely different question. This case you may consider solved. You might post another question on that topic, though. I am sure someone will respond. – LinuxSecurityFreak Apr 15 '18 at 17:57
  • Well, I thought they are actually one and the same. I couldn't dd an image back to the original drive because the size of the image was ~400 MB (or MiB) bigger than the original drive I dd-ed. – Weylyn Savan Apr 15 '18 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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