On Saturday 02 January 2010 06:45:11 Brian K. White wrote:
Bob S wrote:
Hello SuSE people,
I did a dd backup on my 11.2. Question is can I update it with rsync, or more important could I restore certain files/directories using rsync?
Bob S
_what_ did you backup with dd? a filesystem? or a partition or whole drive that might have more than one filesystem?
Hello Brian. Thanks for your reply. I backed up one filesystem, oS 11.2 consisting of four partitions.
You can loopback mount a filesystem and update it's contents.
For instance if you did just a filesystem: If your "/" is/was /dev/sda3 and you dd'd it to an external drive: dd if=/dev/sda3 of=/media/my_external_drive/sda3.dd
You can update it's contents like this: mkdir /oldsda3 mount -o loop /media/my_external_drive/sda2.dd /oldsda3 rsync -axv --inplace --del /* /oldsda3 umount /oldsda3
The x in the rsync options means don't include other filesystems. Thats a quick way to exclude several problems at once such as oldsda3 itself and sys proc dev, but it also means any other seperate filesystems you do want, you need to include with separate rsync commands. Or use a single fancier rsync command using --filter or --exclude or --include etc which you are free to figure out yourself.
I would stick with the individual rsync commands otherwise it would get too complicated and mistake prone for me. Besides, I only wasnt to deal with one partition.
If you dd'd a whole drive with multiple partitions and multiple filesystems, that takes extra steps and there are are a couple ways. Ypu can follow this to see how to find out the offsets of the different filesystems within the dd image and use the offset option to mount. http://www.andremiller.net/content/mounting-hard-disk-image-including-parti tions-using-linux
Good info. Filed for the future. Don't think I would ever do a whole drive though. Never know.
Or you can use losetup and kpartx. I think this is easier and safer because you don't have to figure out the offsets or risk getting them wrong. losetup first to make a block device that maps to the file. # losetup -v -f sda.dd Loop device is /dev/loop0
Don't knowof losetup and kpartx but filed for future use if needed.
Now /dev/loop0 is like /dev/sda a device node that maps to an entire drive. Now kpartx to create /dev/mapper/* device nodes which map to the various partitions within the "drive"
# kpartx -av /dev/loop0 add map loop0p1 (253:0): 0 97632 linear /dev/loop0 32 add map loop0p2 (253:1): 0 19584 linear /dev/loop0 97664 add map loop0p3 (253:2): 0 931328 linear /dev/loop0 117248
This created: /dev/mapper/loop0p1 /dev/mapper/loop0p2 /dev/mapper/loop0p3
/dev/mapper/loop0p3 is the 3rd partition in the image, so if that was your "/" then: Mount it: mkdir /oldsda3 mount /dev/mapper/loop0p3 /oldsda3
Update it: rsync -axv --inplace --del /* /oldsda3
Now unmount and unmap everything: umount /oldsda3 kpartx -dv /dev/loop0 losetup -d /dev/loop0
Thanks for your very detailed and enlightening explanation. As I stated goes into my info for future use file. Bob S -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org