Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Second opinion on dd

  1. #1

    Second opinion on dd

    Hello everyone,

    I'm trying to create an image of a partition using dd. I have read some horror stories on the topic so I would very much value a second opinion.

    This is my setup:

    Code:
    -sh-3.00$ df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda5            237152860  86503024 138603096  39% /
    /dev/sda1               101086     92498      3369  97% /boot
    none                    517204         0    517204   0% /dev/shm
    /dev/sda2              2063536     45988   1912724   3% /tmp
    I am trying to backup /dev/sda5. This makes me believe this should work:

    Code:
    dd if=/dev/sda5 of=~/sda5disk.img
    Does this look okay to you?

    Many Thanks
    Last edited by s.fox; March 30th, 2015 at 10:51 AM.

  2. #2
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Second opinion on dd

    No, it would make an image of /dev/sda5 onto itself. But there are better ways than using dd for that purpose. dd is slow and dangerous.

    You can use rsync or Clonezilla, which would not copy the free space of the partition.

    Why do you want to backup only sda5?

    You can also use some GUI front end using rsync (or a small script if you prefer command line tools).

    You can also make a tarball, a compressed tar file.

    Edit: dd can be used, but you should not read from a mounted partition or a device with mounted partitions. And you should write to another device (or at least another partition). Typically, boot from an external drive when making an image of the internal drive.
    Last edited by sudodus; March 30th, 2015 at 10:46 AM.

  3. #3
    Join Date
    Jul 2006
    Location
    Here
    Beans
    11,189

    Re: Second opinion on dd

    that is going to take forever, then fail.
    your copying a huge disk to the same disk, not enough space will be the error.
    are you using standard ubuntu ? you can use settings-> backup or disks-> create image
    but your going to need an equal amount of space to put it.
    it's been a long held practice just to back up home, 1 folder & you can compress it if need be.

  4. #4

    Re: Second opinion on dd

    Thanks all for the advice

    CloneZilla might be better suited to my needs afterall. Thank you for the suggestion. Just reading into it now.

    The reason I only want sda5 is because that is where /home is. I don't really want to keep anything else.

    Thanks also for catching the space problem, that would have been an issue. I'll get that sorted with another hdd and adding a partition

  5. #5
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,897
    Distro
    Xubuntu 19.10 Eoan Ermine

    Re: Second opinion on dd

    I would suggest using tar as this will:
    * only copy used files (not the empty disk space),
    * will not try to copy its own output file (you are writing to the filesystem you are trying to image)
    * will use compression to reduce the output file size

    Code:
    sudo tar -czf sda5disk.tar.gz --one-file-system /
    The one-file-system option stops it from descenting into /proc, /sys etc.
    I have succesfully restored a system from a tar file before, and booted it succesfully.

    EDIT:
    You replied while I was typing the above reply.
    If you only want /home, then I would definitely use tar like this:
    Code:
    sudo tar -czf sda5home.tar.gz /home
    Last edited by The Cog; March 30th, 2015 at 01:25 PM.

  6. #6
    Join Date
    Feb 2008
    Location
    Land of fire and drought
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: Second opinion on dd

    Hey, s.fox, these might help on your Clonezilla trek:

    Create image:
    http://rbgeek.wordpress.com/2013/04/...ery-iso-image/

    Create recovery ISO:
    https://rbgeek.wordpress.com/tag/usi...ate-iso-image/

    Partition cloning step by step:
    http://cdonner.com/partition-cloning...clonezilla.htm

    Create Live media (with pics):
    http://clonezilla.org/fine-print-liv...-boot-menu.doc

    I have these links in Zim for these very occasions.

    One thing to remember is that if you clone a 50Gb partition with only 20Gb on it, you need to clone it back to a 50Gb partition, regardless. I thought Clonezilla did clone unused space because of this fact. Happy to be enlightened.

  7. #7

    Re: Second opinion on dd

    Quote Originally Posted by The Cog View Post
    I would suggest using tar as this will:
    * only copy used files (not the empty disk space),
    * will not try to copy its own output file (you are writing to the filesystem you are trying to image)
    * will use compression to reduce the output file size

    Code:
    sudo tar -czf sda5disk.tar.gz --one-file-system /
    The one-file-system option stops it from descenting into /proc, /sys etc.
    I have succesfully restored a system from a tar file before, and booted it succesfully.

    EDIT:
    You replied while I was typing the above reply.
    If you only want /home, then I would definitely use tar like this:
    Code:
    sudo tar -czf sda5home.tar.gz --one-file-system /home
    Thanks, will it actually fit on the same partition? If it will then this looks ideal to me. df indicates that I've used 39% of /sda5 but i'm not sure I understand the blocks info. The used appears to be a lot more than 39%.

  8. #8
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Second opinion on dd

    Quote Originally Posted by s.fox View Post
    Quote Originally Posted by The Cog View Post
    I would suggest using tar as this will:
    * only copy used files (not the empty disk space),
    * will not try to copy its own output file (you are writing to the filesystem you are trying to image)
    * will use compression to reduce the output file size

    Code:
    sudo tar -czf sda5disk.tar.gz --one-file-system /
    The one-file-system option stops it from descenting into /proc, /sys etc.
    I have succesfully restored a system from a tar file before, and booted it succesfully.

    EDIT:
    You replied while I was typing the above reply.
    If you only want /home, then I would definitely use tar like this:
    Code:
    sudo tar -czf sda5home.tar.gz --one-file-system /home
    Thanks, will it actually fit on the same partition? If it will then this looks ideal to me. df indicates that I've used 39% of /sda5 but i'm not sure I understand the blocks info. The used appears to be a lot more than 39%.
    The Cog's command line is good, if you must write to the same partition. You might get the message 'tar: .: file changed as we read it' because the target file is in the source directory.

    But there are better ways to make backups

    1 - If the file system is corrupted, it would be better to have the backup in another partition.

    2 - If the drive is damaged (electronically or mechanically) or stolen or burned in a fire, it would be better to have the backup in another drive, even in another house.

    So I suggest that you get an external drive for your backup.

  9. #9

    Re: Second opinion on dd

    Quote Originally Posted by sudodus View Post
    The Cog's command line is good, if you must write to the same partition. You might get the message 'tar: .: file changed as we read it' because the target file is in the source directory.
    Wouldn't the --one-file-system argument stop this?

    Quote Originally Posted by sudodus View Post
    1 - If the file system is corrupted, it would be better to have the backup in another partition.

    2 - If the drive is damaged (electronically or mechanically) or stolen or burned in a fire, it would be better to have the backup in another drive, even in another house.
    Thankfully the system is not corrupt, neither is the drive damaged.

    So willl it fit? I'm concerned by df showing 39% used, but blocks used seems to be a lot more.

    Thanks again for all the help everyone

  10. #10
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Second opinion on dd

    Quote Originally Posted by s.fox View Post
    Thankfully the system is not corrupt, neither is the drive damaged.
    The system is good now and the drive is good now, but if you need the backup because of a damage, and the backup is lost too ...
    So willl it fit? I'm concerned by df showing 39% used, but blocks used seems to be a lot more.

    Thanks again for all the help everyone
    A compressed image will need less space than than it's source, and the source is the /home directory tree with files, which contains less than 39 % of the drive space. So the compressed image will need [much] less than that, and the available drive space is 61 %, so according to df, yes. You should always have at least 10% free space to avoid fragmented files.

    Maybe it is easier to interpret the output of

    Code:
    df -h   # in Gibibytes, Mibybytes ...

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •