laszlo.nu

How I backup my Linode instances over ssh

Sometimes you need to backup a complete disk image. I’m using Linode for some things, and the other day I was shutting one of the nodes down. I wasn’t sure the node had any important data on it, so I had to make a backup.

The workflow described in the Linode Library is broken. It suggests running the dd command in the rescue console, directly over ssh. The problem seems to be that before you run the command to dump the disk to stdio, you have to interact with Lish, the Linode Shell, and select the right node etc.

First of all, trying to run the suggested command doesn’t work at all:

ssh: connect to host 123.123.123.123 port 22: Connection refused

And when I actually managed to connect, I was greeted with the following error message:

[linode12345@london363 lish] Thu Feb  6 02:16:50 EST 2014
[linode12345@london363 lish] Linode Shell (lish) Console starting...
[linode12345@london363 lish] $TERM too long - sorry.
Your Linode isn't running, or another console session is already active.

To make a long story short. First I did the following on my local laptop:

$ export TERM=screen-256color # lish didn't like my long term
$ ssh -t my_username@lish-london.linode.com linode12345

When connected to my linode, I did the following:

root@hvc0:~# mkdir backup
root@hvc0:~# sshfs my_username@mylaptop.isp.se:/backups/linode/ backup  # mount a directory on my laptop
my_username@mylaptop.isp.se's password: 
root@hvc0:~# cd backup/
root@hvc0:~/backup# dd if=/dev/xvda | gzip -9 - > linode.img.gz
49807360+0 records in
49807360+0 records out
25501368320 bytes (26 GB) copied, 4247.53 s, 6.0 MB/s

Piping the image to gzip isn’t strictly necessary, but I knew the disk was mostly empty so I figured it would compress pretty well. Downloading things from Linode isn’t very fast for me, so this reduced the 26 GB image to 3.3 GB.

Arch Linux on HP Proliant DL380 G4

I recently got my hands on an HP Proliant DL380 G4. After fiddling with it for a while, trying to get the VGA port to output anything whatsoever, I finally managed to get it up and running. The VGA fix was easy - just unplug all the memory and plug it again. No idea why that worked though…

The trickiest part was getting Grub2 to load Arch (in Ubuntu it just works though), so I thought I should make a note about it for future reference since a quick google search did not yield any results.

The DL380 G4 comes shipped with an HP SmartArray RAID controller, version i6. Currently, the newer hpsa driver is not supported for the i6 SmartArray, instead you have to use the old CCISS driver. The two drivers have some interesting differences. The former uses the kernel SCSI interface and hence the drives get mapped to the well-known /dev/sda1 etc, whereas the latter maps to /dev/cciss/c0d0p0.

So it turns out that Arch’s setup script is not able to auto detect my RAID controller. Instead I get the annoying message “root boot device could not be autodetected”. To solve this, I did the following:

  • Follow the setup script until you get to the install bootloader step. Try it, it might work. At least it should generate a decent menu.lst for you. You will now probably watch it fail with the above message, though.
  • You should now have your newly created partitions mounted under /mnt but before chrooting you will some devices etc:
    # mount -o bind /dev /mnt/dev
    # mount -t proc /proc /mnt/proc/
    # mount -t sysfs /sys /mnt/sys/
    # chroot /mnt bash
    
  • Create the file /boot/grub/device.map and add this line to it:
    (hd0) /dev/cciss/c0d0
  • Now, run grub --device-map=/boot/grub/device.map
  • In the grub prompt, run grub as usual:
    > root (hd0,0)
    > setup (hd0)
    > quit
If you get an error message in any of the steps above, investigate! Otherwise it should have worked and your OS should boot from your raid volume.
life:

Wow, this photo: A little girl receiving tests gazes into pool containing baby ducks — an early use of animals as part of medical therapy, 1956.
(see more photos here)

life:

Wow, this photo: A little girl receiving tests gazes into pool containing baby ducks — an early use of animals as part of medical therapy, 1956.

(see more photos here)

(via mightequinn)