Tuesday, May 21, 2024
Homepage · dd
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 16982  / 3 Years ago, wed, august 11, 2021, 12:33:29

I am using dd to create an image of my boot partition on Ubuntu 14.04. This is my first time doing this.



In checking the usage on my disk, I used df -h. You will see that my /dev/sda1 partition is 5.8G in size...



bash$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 220G 5.8G 203G 3% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 3.9G 4.0K 3.9G 1% /dev
tmpfs 797M 976K 796M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.9G 30M 3.9G 1% /run/shm
none 100M 28K 100M 1% /run/user
/dev/sda5 239G 32K 239G 1% /windows


I tried to create in image and save it in /tmp with the following command:



bash$ sudo dd if=/dev/sda1 of=/tmp/ubuntu.image


It started creating an image in my /tmp dir, but as I checked on its progress, the image kept growing to well over 30G before I cancelled it.



This raises a few questions in my mind:




  • Why would the disk image be so large?

  • Is it going to equal the size
    of the partition?

  • Is there a way to keep the disk image to just the
    size of the actual space used?

  • Is there a better tool to use?


More From » dd

 Answers
4

/dev/sda1       220G  5.8G  203G   3% /



/dev/sda1 is 220 GB in size, and has 5.8 GB used. So:




  1. dd makes a byte-for-byte copy, so the total size of the partition matters, not what's in the partition.

  2. Yes. It will grow to 220 GB.

  3. You can compress the resulting image using gzip or xz:



    sudo dd if=/dev/sda1 | xz > /tmp/ubuntu.image

  4. Depends on what you call a better tool. For some tasks, a byte-for-byte copy is needed (say, data recovery from a failing disk). In such cases, dd + compression is the simplest way. If not, consider something like partimage .


[#22829] Wednesday, August 11, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
azaaburge

Total Points: 266
Total Questions: 85
Total Answers: 109

Location: Djibouti
Member since Sat, Oct 29, 2022
2 Years ago
azaaburge questions
Thu, Jun 2, 22, 23:28, 2 Years ago
Sun, Oct 17, 21, 05:20, 3 Years ago
Fri, Jun 25, 21, 16:22, 3 Years ago
;