Tuesday, January 30, 2007

Rescuing a Linux installation

In an attempt to save a system without doing a fresh reinstall by copying the contents from dying hard drive to new hard drive using external hard drive enclosure. This method seems to have worked well for me. I'm posting it as reference so others have a guide to work from and improve upon. I have only used this method once so make sure you know what you are doing if you follow the guide.

WARNING: Use the following formation at your own risk. Make sure you make proper backups. The following information may have errors or may not work properly
and could possibly damage your system or cause the loss of data. Once again, use the following at your own risk. Research how to use each individual command so you know what you are doing.

Guide to moving a Debian or Ubuntu Linux installation from an old hard drive to a new hard drive without re-installing.
  1. Attach external hard drive
  2. Reboot computer into single user mode (i.e. rescue mode)
  3. Find the new device of the external hard drive (probably sda or sdb) dmesg | grep hd; dmesg | grep sd
  4. create new partions on new drive: fdisk /dev/sd(a,b, etc.)
    1. create swap partition
    2. create linux partition(s)
  5. initialize swap: mkswap
  6. create filesystem (I'm using ext3): mkfs.ext3
  7. Mount the new hard drive (referred to as /dev/sda2 from now on): mount -t ext3 /dev/sda2 /mnt
  8. Use debootstrap to get base install (ubuntu edgy example): debootstrap edgy /mnt http://us.archive.ubuntu.com/ubuntu
  9. Now the copy command: rsync -av --exclude=/dev --exclude=/sys --exclude=/mnt --exclude=/proc --exclude=/media / /mnt
  10. Make partition bootable: fdisk /dev/sda2 # use the 'a' option
  11. Shutdown system and put in the new drive.
  12. Get Grub working again:
    1. Insert Ubuntu or other Debian based live CD (Knoppix is a good choice too).
    2. Mount the new drive: mount -t ext3 /dev/hda2 /mnt
    3. Install grub: install-grub --root-directory=/mnt /dev/hda2
    4. chroot into new drive: chroot /mnt
    5. edit /boot/grub/menu.lst
      1. Update groot(hd0,) #if bootable partition changed (i.e. Was /dev/hda5 is now /dev/hda2... Old: groot(hd0,4) New: groot(hd0,1)
      2. Update kopt=root #if bootable partition changed (i.e. Was /dev/hda5 is now /dev/hda2... Old: kopt=root=UUID= or kopt=root=/dev/hda5 New: kopt=root=/dev/hda2 (NOTE: There is probably a way of getting the new UUID of the new partition, in which case you can just update the UUID option, but I don't know enough about this yet to offer advice... Feel free to post a comment if you know more.)
    6. type: update-grub
  13. Reboot and hope everything works properly.

Labels: , , , , , , ,

Wednesday, January 17, 2007

xen error: Error: Device 0 (vif) could not be connected. Backend device not found.

Currently, I'm working on setting up Xen 3.0.3 on Debian Etch 64-bit. I installed the debian packages rebooted and used xen-tools to create a Debian etch guest domain. When I used xm create -c debian_etch_guest.cfg vmid=1 I got the following error:

Error: Device 0 (vif) could not be connected. Backend device not found.

I googled for the error and didn't immediately find a solution to the problem (it may still be there in the search results), but as it turned out, the only thing I needed to do was install bridge-utils:

apt-get install bridge-utils

That's it, now the guest domain boots without a problem.

Labels: , , ,