Page 1 of 1
Backup with dd
Posted: Sun Mar 22, 2009 7:15 pm
i have the following Idea:
Backup a Partition with dd and then Backup the Bootsector that everything is bootable later.
I did this:
dd if=/dev/sda2 of=/backup/partition.img
dd if=/dev/sda of=/backup/bootsec.img bs=512 count=1
then i experimenting with different operating systems (linuxe) eg, after this, i want to restore...
dd if=/backup/partition.img of=/dev/sda2
dd if=/backup/bootsec.img of=/dev/sda bs=512 count=1
rebboting and then.... grub error 2 !
why? what happens? is not everything complete? the bootsector, the whole partition with filesystem?
Posted: Mon Mar 23, 2009 8:40 pm
Are you sure the partition table was not modified by the 2nd restoration dd, it seems that you restored /dev/sda2 first and then the MBR that contains the partition table.
If you read http://en.wikipedia.org/wiki/GNU_GRUB
, you will see that Grub writes its stage1 in the MBR, and then it may have a stage-1.5 in the sectors just after the MBR.
So the static way (dd) to backup the boot manger is probably not the right method. I would prefer a program that can just run grub-install or something similar.
Posted: Sun May 17, 2009 8:04 pm
I think you should copy more than just first sector. Try copying first 63 sectors.
Code: Select all
sfdisk -n -d /dev/hda
# partition table of /dev/hda
/dev/hda1 : start= 63, size= 9767457, Id=fd, bootable
Because sectors start from 0, first 63 sectors (0...62) contains all needed information for boot. At least this works when I have copied disks with dd or partimage.
Why it doesn't work when using fsarchiver is still mystery for me. Grub should understand underlying filesystem, so that should not be the reason why I get "GRUB GRUB GRUB" when restored with fsarchiver. That problem is solved by reinstalling grub.
Grub error 2 is explained in grub page:
http://www.gnu.org/software/grub/manual ... leshooting
2 : Bad file or directory type
This error is returned if a file requested is not a regular file, but something like a symbolic link, directory, or FIFO.
Posted: Sun May 17, 2009 8:08 pm
I think the problem is that the grub files which are on the filesystem have moved. There must be a physical file location in the MBR (grub stage1 or stage-1.5 maybe) that refers to the extra grub files which are on your boot/root filesystem. Once these files are loaded (grub-stage2) then it knows the filesystems.
Posted: Sun May 17, 2009 9:16 pm
That would explain why copying 63 sectors cause bootable fs with partimage (copies files blocks by blocks to same places) but not bootable fs with fsarchiver (which copies files to different physical locations). I have understood that this is main-difference between partimage and fsarchiver. Correct if I am wrong.
I still don't understand why it matters. Because grub should understand the filesystem. Have to find more documentation about levels.
Posted: Sun May 17, 2009 9:53 pm
I am not absolutely sure, but I think this is because grub-stage1 uses a physical sector address to load grub-stage-1.5, and then grub-stage-1.5 is able to read filesystems. If the very first stage cannot load the module that understands filesystems then you cannot go further.
For instance grub-stage1 (instructions written in the mbr) may know that e2fs_stage1_5 is located at sector 1546, and then you save and restore your /boot that contains e2fs_stage1_5, and e2fs_stage1_5 is restored on sector 1849. The grub-stage-1 code which is in the mbr won't be able to read e2fs_stage1_5.
So if you have a separate partition for /boot and you only save/restore your root / data filesystems then you won't have these problems with grub.
Posted: Mon May 18, 2009 9:25 pm
fdupoux wrote:So if you have a separate partition for /boot and you only save/restore your root / data filesystems then you won't have these problems with grub.
Yes I see your point. Maybe one ideal solution could be also backing up
/boot -partition with partimage (small, doesn't need to be resized) and another partitions on same disk with fsarchiver (bigger, freely resizable in future). Then there would be no need to reinstall grub.
However, I already tested everything with my latest system rescue cd, so I wont bother to change and test again.
Offtopic, I hope that system rescue cd will make some day general tools, like ntfs-3g, partimage, dd, sfdisk easy to use. It would be usefull especially for beginners to have some sort off gui, which knows how to use right tool to right purpose without bothering user to know much about Linux. We have plenty of fdisks, plenty of imagingtools like partimage and still it is difficult for normal Windows-user to boot to Linux and make complete image of his/her computer in few minutes. That is the thing, what most of us want anyway, regardless of operating system.
Posted: Tue May 19, 2009 7:16 pm
It's a lot of work to do gui for these program, I prefer focusing on my existing projects. Saving and restoring the partition table is something that fsarchiver could do in next releases so it won't require another program in that case.