Snott

Author: snott

  • Recovering from a totally dead boot partition

    Recovering from a totally dead boot partition

    Here is the case:

    The hard disk containing your /boot partition has just died, you have a separate RAID1 array (using mdadm) with all the information on the array intact, but the system is unable to boot because all the files in /boot got lost.

    Your best bet is to get the following iso onto a USB flash drive or CD:

    http://sourceforge.net/p/ubuntu-secured/home/Home/

    Ubuntu secure remix provides the following functionalities:

    • Full Ubuntu DVD distro
    • integrates Clean-Ubiquity: automatic backup of the MBRs and partition tables when installing Ubuntu, which is highly recommended for dual-boot Ubuntu-Windows (or MacOS)
    • integrates OS-Uninstaller (tool to uninstall any Operating System from your PC)
    • integrates Boot-Repair (tool to fix the PC boot)

    the one highlighted in bold is what we are going to use to fix the boot partition.

    With the ubuntu DVD and Boot-repair you will be able replace the missing kernels and initrds, reinstall any broken packages and get grub again onto the MBR, successfully restoring the computer or server to a bootable state.

    Now, burn your iso to cd (I assume you know how to do this) or get into an USB drive like this:

    dd if=/path/to/file.iso of=/dev/sdb

    where /dev/sdb is your USB drive, you can use the mount command to double check this. If you make a mistake here (for example if you input /dev/sda and /dev/sda is your laptop hard drive) you will end up writing the iso to your hard drive and DESTROY all of your data. So please double-check this.

    After you boot into the Ubuntu Secure Remix, first thing to do is chroot and then create a /boot directory (since the old one is lost). Chroot is a command that will mount the operating system stored on the hard drive so you are able to execute commands inside it. This is a very important step. To do this:

    # means run with root or sudo
    1. Create a mountpoint

    # mkdir /mnt/mountpoint

    2. Mount /dev and /dev/pts to chroot

    # mount -o bind /dev /mnt/mountpoint/dev

    # mount -o bind /dev/pts /mnt/mountpoint/dev/pts

    3.Open bash in chroot

    # chroot /mnt/mountpoint /bin/bash

    4. create the /boot directory

    #mkdir /boot

    At this point, you are now inside your unbootable linux system with and empty /boot directory, now do:

    sudo apt-get install linux-image-server

    That command (on a debian/ubuntu based system) will pull the latest kernel image and install it, populating the /boot directory with some files (which are the kernel and initrd images). If you have a different distro do the same with your distro’s package manager.

    Next open up Boot-repair from the GUI and follow the onscreen instructions to restore grub into the mbr. I won’t post them here because:

    a) it varies from system to system and depends on how screwed the OS got

    b) On screen instructions are easy to understand and get the job done

    After Boot-repair finishes, exit your chrooted terminal (by typing exit at the terminal) and restart your system.

    Everything should be in order now and the machine should boot without a problem. If it does not, feel free to leave a comment below and I will do my best to help you.

    NOTE: This procedure was tested under a Software RAID using mdadm on Ubuntu Server 10.04.4 LTS, I haven’t tested this with any other RAID array configuration or distro, be it fake, firmware or hardware RAID.

  • Thanks for the support!!

    Thanks for the support!!

    When I started this blog I did it as a hobby and to document some of the hiccups I get while managing my servers. Today I want to share with you the annual report on how this site did. People tend not to share this kind of things but I do.

    http://jetpack.me/annual-report/23384437/2012/

    The most surprising stat for me is that on 2012 alone, this blog racked up 22 000 visits, that’s a lot when you take into account that I don’t do SEO at all, I just write what comes to mind and problems or cool stuff I find on the net.

    To every one of you 22 000 visitors I want to say thank you! This year I will try to make a lot more posts to keep you coming back for more!

    If you have any suggestion for me to improve this blog or any topic you want me to blog about, feel free to contact me at admin at snott dot net.