You are not logged in.

#1 2012-05-14 04:01:32

Ichimonji10
Member
Registered: 2010-11-07
Posts: 32
Website

Zombie laptop lives on after internal HDD interface dies.

Hey all. This post isn't a question or request for help -- I just wanted to let you all know about some computer issues that cropped up recently, and how I resolved them.

I've been running Arch on my laptop for a while now, say at least a year. However, HDD access recently became iffy, and would often fail. After running some tests with smartctl (e.g. smartctl -t long /dev/sda && smartctl -a /dev/sda) and e2fsck (e.g. e2fsck /dev/sda2 while unmounted), I determined that the hard drive and its filesystems were healthy. I concluded that some other laptop component, such as the motherboard, was at fault. That left me with two options: either buy a new laptop (ha!), or make the existing setup work a bit longer. My solution was to remove my internal HDD and connect it to my laptop via a SATA-to-USB adapter.

The setup looks a bit like this:
HDD --> adapter --> laptop

The setup did not work as-is. The initial ramdisk which was present on the HDD (/boot/initramfs-linux.img) would load modules for SATA controllers, but not for USB controllers. As a result, initramfs could not find /dev/sda2, on which my kernel resided. I found one relevant post through the forums, but that post assumed that you're creating a fresh install on the external HDD, not resurrecting an existing install. At this point, I did lots of reading (see these links), trial and error, and banged my head against the wall. The solution was to rebuild initramfs with support for USB controllers. Here's how I did it (thanks, again, to the posts I linked to above -- great helps).

1) Obtain a bootable live disk. I grabbed the most recent netinstall image from the downloads page and threw it onto a USB drive.
2) Boot from the live disk and mount the external HDD. This one was easy:

# mkdir /media/arch-part
# mount /dev/sdb2 /media/arch-part

3) Edit the menu.lst used by grub, and add "rootdelay=10" (or some other value) to the "kernel" line. This will cause grub to wait up to 10 seconds before expecting the kernel to be available -- I believe accessing the HDD over usb induces delays.

# vim /media/arch-part/boot/grub/menu.lst
# tail -n 9 /media/arch-part/boot/grub/menu.lst
title  Arch Linux [/boot/vmlinuz-linux]
root   (hd0,1)
kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/96a0... ro rootdelay=10
initrd /boot/initramfs-linux.img

title  Arch Linux Fallback
root   (hd0,1)
kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/96a0... ro rootdelay=10
initrd /boot/initramfs-linux-fallback.img

4) Edit mkinitcpio.conf, and add "usb" to the "HOOKS" line.

# vim /etc/mkinitcpio.conf
$ grep ^HOOKS= /etc/mkinitcpio.conf
HOOKS="base udev usb autodetect filesystems"

5) Create a chroot environment. (see note at end of post on why this is necessary)

# mount -o bind /dev /mnt/chroot/dev
# chroot /media/arch-part /bin/bash -i
# mount -t proc none /proc

6) Backup the old initramfs, and generate a new one. Optionally, specify a kernel version (you can find a listing of kernel versions in /lib/modules).

# cp /boot/initramfs-linux.img{,.old}
# mkinitcpio -g /boot/initramfs-linux.img -k 3.3.4-2-ARCH

7) Shut down, remove the live disk, ensure the HDD is plugged in, and power up. Success!

Why did I need to create a chroot environment? Well, the version of mkinitcpio included with the most recent Arch Linux live disk is out of date. For example, the old version will look for files in /lib/initcpio/busybox, whereas a current Arch system will store the same files in /usr/lib/initcpio/busybox. Furthermore, some distributions (like the Linux Mint live USB I tried using) don't even have the tool available on their live disks. By creating a chroot environment, you're able to use the perfectly up-to-date version of mkinitcpio already installed on the HDD. Mounting proc is necessary for mkinitcpio to work correctly. And I have no idea if mounting dev is necessary -- the "slackworld" article I linked to suggested doing so, and I went along.

Last edited by Ichimonji10 (2013-02-12 01:11:53)

Offline

#2 2012-05-15 20:04:19

baronmax
Member
From: Missouri, USA
Registered: 2012-04-22
Posts: 37

Re: Zombie laptop lives on after internal HDD interface dies.

Very clever.  wink

I'd have been too bummed out about losing my laptop to come up with such a solution.  I doubt I'd have thought of this in a million years.  I'd probably have resorted to selling my body (ha! as if anyone would pay for THAT) to save up for a new laptop, or worse. 

I do appreciate you sharing your story though, I hope I never have that issue, but if I do, it'll be nice to know how to work around it.


Intel 980x| 24GB RAM| Arch + Cinnamon/i3
Intel 2600K| 8GB RAM| Arch + Awesome/XFCE
Intel Q740| 6GB RAM| Arch + XFCE/Cinnamon
AMD Phenom x6 1090T| Ubuntu/Winblowz (gaming)

Offline

#3 2012-05-15 20:33:15

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Zombie laptop lives on after internal HDD interface dies.

3) Edit the menu.lst used by grub, and add "readonly=8" (or some other value) to the "kernel" line.

I don't get this step.  Did you mean to say "add rootdelay=#"?

Last edited by alphaniner (2012-05-15 20:34:09)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2012-05-16 17:22:46

Ichimonji10
Member
Registered: 2010-11-07
Posts: 32
Website

Re: Zombie laptop lives on after internal HDD interface dies.

alphaniner wrote:

3) Edit the menu.lst used by grub, and add "readonly=8" (or some other value) to the "kernel" line.

I don't get this step.  Did you mean to say "add rootdelay=#"?

Yep, my mistake! I'll correct the original.

EDIT:
@baronmax Thanks! I'd never touched mkinitcpio before, so it took me a while to figure everything out. As the saying goes, "necessity is the mother of invention". And when you have $400 to your name...

Last edited by Ichimonji10 (2012-05-16 17:47:57)

Offline

#5 2012-05-16 18:26:19

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Zombie laptop lives on after internal HDD interface dies.

In that case, while I applaud your achievement (heck, I remember how proud I was when I first learned how to use fdisk tongue), I think you made it harder than it needed to be.  Still, you undoubtably learned more than you would have had you blindly followed a guide, so huzzah for that.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#6 2012-05-16 19:27:31

Ichimonji10
Member
Registered: 2010-11-07
Posts: 32
Website

Re: Zombie laptop lives on after internal HDD interface dies.

Oh, buying a new laptop would have definitely been my preferred solution! But the money I have left is already spoken for (food, gas, emergencies, etc), and this solution cost $0. Thus the PITA solution.

Offline

Board footer

Powered by FluxBB