Fix Your Broken Linux with chroot

  • S07E36
  • June 3, 2014

Robbie's Linux kernel is missing and he can't boot. Use chroot to fix problems like this, or to reinstall grub, or anything else that requires a bootable computer.

This video is provided free of charge. If you enjoy what we do, please consider becoming a Patron so we can continue offering more great content.
Support This Free Content
Notes:
We used one of the Logitech C920 webcams for our main camera this week to see if we could get good picture without the flicker.

Topics Covered:

  • {play 3:58}Greetings to viewers hanging out in the chat room.
  • {play 4:52}An update on our unRAID server: Robbie replaced the parity drive, but one of the data drives failed. This is when good backups come in, but also shows how unRAID is just a dream when recovering from catastrophic failure. Review Episode 103 for details about our unRAID system.
  • {play 8:17}Battle of the Bands is this Friday.
  • {play 9:04}Feature: Fixing a broken Linux installation using a Linux live CD and the chroot command.
    • Scenarios where simply mounting the hard drive from a Linux live CD is adequate:
      1. You've modified your /etc/fstab file and accidentally broke it. Now you can't boot.
      2. Your video driver install failed and you now have a broken video system, you can fall back to nvu by editing the config (eg., /etc/X11/xorg.conf).
    • Scenarios where that just isn't good enough and you really need to boot into a working Linux system to fix the problem (as demonstrated in this tutorial):
      1. Your grub installation is broken and you want to reinstall or update-grub.
      2. Your Linux kernel is missing or corrupt. While incredibly rare, this can happen after a failed apt-get upgrade.
      3. Your video driver install failed and you'd like to fix it (rather than just falling back to another driver).
    • Robbie boots into his Linux installation, which is missing a Linux kernel, to be greeted with a "GNU GRUB Minimal BASH-like line editing is supported" message.
    • To chroot into your system, you'll need a Linux live boot CD or bootable USB stick that has the same architecture (eg., i386, AMD64), and ideally (though not required) of the same distro and version of your installed system.
    • The methods we're showing will work (with slight modification to lines such as apt-get update where applicable) on any Linux distro: Ubuntu, Fedora, Arch Linux, Linux Mint, Point Linux, Debian, Manjaro, you name it!
    • Using the Linux live CD, we can easily browse to our computer's hard drive to backup our files, or fix issues such as those outlined in the first group of scenarios above.
    • Let's chroot to our Linux hard drive...
      • Use sudo fdisk -l to see a list of your hard drive partitions, and determine which one is your actual Linux installation partition. We'll call this sdXX (replace XX with your drive and partition, eg., sda2).
      • Create the mountpoint:
        sudo mkdir -p /mnt/mydrive/boot
      • Mount the root of your partition to our new mountpoint's base:
        sudo mount /dev/sdXX /mnt/mydrive
      • Note: If you have /boot or /home or any other mountpoints on a different partition on your installation, you'll need to also mount them now. For example:
        sudo mount /dev/sdXX /mnt/mydrive/boot
      • Mount the proc filesystem:
        sudo mount -t proc none /mnt/mydrive/proc
      • Mount your /dev folder:
        sudo mount -o bind /dev /mnt/mydrive/dev
      • Mount udev's /run folder:
        sudo mount -o bind /run /mnt/mydrive/run
      • Now we're ready to chroot (change root) into our drive!
        sudo chroot /mnt/mydrive /bin/bash
    • Robbie fixes his missing Linux kernel with the following commands:
      apt-get update
      apt-cache search linux-image
      apt-get install linux-image-3.2.0-4-686-pae
    • Booting from our fixed Linux installation.
  • {play 35:08}Top Stories from the Category5.TV Newsroom
    • The NSA is harvesting pictures online to build its facial recognition system.
    • The universal translator is real, and coming to Skype.
    • The modern car is a computer on wheels, just waiting to be hacked.
    • Google is building satellites to provide Internet service to the world at large!
  • {play 47:59}Greetings to our live viewers.
  • {play 49:52}The International Space Station now has live HD webcams - see cat5.tv/isscam.
  • {play 52:50}Viewer Comment: I love the show! I'll be watching live on my Roku with the chat room up on my laptop. I watched some older shows. I'm running Manjaro Linux and love trying new tech ideas.
  • {play 54:20}Viewer Comment: I use my Roku 2 connected via composite cables to watch Category5 TV. I started with watching the Roku intro and then Episode 342. I got the flicker that was mentioned, but it wasn't unbearable.
  • {play 56:10}Viewer Comment: I found a Cat5e inline coupler and I use it to disable Internet by unplugging the cable when using my Windows XP virtual machine.

Discussion

Twitter Posts

Login to Category5

Error message here!

Hide Error message here!

Forgot your password?

Register on Category5

Error message here!

Error message here!

Hide Error message here!

Lost your password? Please enter your email address. You will receive a link to create a new password.

Error message here!

Back to log-in

Close