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.
-
corbintechboy Notebook Consultant
dd if=/dev/foo of=/foo/foo/fooimage
might need sudo
So in your case:
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.Code:dd if=/dev/sda of=/dev/sdb1/disk1.img
-
This command is not working it gives me:Code:
dd if=/dev/sda of=/dev/sdb1/disk1.img
I've also tried:Code:dd: opening `/dev/sdb1/disk1.img': Not a directory
This works, but only until the file gets to 4GB, I need to save a file ~100 GBCode:dd if=/dev/sda of=/dev/sdb/disk1.img
Code:dd if=/dev/sda of=/media/foo/disk1.img
-
corbintechboy Notebook Consultant
Try running Ubuntu live and doing the backup.
-
I prefer not to use the live cd, using dd is probably more convenient. I'm not sure why it says "Not a directory..."
-
corbintechboy Notebook Consultant
"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. -
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?
-
Wait a minute I think my external drive has fat filesystem so I think thats the reason it stops at 4GB right?
-
corbintechboy Notebook Consultant
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) -
corbintechboy Notebook Consultant
That very well could be (been ages since I worked with a fat file system). You could format the external to EXT or NTFS... -
Thanks Corbin, my file now is able to exceed 4GB.
-
corbintechboy Notebook Consultant
Np, glad I was a help
.
-
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.
Disk image using dd command
Discussion in 'Linux Compatibility and Software' started by graycolor, Jan 23, 2011.