Restoring root-fs to smaller disk-system

Please ask questions here if you are not familiar with fsarchiver
Post Reply
tuipveus
Posts: 44
Joined: Thu May 14, 2009 7:02 pm

Restoring root-fs to smaller disk-system

Post by tuipveus » Thu May 14, 2009 7:10 pm

I would like to restore root-filesystem among others to smaller disk or disksystem.

My setup currently:
sda1 = /boot
sda2 = swap
sda3 = /

First I took backup with dd of 63 first sectors and restored it to smaller disk.

Then I took dumps with sfdisk of partition table and restored it to smaller disk. Because physical disk is smaller, it doesn't work.

After that I restored partitions of only sda1 and sda2 with sfdisk and made smaller than original sda3 with cfdisk.

Then restored filesystem with fsarchiver. System can't find operating system. After that I tried to install grub with:

"grub-install /dev/sda"

but it failed with error:
/dev/sda: Not found or not a block device.

After I did
"mount /dev/sda1 /something/somewhere"
and

grub-install --root-directory=/something/somewhere
... I managed to install grub.

However, now I can see only grub-commandline when booting, not grub menu.

How should I install grub so that menu would also work and I would be able to boot?

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

Post by admin » Thu May 14, 2009 7:32 pm

You are right, fsarchiver can copy filesystem but not the partition table and not the boot manager.

To reinstall grub, you can do that:

grub
> root (hd0,0)
> setup (hd0)
> quit / exit

In your case:
(hd0,0) == /dev/sda1
(hd0) = /dev/sda

If you don't see the menu, maybe it cannot find your grub config file. Make sure you have both grub.conf and menu.lst, these two names can be used for the config file (you can make a symlink)

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

Post by tuipveus » Fri May 15, 2009 11:49 am

I have now workaround, but still not satisfied that I am not able to copy grub and I have to install it.

I have 2 receipts for complete bootable backup:

receipt 1)

a) take mbr with dd (if windows, take first 63 sectors, instead first one)
b) take extended partitiontable with sfdisk dump
c) save partitions with partimage

receipt 2)

a) take mbr with dd (if windows, take first 63 sectors, instead first one)
b) take extended partitiontable with sfdisk dump
c) save partitions with sfarchiver
d) mv /boot /boot_sysresccd
e) mkdir /boot
f) mount /dev/sda1 /boot
g) grub-install /dev/sda

If I skip steps d,e,f grub-install will complain that sda is not blockdevice etc. Even with specifying directory, I can't get it boot if I skip those steps.

Post Reply