Quote:
Originally Posted by thedoctor
For a external drive, if I write
sudo swapoff -a
sudo dd if=/dev/sda | gzip > /path/to/storage/sdb1.dd.gz
restore
sudo gzip -dc /path/to/storage/sdb1.dd.gz | dd of=/dev/sda
sudo swapon -a
Is the above correct.
|
That sort of thing will work, but seems to show that you still have some confusion about what the commands are doing.
It is good that you try to understand the commands before you use them.
for more information - enter
man dd
man gzip
the important command starts "sudo dd" - that is the bit where the drive gets imaged. I'll break it down in steps for you so you understand better:
sudo dd
- because you need to be root in order to access a /dev file.
if=/dev/sda
"if" means "input file", here we want to use /dev/sda - the entire internal hard drive - as the input. dd will read it in as pure binary, without trying to figure out what it is supposed to be. The drive needs to be unmounted to make a clean image.
| gzip > /path/to/storage/zipfilename.gz
the | is called a "pipe", which puts the output of the program in front of it into the input of the program after it. In this case, it takes the raw binary image of dd and puts it into gzip.
the > is also a pipe, but instead of a pipe to a program, it is a pipe to a file. So it's job here is to tell gzip where to put the resulting zip file. You can call the zip file anything you want, but it is helpful to make "zipfilename" something meaningful.
In this case, the file is a zip the image of sda created by dd, which is why I called it sda.dd.gz - but you can call it anything.
/path/to/storage/ is the absolute path to the filesystem you want to store the zip file in. If you use an external device, then this is the path to where the devices filesystem is mounted. That is going to be different for different systems, so you need to sort this out yourself.
Often, when you plug a removable device in, the OS will mount it for you in the /media directory. Go look. My system mounts my external drive as /media/usbdrive0 so, for me, /path/to/storage/ = /media/usbdrive0/ but yours will be different.
The reason we are piping the output directly to a storage medium is that you are running these commands from a live distro - running in RAM. It is unlikely you will have enough RAM to store the image. You can always cd into the directory you want the image to end up in first, in which case you can leave out the /path/to/storage/ part - which seems to be confusing you.