Pages

2013-05-28

Fsarhiver, moving OS

And also backing up all shit, of course.
Links of backing up  and to get SystemRescueCD (has fsarchiver and partimage). Especially first link gives nice overview what happens and so on. Also link to fsarchiver itself.
The following is not so much of backing up, but of moving your (backed-up) distro to entirely different partition.
I chose Fsarchiver because it can write to a partition of different size of original... PartImage can not. Other option could be Remastersys, of course. Somehow it seemed more difficult to me... might be - for no reason.
Anyway, it's an AAR of moving installed distro to another partition, AND making it also a master of multibooting Grub2. Yes-yes, finally I am going to remove my Openboxed Xubuntu from this exalted position and elevate freshly-cooked Wheezy Openbox to be the new boot-boss.

What I did:
Dramatis personae: sdb/MBR - bootloader from sdb6 Xubuntu, sdb8 Vsido, sdb9 Wheezy, sdc2 is a backup partition.
Vsido has fsarchiver out of box - if you don't (have Vsido or fsarchiver), install it.
I started in Vsido, opened terminal and:

# mount a partition to put an archive on
sudo mkdir /mnt/back 
sudo mount /dev/sdc2 /mnt/back 
# make backup
sudo fsarchiver -j2 savefs /mnt/back/backup-sdb9-deb.fsa /dev/sdb9
# last command creates a file from whole sdb9 and puts it to sdc2. 3G was compressed to one and it took 4 minutes. -j2 means that my old AMD X2 can use both cores for this task.
If curious what's in there:
sudo fsarchiver archinfo /mnt/back/backup-sdb9-deb.fsa
# Shows you some information about the file.
sudo umount /mnt/back


Then I rebooted and logged into Wheezy - thinking that then I wouldn't have problems with different grub versions... As I realized afterwards: there is no difference - when chrooted in, you download proper grub anyway.
And another afterthought: it might have been really wiser to make that bloody live usb and do the thing from there - less problems with uuids.
Opened Gparted and formatted sdb6 to ext4. Xubuntu died - and together with it, booting Grub. No going back now...
Then I restored previously created archive to sdb6 (and id=0 means that there is only one file-system in archive):

sudo mkdir /mnt/back 
sudo mount /dev/sdc2 /mnt/back
sudo fsarchiver -j2 restfs /mnt/back/backup-sdb9-deb.fsa id=0,dest=/dev/sdb6
sudo umount /mnt/back 
TWO important things to do now:
1. Fix /etc/fstab of your new 'installation'. Because uuid remained the same for both Wheezys, I couldn't mount the other one. @#%$#@@ and shit! So I opened fstab of old one and replaced uuid with /dev/sdb9. After that I could mount and fix fstab of the new Wheezy: I also replaced this uuid - in this case with /dev/sdb6 (as root partition) and that was that.
2. Harder part. Fsarchiver writes things back, BUT it doesn't put them into exactly the same place. So, you have to reinstall your Grub. Even if the partition is the same you started with.
In my case, it was different and I also needed already installed root-grub to be replaced by new mbr-grub.
Mount-chroot-purge-install-update:

sudo mount /dev/sdb6 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
apt-get purge grub-common
# 4 packages get removed
apt-get install grub-pc
# 4 comes. AND it asks WHERE to install. Do NOT answer wrong!
update-grub
# Somehow, it missed Vsido. (But I got it after reboot.)
exit
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt
sudo reboot
If someone wants to play with uuids, then blkid shows uuids of all partitions, and uuidgen can produce new random uuids. Then do:
sudo tune2fs /dev/sdb6 -U number-you-generated. And your sdb6 partition has a new uuid.

My new 'bootmaster' booted without problems, and additional fast 'update-grub' found, yes, everything that was bootable.
I am not sure if installing from remastersys-backup is not a better way. But doing it with fsarchiver was certainly educating... though somewhat scary.

No comments: