Booting from a USB drive

When my desktop computer failed, I could still fall back to using my laptop.  But I wanted to get back up and running with a desktop, which I find more congenial to use.  I could just use my UEFI box.  However, my old desktop was also being used to support some network file sharing (NFS on opensuse and samba for Windows).  I could set that up on the new box, but it would take a while.

The simplest strategy seemed to be to take the disk from the failed box, install in a hard drive enclosure, and access that as a USB disk.  I already had a suitable hard drive enclosure.  Removing the disk from the failed computer, and installing in the enclosure was simple enough.

Adding to the boot menu

I already had opensuse on the UEFI box.  I booted that.  Then I plugged in the disk enclosure to a USB port to check that everything looked okay.  Since I was using an encrypted LVM, I manually ran “cryptsetup” to handle the crypto, and then I used the LVM command “vgchange” to make the LVM volumes accessible.

The next step was to run “grub2-mkconfig” to rebuild the grub boot menu.  That added a line to boot the system on the USB disk.  Since disk partitions for that system are identified by their ID, I was not expecting problems from the fact that the disk was now “/dev/sdc” rather than “/dev/sda”.

Attempting to boot

With the USB still connected, I now tried to reboot.  The usual boot menu came up, and it now included an entry to boot my old system.  I selected that entry, and hit “enter”.

The result was a continuous stream of messages that the root file system was not found.  And there was no prompt for the encryption key that would have been needed to access the root file system.  Clearly, something had gone wrong.

Perhaps the problem was UEFI related.  The system that I was trying to boot had been setup for MBR booting.  It wasn’t clear why that would matter.  But, just in case, I disabled secure-boot on the box.  I then rebooted, and hit F12 during boot to get the BIOS boot menu.  I then directly selected the USB drive that I wanted to boot, and I selected it as an MBR boot.

The same stream of messages showed up.  Back to the old drawing board.  The problem that I was having appears to be that the loaded kernel was unable to read USB drives.

I booted to the opensuse system on the main hard drive of that computer.  I then used cryptsetup to decrypt the LVM, and made it accessible with “vgchange”.  I mounted the USB system at “/mnt”.  I then used “chroot” to change into the USB based system, much as described in an earlier post on rescuing.  I then ran “mkinitrd” to rebuild the “initrd” for the USB based system.  I could see from the output, that support for USB devices was now being included in the “initrd”.

Another boot attempt.  And this time it worked.  There was a screen of messages about accessing the root partition.  But, after one screen, I was prompted for the encryption key.  And, thereafter, the boot proceeded normally.  The screen of messages is probably because the USB is slower than a regular drive, so there was a time delay before the crypto was properly setup.

Now in the system, I ran “mkinitrd” once again.  I always prefer that to come from the running system, rather than from a “chroot” environment.

Cold booting a USB

I shut that system down overnight.  And then I tried booting again in the morning.  It would not boot.  The grub2-efi boot manager gave me a message that the kernel was not available.

It probably would have booted if I had disabled secure-boot and tried booting directly from the BIOS boot menu.  The problem seems to be that the BIOS is not initializing the USB devices.  My quick and dirty solution was to first boot the system installed on an internal drive, and then reboot to the USB based system.  That worked fine, with the same screen of messages on availability of the root file system.

Internal mounting

My final step was to take that disk out of the disk enclosure, and mount it internally in the box.  Before doing that, I had to purchase a long-enough SATA cable.  And I had to work out how to securely mount the disk in the only empty bay, which was intended for a DVD drive.

Once mounted internally, it boots up more quickly and without that screen of messages.  It should cold boot without difficulty, though I’m not sure whether I have actually tested that.

Advertisements

Tags: , ,

About Neil Rickert

Mathematician and computer scientist who dabbles in cognitive science.

Trackbacks / Pingbacks

  1. Mixing UEFI and MBR | Thoughts on computing - 2013/08/03

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: