The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    Disk image using dd command

    Discussion in 'Linux Compatibility and Software' started by graycolor, Jan 23, 2011.

  1. graycolor

    graycolor Notebook Evangelist

    Reputations:
    30
    Messages:
    459
    Likes Received:
    0
    Trophy Points:
    30
    I'm trying to create a disk image using the dd command however it saves the image in my home directory and it's obvious the hard-drive is going to run out of space. I have an external usb hard-drive, but how do I save the image file directly to the usb hard-drive and not first saving it in the home directory.

    This is the command I'm using:
    dd if=/dev/sda of=~/disk1.img <-- Stores image file in home directory.

    I want the disk1.img to be stored into /dev/sdb1 not the homedirectory.
     
  2. corbintechboy

    corbintechboy Notebook Consultant

    Reputations:
    126
    Messages:
    189
    Likes Received:
    2
    Trophy Points:
    31
    dd if=/dev/foo of=/foo/foo/fooimage

    might need sudo

    So in your case:

    Code:
    dd if=/dev/sda of=/dev/sdb1/disk1.img
    EDIT: If your interested, you can also set up a Cron job to have this done in time intervals. You could even have Cron point to a bash script and have the script only keep the most recent 2 or 1 backup if you desire.
     
  3. graycolor

    graycolor Notebook Evangelist

    Reputations:
    30
    Messages:
    459
    Likes Received:
    0
    Trophy Points:
    30
    Code:
    dd if=/dev/sda of=/dev/sdb1/disk1.img
    This command is not working it gives me:

    Code:
    dd: opening `/dev/sdb1/disk1.img': Not a directory
    I've also tried:
    Code:
    dd if=/dev/sda of=/dev/sdb/disk1.img
    This works, but only until the file gets to 4GB, I need to save a file ~100 GB
    Code:
    dd if=/dev/sda of=/media/foo/disk1.img
     
  4. corbintechboy

    corbintechboy Notebook Consultant

    Reputations:
    126
    Messages:
    189
    Likes Received:
    2
    Trophy Points:
    31
    Try running Ubuntu live and doing the backup.
     
  5. graycolor

    graycolor Notebook Evangelist

    Reputations:
    30
    Messages:
    459
    Likes Received:
    0
    Trophy Points:
    30
    I prefer not to use the live cd, using dd is probably more convenient. I'm not sure why it says "Not a directory..."
     
  6. corbintechboy

    corbintechboy Notebook Consultant

    Reputations:
    126
    Messages:
    189
    Likes Received:
    2
    Trophy Points:
    31
    "foo" is just a generic explanation for your directory.

    On your drive you would have a directory (maybe backup) to place the backup.

    You can just do /dev/sdb1 without a directory, and /dev/sdb1 needs to be mounted.
     
  7. graycolor

    graycolor Notebook Evangelist

    Reputations:
    30
    Messages:
    459
    Likes Received:
    0
    Trophy Points:
    30
    I'm a linux noob, you need to slow down. When I plug my external harddrive in it automatically mounts to /media/foo. How do I mount this thing to /dev/sdb? If that's what your saying?
     
  8. graycolor

    graycolor Notebook Evangelist

    Reputations:
    30
    Messages:
    459
    Likes Received:
    0
    Trophy Points:
    30
    Wait a minute I think my external drive has fat filesystem so I think thats the reason it stops at 4GB right?
     
  9. corbintechboy

    corbintechboy Notebook Consultant

    Reputations:
    126
    Messages:
    189
    Likes Received:
    2
    Trophy Points:
    31
    Mounting to /media is fine.

    Code:
    dd if=/dev/sda ("sda" is wherever you want to backup)  of=/dev/sdb1/disk1.img (this is wherever it is mounted, could be "of=/media/whereveritis/disk1.img)
     
  10. corbintechboy

    corbintechboy Notebook Consultant

    Reputations:
    126
    Messages:
    189
    Likes Received:
    2
    Trophy Points:
    31
    That very well could be (been ages since I worked with a fat file system). You could format the external to EXT or NTFS...
     
  11. graycolor

    graycolor Notebook Evangelist

    Reputations:
    30
    Messages:
    459
    Likes Received:
    0
    Trophy Points:
    30
    Thanks Corbin, my file now is able to exceed 4GB.
     
  12. corbintechboy

    corbintechboy Notebook Consultant

    Reputations:
    126
    Messages:
    189
    Likes Received:
    2
    Trophy Points:
    31
    Np, glad I was a help :D.
     
  13. debguy

    debguy rip dmr

    Reputations:
    607
    Messages:
    893
    Likes Received:
    4
    Trophy Points:
    31
    Creating a raw image with dd from withing the running system will most likely cause trouble when restoring the image because of the inconsistencies that are caused by the file system write between start and stop of the copy process. Backups are quite pointless if you don't know for sure that they'll work.
    If you really want to make an image copy with dd always use another system (e.g. a live CD).

    But I guess instead of saving an image it would be more reasonable to only save your personal data. This can very easily be done with rsync. There are also graphical frontends available like Grsync. Others report that Unison works quite well, but I have no experience with it.