Pages

Showing posts with label fsarchiver. Show all posts
Showing posts with label fsarchiver. Show all posts

2014-02-08

New hardware, old Linuxes

I swapped out my 5 years old machine to a bit more contemporary one.
Everything except video card (gtx 560) and one irrelevant hdd got swapped out.
Relevant changes were - ahci/ehci mode for hdd-s, new sound chip, new network chip.

Practical philosophy for hardwaring:
Decide what you really need - for example, in my case:
- inverted-layout box, as I keep it against wall and wanted to turn back panel to front (which would have caused blocked cooling for classic box). AND - it's very, very inconvinient to have big video card and hdd-s kissing each other.
- bigger hdd bay, for not cramming several hdd-s on top of each other.
- modular psu, as miditowers are bloody tight really.
- and if you do not need raid or full-ATX or simply-mucho-expencive MB, then really, you don't.
Why back panel in front, you ask? Because it irritates me to have usb-s divided between ends of box. So I cannibalized the front and planted usb-s, switches and leds to back panel, closed holes in front panel and - done.
- There are two things one have to read - as RTFM - MB manual and Bios. Don't skip!

Software, fixing it:
I packed (and backed) up all my current 5 linuxes with fsarchiver. Then I connected the new system-hdd to the old machine and unpacked distros to their new partitions.
When the new box was ready - bios checked etc, it got it's hdd-s installed. First boot was from usb stick (which happened to be PartedMagic).
Usb because, with such a total overhaul there are some things to be done before you can have any hope to see your dear display manager again.

# Did the distros end up on different partitions (of originals)? Open up all etc/fstab-s and correct them. There is no such problem if fstab uses UUIDs (sudo blkid to get whole list) as fsarchiver restores systems with original UUID.

# Chroot.
For that procedure it's better to google and find your own recipe - I am not sure that mine is the very right one.
What you have to do is, basically: mount and bind targets' /sys, /proc and /dev (for debian, better to mount also sysfs) to /mnt, then
sudo chroot /mnt. And fun begins.
Patients: Slackware, Salix, Vsido and my own netinstalled Wheezy and Sid. All need new initrd files (changed drivers!)
- Slackware and Salix have most nice mkinitrd script, currently ran like that:
/usr/share/mkinitrd/mkinitrd_command_generator.sh -k 3.10.17
which works no problems. Run lilo afterwards. In my case, lilo is in root part (not MBR), and has to be run with partition-number: lilo -b /dev/sda2 -c
- Debians: dpkg-reconfigure linux-image-3.x.x... (number is uname -r). Which is dandy, except that uname -r in chroot shows number for host kernel. So I checked up how old initrds look and - seems that everything between kernels' number-start and .gz IS the right thing. Example:
dpkg-reconfigure linux-image-3.11-10.dmz.1-liquorix-amd64
The good thing with previous command is - it also renews your grub.
Done with chroot. 'exit' and 'umount' everything you mounted.

- And that was all that Slackware needed for reaching the desktop.
- Not so with Debians - error: no screens, and no xorg. To cut it short, the solution was  simple: delete /etc/X11/xorg.conf and recreate it. Mind! I am talking of Nvidia binary driver. It installs itself and also makes new xorg.conf. I do not know what happens with other video drivers.

# Network: new chip, new interface = no network.
The important file is
/etc/udev/rules.d/70-persistent-net.rules
Only Wheezy - somehow - managed to create new entry there (with new mac number!), and named it as eth1. And/but - eth1 does not start automatically - still no network.
So, I copied this new entry to every other distro, changed NAME="eth0", and that was that. I still do not know where to find mac numbers :)
It is also said that deleting that file and rebooting creates automagically the new (correct) one.

# alsa gave a looooong list of warnings when starting (but worked). In Slackware, delete
/var/lib/alsa/asound.state
and create new, 'alsactl store', done.
In Debians.... I think it just went away after first boot.

# Sid and sensors. Or, really - no sensors... Run:
sudo sensors-detect, answer questions, let it write modules and run:
sudo /etc/init.d/kmod start
Done.

# Annoyances:
- monitor dimensions changed and some (desktopy) things were not in right places anymore.
- sensors data presentation errors in conky (new cpu, new 'cut's  etc)
- console resos out of whack. None that is possible according to vbeinfo is fitting for 1920x1080. and KMS doesn't work as I use proprietary driver... bugger. Still no solution here.
- some 5-6 irritable hours thrown into googling.
And I am sure there will be more things creeping out.

But all in all - it was quite alright compared to coming reinstall of borked Windows. Always hated that...
'Old Linux in new box' can be summed like that: fstab, initrd, 70-persistent-net.rules. Done.

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.