Maybe this will sound like dumb question but the way i'm trying to do it doesn't work.
I'm on livecd, drive is unmounted, etc.
When i do backup this way
sudo dd if=/dev/sda2 of=/media/disk/sda2-backup-10august09.ext3 bs=64k
...normally it would work but i don't have enough space on external hd i'm copying to (it ALMOST fits into it). So I wanted to compress this way
sudo dd if=/dev/sda2 | gzip > /media/disk/sda2-backup-10august09.gz
...but i got permissions denied. I don't understand.
Do you have access to the sda2-backup...gz file? Sudo only works with the command after it, and doesn't apply to the redirection. If you want it to apply to the redirection, then run the shell as root so all the children process are root as well:
Alternatively, you could mount the disk with the uid / gid mount options (assuming ext3) so you have write permissions as whatever user you are. Or, use root to create a folder in /media/disk which you have permissions for.
Other Information that might help you:
of
instead ofif
and you end up overwriting what you are trying to backup!! Notice how the keyso
andi
are next to each other? So be very very very careful.In the first case,
dd
is running as root. In the second case,dd
is running as root butgzip
is running as you.Change the permissions on
/media/disk
, give yourself a root shell, or run thegzip
as root too.In addition, you can replace gzip with
bzip2 --best
for much better compression:7z utilizes all CPU cores. Also, adding
bs=32M
or with some other non-default values may significantly speed up the process.Test results:
Almost 2 times faster.
And, almost 2 times smaller.
Credits to Igor Pavlov for that.