Booting from USB disk

I want to install a minimal version of linux (probably oS 11.4) onto a
partitioned 1TB USB drive to serve as a standalone, bootable restore
mechanism for a couple of machines.

First off, is this feasible?

Second, how do I go about it? I was able to install the system to the drive
but how do I make that drive bootable? So far, I can’t even get it to boot
from the grub menu on the first internal hard drive as the system complains
loudly about not being able to read disk descriptors and such. I tried the
various boot spec (chainloader, menulist, etc) with no luck. Do I need to
disconnect all the internal drives then install as if it were the only hard
drive in the machine with the DVD reader?

I am assuming that I need some sort of bootstrap code in the MBR of the USB
drive to get started but I’m a bit lost here and would appreciate any input,
especially from some one who has tried this, before I spend anymore time on
it.


Will Honea

Each hard drive can have up to four PRIMARY partitions, any of which could be marked active and bootable. No matter what you might hear, only one of the first four primary partitions can be booted from. That means you can boot from Primary partitions 1, 2, 3 or 4 and that is all. In order to boot openSUSE, you must load openSUSE and the grub boot loader into one of the first four partitions. Or, your second choice is to load the grub boot loader into the MBR (Master Boot Record) at the start of the disk. The MBR can be blank, like a new disk, it can contain a Windows partition booting code or generic booting code to boot the active partition 1, 2, 3, or 4. Or, as stated before, it can contain the grub boot loader. Why load grub into the MBR then? You do this so that you can “boot” openSUSE from a logical partition, numbered 5 or higher, which is not normally possible. In order to have more than four partitions, one of them (and only one can be assigned as extended) must be a extended partition. It is called an Extended Primary Partition, a container partition, it can be any one of the first four and it can contain one or more logical partitions within. Anytime you see partition numbers 5, 6 or higher for instance, they can only occur inside of the one and only Extended Primary partition you could have.

What does openSUSE want as far as partitions? It needs at minimum a SWAP partition and a “/” partition where all of your software is loaded. Further, it is recommended you create a separate /home partition, which makes it easier to upgrade or reload openSUSE without losing all of your settings. So, that is three more partitions you must add to what you have now. What must you do to load and boot openSUSE from an external hard drive? Number one, you must be able to select your external hard drive as the boot drive in your BIOS setup. Number two, you need to make sure that the external hard drive, perhaps /dev/sdb, is listed as the first hard drive in your grub device.map file and listed as drive hd0. I always suggest that you do not load grub into the MBR, but rather into the openSUSE “/” root primary partition which means a primary number of 1, 2, 3 or 4. If number one is used, then that will be out. You will mark the openSUSE partition as active for booting and finally you must load generic booting code into the MBR so that it will boot the openSUSE partition. I suggest a partition setup like this:

  1. /dev/sdb, Load MBR with generic booting code
  2. /dev/sdb1, Primary NTFS Partition for Windows
  3. /dev/sdb2, Primary SWAP (4 GB)
  4. /dev/sdb3, Primary EXT4 “/” openSUSE Partition Marked Active for booting (80-120 GB)
  5. /dev/sdb4, Primary EXT4 “/home” Your main home directory (Rest of the disk)

Since I don’t know how much space you want to allocate to openSUSE or what else might be on this hard drive, more info can help provide a better partition setup.

What happens when this external hard drive is not connected? Normally, your BIOS will proceed to the next hard drive in sequence or the next one you have designated to boot from. What happens when you plug in a bootable USB hard drive that has been absent, but was present and booted from at least once? Well this depends really on how the BIOS treats the external device. I have had Dell laptops that do not miss a beat and boot directly from the external hard drive like it has never been gone. I have had Desktops that require you to go back into BIOS setup and reassign the external hard drive as the first boot device again, as if it had never been used. It just depends on how your computer BIOS functions.

Thank You,

jdmcdaniel3 wrote:

> Since I don’t know how much space you want to allocate to openSUSE or
> what else might be on this hard drive, more info can help provide a
> better partition setup.

That part is simple - I set up 2 primaries for / and /home as the first two
partitions on the drive. The rest is - or should be - irrelevant to
booting.

I did manage to get it to boot - the install went nice and clean and wrote
grub to the root partition BUT: the menu.lst file starts with

code:

root(hd0,0)
etc…

Now that is plainly incorrect. If I’m chaining from the first hard drive, it
was already mapped as hd0. Even changing the device map in boot/grub on the
USB drive doesn’t seem to over-ride that initial map so I need to do some
more reading of the grub manual and gives me a hint that various hard drive
configs may give me some real grief.

This blows much of my idea since I wanted to be able to go to any of the
machines, plug in, and restore if needed. That covers the blown disk case
where I lose the entire hard drive. A little experimentation shows that
some of the older machines have a BIOS limitation which has problems booting
from partitioned USB media anyway - they only seem to accept FAT/FAT32 large
floppy devices - and won’t even boot from the flash drive even if the BIOS
supposedly supports that boot mode (my 11.1 live USB flash drive won’t boot
on some). I’ve also found that I need to write grub to the MBR of the USB
drive in order to actually boot from it

For now, I’m back to a Live CD and the associated gyrations. That works but
that nice compact terrabyte drive really tempts me - I could pretty much
back up the whole office and have the whole backup/restore solution in one
neat package.


Will Honea

Now that is plainly incorrect. If I’m chaining from the first hard drive, it
was already mapped as hd0. Even changing the device map in boot/grub on the
USB drive doesn’t seem to over-ride that initial map so I need to do some
more reading of the grub manual and gives me a hint that various hard drive
configs may give me some real grief.

This blows much of my idea since I wanted to be able to go to any of the
machines, plug in, and restore if needed. That covers the blown disk case
where I lose the entire hard drive. A little experimentation shows that
some of the older machines have a BIOS limitation which has problems booting
from partitioned USB media anyway - they only seem to accept FAT/FAT32 large
floppy devices - and won’t even boot from the flash drive even if the BIOS
supposedly supports that boot mode (my 11.1 live USB flash drive won’t boot
on some). I’ve also found that I need to write grub to the MBR of the USB
drive in order to actually boot from it

For now, I’m back to a Live CD and the associated gyrations. That works but
that nice compact terrabyte drive really tempts me - I could pretty much
back up the whole office and have the whole backup/restore solution in one
neat package.

The boot drive is ALWAYS HD0 to Grub. Take a look at my device.map file where I am booting from the second hard drive:

(hd1)    /dev/disk/by-id/ata-Hitachi_HDS721010CLA332_JP9921HD2SSJLH
(hd2)    /dev/disk/by-id/ata-ST31500541AS_5XW14NDQ
(hd0)    /dev/disk/by-id/ata-INTEL_SSDSA2M080G2GC_CVPO037603KN080JGN

Now look again with basic device names:

(hd1)    /dev/sda
(hd2)    /dev/sdc
(hd0)    /dev/sdb

So, when you are booting from a second or third hard drive, based on hardware order (and it matters not if it is internal or external) hd0 will be the boot drive. When doing your install, make sure you are not installing the grub boot loader to the MBR, which can send it to /dev/sda and that you are installing it into Primary Partitions 1, 2, 3, or 4 and normally the one which is the root / for openSUSE, but oddly, it can also be an Extended Primary Partition as well, which just contains Logical Partitions within. The root partition, which contains the grub menu, must be on the same hard drive as the boot loader. Finally, don’t forget you MUST set your BIOS to boot this second external or internal hard drive first. You need to look back on what you did. This really does work and you will not believe how simple it really is, once you get full understanding of the situation.

Thank You,

jdmcdaniel3 wrote:

>
>> Now that is plainly incorrect. If I’m chaining from the first hard
>> drive, it
>> was already mapped as hd0. Even changing the device map in boot/grub on
>> the
>> USB drive doesn’t seem to over-ride that initial map so I need to do
>> some
>> more reading of the grub manual and gives me a hint that various hard
>> drive
>> configs may give me some real grief.
>>
>> This blows much of my idea since I wanted to be able to go to any of
>> the
>> machines, plug in, and restore if needed. That covers the blown disk
>> case
>> where I lose the entire hard drive. A little experimentation shows
>> that
>> some of the older machines have a BIOS limitation which has problems
>> booting
>> from partitioned USB media anyway - they only seem to accept FAT/FAT32
>> large
>> floppy devices - and won’t even boot from the flash drive even if the
>> BIOS
>> supposedly supports that boot mode (my 11.1 live USB flash drive won’t
>> boot
>> on some). I’ve also found that I need to write grub to the MBR of the
>> USB
>> drive in order to actually boot from it
>>
>> For now, I’m back to a Live CD and the associated gyrations. That works
>> but
>> that nice compact terrabyte drive really tempts me - I could pretty
>> much
>> back up the whole office and have the whole backup/restore solution in
>> one
>> neat package.
>> The boot drive is ALWAYS HD0 to Grub. Take a look at my device.map file
> where I am booting from the second hard drive:
>
>
> Code:
> --------------------
> (hd1) /dev/disk/by-id/ata-Hitachi_HDS721010CLA332_JP9921HD2SSJLH
> (hd2) /dev/disk/by-id/ata-ST31500541AS_5XW14NDQ
> (hd0) /dev/disk/by-id/ata-INTEL_SSDSA2M080G2GC_CVPO037603KN080JGN
> --------------------
> Now look again with basic device names:
>
>
> Code:
> --------------------
> (hd1) /dev/sda
> (hd2) /dev/sdc
> (hd0) /dev/sdb
> --------------------
> So, when you are booting from a second or third hard drive, based on
> hardware order (and it matters not if it is internal or external) hd0
> will be the boot drive. When doing your install, make sure you are not
> installing the grub boot loader to the MBR, which can send it to
> /dev/sda and that you are installing it into Primary Partitions 1, 2, 3,
> or 4 and normally the one which is the root / for openSUSE, but oddly,
> it can also be an Extended Primary Partition as well, which just
> contains Logical Partitions within. The root partition, which contains
> the grub menu, must be on the same hard drive as the boot loader.
> Finally, don’t forget you MUST set your BIOS to boot this second
> external or internal hard drive first. You need to look back on what
> you did. This really does work and you will not believe how simple it
> really is, once you get full understanding of the situation.

Should work. I’m going to have to put this off for a couple of weeks - the
wife insists we are going on vacation next week whether I want to or not -
so I won’t have time to deal with the testing until we get back in the
country.

BTW, your explanations on this are excellent. I need to spend some more
time with the grub docs since it can be a bit tricky unless you understand
all the nuances.


Will Honea