Saving and restoring bootable partitions using fsarchiver

Post here if your topic does not match the previous sections
gnu
Posts: 2
Joined: Mon Nov 16, 2009 9:05 am

Saving and restoring bootable partitions using fsarchiver

Postby gnu » Mon Nov 16, 2009 9:34 am

Hello,
I read the posts about dd and that is what I was using before I found out about fsarchiver. My situation is the following: I use a bootmanager - not grub (bootus) - in the mbr and have chainloaded bootmanagers in several partitions. When restoring a bootable partition (grub in the partition) with fsarchiver the partition would not boot. After saving I formattet the partition to make sure it was clean. I guess you only save the files. OK. So I have to do an extra saving with dd. How much do I have to save in order to get the partition table and partition boot loader? (It seems to be sectors 0 to 63 ?)
One afterthought: You say fsarchiver can restore into smaller and larger partitions. So it does write the partition table ? Always? Then what do I have to save and to restore with dd in order to let the changed partition table untouched but get the bootloader back?
Thanks

admin
Site Admin
Posts: 550
Joined: Sat Feb 21, 2004 12:12 pm

Re: Saving and restoring bootable partitions using fsarchiver

Postby admin » Mon Nov 16, 2009 7:15 pm

fsarchiver does not save partition tables. It only saves the contents of filesystems.

The idea is that fsarchiver is a dynamic tool that recreate things, this way you can recreate a filesystem with the appropriate size on a smaller disc. It's not a static tool that makes a copy of data and that restores exactly the same things: if we did that with the partition table it would restore a table with inappropriate partitions on a different disk.

You can use parted in script mode to recreate the partitions. Can't you dynamically reconfigure bootus ?
You can copy sectors using dd but you have to know what you are doing, and where things are located on the disk.

gnu
Posts: 2
Joined: Mon Nov 16, 2009 9:05 am

Re: Saving and restoring bootable partitions using fsarchiver

Postby gnu » Wed Nov 18, 2009 11:20 am

Hello
my misunderstanding came from the fact that fsarchiver is being compared to partimage which is misleading. You say I have to know what I am doing when I use fasarchiver to save bootable partitions. You could help me if you tell me from what sector on fasarchiver is writing back to the device. Is it filesystem dependent then lets say for ntfs and for reiserfs. Is this the start of the first superblock?
Thanks again

admin
Site Admin
Posts: 550
Joined: Sat Feb 21, 2004 12:12 pm

Re: Saving and restoring bootable partitions using fsarchiver

Postby admin » Sat Nov 21, 2009 8:50 pm

Windows and Linux have different way to install the boot code. For ntfs you don't have to save any particular sector: it should be bootable when you restore it. For Linux, you have to restore the sectors where grub has been installed. You can use a static program such as dd only if you kept exactly the same partitions layout.

This may help you:
http://www.sysresccd.org/Sysresccd-Part ... oot-stages

tuipveus
Posts: 43
Joined: Thu May 14, 2009 7:02 pm

Re: Saving and restoring bootable partitions using fsarchiver

Postby tuipveus » Sat Feb 20, 2010 10:19 pm

admin wrote:You can use a static program such as dd only if you kept exactly the same partitions layout.

This may help you:
http://www.sysresccd.org/Sysresccd-Part ... oot-stages


Your first comment is not entirely true, but everything was well written in that url. I have stages 1, 1,5 and 2. Let me explain story, about my latest harddrive crash.

I have Debian Linux system, which is actually my moms computer and I haven't backed it up since there is nothing important to loose. Few weeks ago, I updated the deb-packages with normal aptitude update && aptitude safe-upgrade.

Suddenly I noticed that there was some strange language xml which run fast and soon I got errors with some of the debs and I found out that fs (ext3) was corrupted. I took md5sum of the deb's in cache, and found out that there are about 10 different md5sum compared to my stable computer. I redownloaded the broken packages, and installed those again. Everything was fine. After that I restarted computer to single user mode and marked badblocks with "fsck -c" For me it is still mystery, why installer installed those packages, even their md5sum did not match.

harddrives:

a) 40 GB original
b) 40 GB
c) 20 GB
d) 6 GB
e) 6 GB


Now after couple of weeks I took 4 old + (original 40GB) harddisks, from size 6GB to 40GB. First I put 40GB (b) harddisk to my computer and noticed with smartctl that it also had bad blocks.

I saved data from original broken 40GB harddisk to 6GB harddisk, and tried to restore it to 20GB harddisk. When I was restoring, fsarchiver complained about broken file (checksums works!) and I noticed that third (6GB) (d) harddisk was also broken. This time I didn't get any hardware errors.

Then I took the original harddisk and 6GB (e) harddisk again and saved the data there. Restarted the computer with new harddisk. Everything worked fine, but just to make sure I restarted it again to singleuser mode and run "e2fsck -c". Again I found bad blocks. Harddisk (c) 20GB was also broken, even it was booting.

Since I had correct data in working disk (e), I made new image from original hd to empty space of broken 20GB hd (c). After this I checked md5sums and everything was matching. Good enough! I restored data successfully from broken 20GB hd, where images were correctly written to 6Gb (e).

After I restarted, I noticed that cfdisk didn't liked my partitiontable. Original partitiontable was probably corrupted since hdx2 partition was ending after end of disk. There might be also some problems with CHS, because my target disk was actually a lot smaller than original.

First I used dd to copy 63 first blocks from original disk to set grub stage2. Then I used sfdisk to dump partitiontable and edited the sfdisk dump-file by hand just to copy first partition (/boot). I added the other partitions with cfdisk, restored the dumps with fsarchiver and after that it booted fine and cfdisk was also happy about partitiontable.

Result:

a) 40 GB, boots to os but has bad blocks (which are marked as badblocks in fs)
b) 40 GB, broken
c) 20 GB, boots to os, but has bad blocks ( all are not marked as badblocks in fs)
d) 6 GB, broken
e) 6 GB working and in use now!

System works and boots because

1) I copied 63 sectors which contains the grub stages 1 and 1,5
2) my /boot is in same partition but physical place on disk of stage 2 might be in different place
3) my / is still in hda6/sda6, where it was before. No need to modify menu.lst.

There was no need to reinstall grub!

Questions:
1) deb-packages have some checksums, but they were still installed even if they were broken, why? (not actually fsarchiver -question)
2) after final restoring I did run e2fsck -c again in singleuser and e2fsck did some modifications to disk. However I am not able to see any badblocks anymore. Does this mean that fsarchiver also saves the badblock-information with filesystem and by running e2fsck -c I "released" those blocks again?

admin
Site Admin
Posts: 550
Joined: Sat Feb 21, 2004 12:12 pm

Re: Saving and restoring bootable partitions using fsarchiver

Postby admin » Wed Feb 24, 2010 3:04 pm

1) maybe your deb package have been corrupted after they have been installed
2) fsarchiver does nothing particular about bad blocks.

I don't want to save static blocks like that for grub because it would be very complicated. The plan is to save and restore the partition table normally (considering partitions, not just low level blocks), and then to run a command to reinstall grub. It should be flexible enough and it should work on different hardware. I am not sure that reinstalling grub this way can work, but at least it's ok for partition tables.

tuipveus
Posts: 43
Joined: Thu May 14, 2009 7:02 pm

Re: Saving and restoring bootable partitions using fsarchiver

Postby tuipveus » Wed Feb 24, 2010 8:13 pm

Now the fifth e) harddisk had also bad sectors in it. :(

admin wrote:1) maybe your deb package have been corrupted after they have been installed


I agree that it is theoretically possible, however I think it is unlikely that 10 packages suddenly have different md5sum and several broken packages gave strange output to screen during installation.
admin wrote:
2) fsarchiver does nothing particular about bad blocks.

I don't want to save static blocks like that for grub because it would be very complicated. The plan is to save and restore the partition table normally (considering partitions, not just low level blocks), and then to run a command to reinstall grub. It should be flexible enough and it should work on different hardware. I am not sure that reinstalling grub this way can work, but at least it's ok for partition tables.


So if I understood correctly, fsarchiver will make (create) the new filesystem with exactly same size as in the archive and badblocks information is not stored to archive. This means that broken harddisk should not be restored to another broken harddisk, even if it is the same harddisk. (who needs to use broken harddisks anyway!:)

If I restored fs to harddisk which is intact and run e2fsck -c, why e2fsck did some modifications to disk and after those modifications I still did not have any broken blocks?

Well, now finally that harddisk has died anyway. I have to buy brand new, since I have already wasted a lot of time with restoring to old non-working harddisks.

Any idea what is causing the corruption in my 5 harddisks? Are they really all 5 broken, or is there some problem with controller or ram? I think I will run memtest86 asap.

admin
Site Admin
Posts: 550
Joined: Sat Feb 21, 2004 12:12 pm

Re: Saving and restoring bootable partitions using fsarchiver

Postby admin » Thu Feb 25, 2010 12:26 pm

fsarchiver is flexible so it will just create the appropriate filesystem for the destination partition. The size of the filesystem is always the size of the destination partition you provide to restfs. It does nothing special with bad blocks.

You can run tests on linux-2.6.32 with btrfs which has checksumming to see what happens. SystemRescueCd-1.4.0 comes with this kernel version so you can try btrfs this way.

tuipveus
Posts: 43
Joined: Thu May 14, 2009 7:02 pm

Re: Saving and restoring bootable partitions using fsarchive

Postby tuipveus » Wed Jun 30, 2010 9:03 am

tuipveus wrote:Any idea what is causing the corruption in my 5 harddisks? Are they really all 5 broken, or is there some problem with controller or ram? I think I will run memtest86 asap.


Controller was most probably faulty. Replacing controller fixed the issue (Installed Ubuntu 4 days ago and system is still stable and debsums can't find broken files)

MBA Whore
Posts: 2
Joined: Thu Oct 09, 2014 3:27 am

Re: Saving and restoring bootable partitions using fsarchive

Postby MBA Whore » Fri Oct 10, 2014 8:39 pm

I am reviving this old thread since it deals with my exact issue. I am not very computer-smart so forgive my ignorance.

Situation: I image my USB flash (it has only 1 partition) with FSarchiver. When I restore it, it will not boot. Only recently I learned FSarchiver is a "file-by-file" program so it excludes grub.

I like FSarchiver. It is flexible. What I mean is this: It can restore the file system to a destination of any size as long as the destination is large enough to hold the uncompressed data. The only problem is that I can't get the restored image to boot.

It would be a perfect "one-stop-shop" if I could just find an easy way to make the restored image bootable.

What if I made a /boot partition? Would that work? What options do I have to make the restored image also become bootable?

tuipveus
Posts: 43
Joined: Thu May 14, 2009 7:02 pm

Re: Saving and restoring bootable partitions using fsarchive

Postby tuipveus » Thu Aug 27, 2015 2:54 pm

It would be a perfect "one-stop-shop" if I could just find an easy way to make the restored image bootable.


For one-stop-shop, you should try Clonezilla. But then again, you will loose the flexibility of fsarchiver... unless you backup the partition of filesystem with fsarchiver and the rest with fsarchiver. And even then you will need to play with partitions manually, if you plan to restore to smaller disk.


Return to “Miscellanous”

Who is online

Users browsing this forum: Google [Bot] and 1 guest