Posts Tagged ‘ohm2013’

live online root migration

Monday, August 19th, 2013

Hey all, yep before you ask, yes OHM was fantastic.
Others have eloquently described that experience, so I’m here to tell you a different story.
fuck cairo

I got an SSD this summer. They finally reached my cost-benefit pricepoint, and I’m not going to waste breath talking about how phun SSDs are. However, I will tell you about the little things I did that others would probably not do, most notably how I migrated a live running debian linux system from one disk to another.

I already RAID-1 my home partition, which has completely different data storage requirements, and besides it wouldn’t fit on 10 SSDs.

The SSD was to be my root drive, the OS disk. The OS is not so important in my setup, because the argument goes that if something dies, I can always reinstall it, I can always boot from USB, I can always configure it and the heavier stuff is in gone already.

I decided to put NILFS2 on it, which I’ve successfully used before to save my girlfriend from inadvertantly discovering how ext2undelete sucks, the argument being that log structured filesystems are better suited to solid state drives, then researched the heck out of it and found out about F2FS, which seemed like a better fit – if nothing else then because it’s faster, I don’t need log-based snapshots on the root disk and it’s not btrfs.

brain fuck schedule

I’m allowed the luxury to try out new things – I compile my very own kernels, complete with Con Kolivas patches as always, and I know I how to keep the pieces if something breaks.

Let’s try out this new magic.

First, the simple stuff; cfdisk/gparted to create one small /boot partition, one large root partition (all primaries of course, because extended partitions are evil) and leave some space for “something unexpected”.. then mkfs.ext2 -L boot /dev/sda1; mkfs.f2fs -l root /dev/sda2.

Why the boot partition? Just in case, mainly because experience has taught me this makes booting a whole lot easier in case of troubles that may or may not be ancient and deprecated in 2013. Let’s get the files there mount /dev/sda1 /mnt/target; rsync -a /boot /mnt/target/; umount /mnt/target.

What I am doing next is not difficult. It’s just not something anyone would consider safe. I want to sync the root filesystem over to the SSD. But I can’t be bothered rebooting into a USB stick, I want to continue using my system while I sync the 40 odd gigs (yes, fourty, ask me why), and I want to do it all in one go, creating the “cleanest” new filesystem with no fragmentation and with directories ordered spatially together on disk.

clever trap, sir

Therefore, first I disable any and all services that might write to root or var:

for daemon in prads gpsd munin-node hddtemp mpd atop powernowd atd and cron ddclient dictd libvirt-bin ntpd ssh timidity smartd uml-utilities postfix rsyslog arpwatch mcelog
do
  service $daemon stop
done

Afterwards, I give it a minute while watching pidstat -d 10 to see if anything else might write to disk. I see nothing and proceed:

mount -o bind / /mnt/src
mount /dev/sda2 /mnt/target
rsync -a /mnt/src/ /mnt/target/

Why did I bindmount? because I don’t want rsync to cross filesystem boundries, which it sometimes does regardless whether I tell it not to.

There are only two more things to do: update fstab and the boot loader. I’ve already disabled swap beforehand, but the rest of this I forget to do. Instead, I am excited to try out the new SSD-enabled system and reboot a little too early.

nuked

Thankfully I’m running grub – grub 1 at that, so much more user-friendly than grub2 – and I tell it to boot into (hd0,0). This fails because initrd cannot mount /dev/sda6. Well duh, that was the old disk at the old location. I mount /dev/sda2 and rewrite fstab. I reboot. Again it fails: the root= argument to the kernel doesn’t match fstab. I reboot again, edit the grub boot again, and it fails on the third try. Because f2fs doesn’t have fsck, and I’ve told it to do a pass in fstab. This is a modern filesystem, it fsck’s on mount. I tell it not to pass with a magic zero in the fstab and hoppla, fourth time is the charm, my machine boots with no further ado, and somewhat faster.

And before you ask, I am not fond of disk UUIDs either, they are terrible from a usability standpoint. Ever tried to type an UUID by hand, let alone remember one?

Furthermore,

Kernel command line: root=/dev/sda2 ro crashkernel=128M zcache vga=791
zcache: using lzo compressor
zcache: cleancache enabled using kernel transcendent memory and compression buddies
zcache: frontswap enabled using kernel transcendent memory and compression buddies
zcache: created ephemeral local tmem pool, id=0

hell yeah, zcache is finally in mainline, which means the ancient war between Time and Space has another battle and I get compressed memory pages which (hopefully) are both faster and more plentiful in physical RAM, now that I’ve foregone a swap partition.

I promptly recompile my kernel, timing the difference now that I use an SSD and zcache aand… it’s not much faster. Oh well, I guess it’s time to upgrade the system :-P

dark nite