You are not logged in.

#1 2012-11-03 10:36:41

dontbugme
Banned
Registered: 2011-11-04
Posts: 166
Website

Linux on Hard Drive, Boot Partition / Bootloader on USB Flash Drive

I'm trying to install Arch on an encrypted partition on the hard drive (using LVM on LUKS).
Since /boot must be on a separate, unencrypted partition, I would like to store it on a USB flash drive.
My plan was to install GRUB (2) to the flash drive (/dev/sdb) and boot Linux from it's MBR, or if the drive was unplugged simply boot Windows from the hard drive's (/dev/sda) MBR.

I installed GRUB (2) to /dev/sdb, but when I tried to boot from the flash drive I got the following message:

Grub Loading

After a couple of seconds I got an additional message:

Read Error

For testing purposes, I tried to delete the contents of /boot, and I got the same message after booting again from the flash drive.

PARTITIONING DETAILS

/dev/sda (Hard Drive)

MBR: Windows Bootloader
/dev/sda1 - Windows System Partition
/dev/sda2 - Windows Boot Partition
/dev/sda3 - Windows Data Partition
/dev/sda4 - Linux partition

/dev/sdb (USB Flash Drive)

MBR: GRUB
/dev/sdb1 - Linux /boot Partition

GRUB DETAILS

/etc/default/grub

GRUB_CMDLINE_LINUX="cryptdevice=/dev/disk/by-uuid/$SDA4_UUID:vg root=/dev/mapper/vg-root resume=/dev/mapper/vg-swap cryptkey=/dev/disk/by-uuid/$SDB1_UUID:ext2:/key"
..
GRUB_DISABLE_LINUX_UUID=true

Installation command

grub-install --target=i386-pc --recheck /dev/sdb

Thank you for any help!

Offline

#2 2012-11-03 11:36:44

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: Linux on Hard Drive, Boot Partition / Bootloader on USB Flash Drive

My plan was to install GRUB (2) to the flash drive (/dev/sdb) and boot Linux from it's MBR, or if the drive was unplugged simply boot Windows from the hard drive's (/dev/sda) MBR.

- Set the BIOS to your equivalent of "Removable Devices" first, "CD-ROM" second, and "Internal Storage" third.
- Then go to the hard disk priority screen, choose the USB stick as the first one to boot, then the HDD that contains the Windows install.
- Exit with saving the settings (usually F10).

If you have a "boot" folder on the USB stick, perhaps the mount path is something like /boot/boot/grub, which is wrong, AFAIK.

Hmmm... Isn't there a wiki article already, or some other information on the Arch wiki about having the bootloader on a USB stick? Have you looked?


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#3 2012-11-03 11:38:13

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: Linux on Hard Drive, Boot Partition / Bootloader on USB Flash Drive

This is how I have my laptop setup.

I simply created a partition on my SSD.
Used cryptsetup to encrypt it with LUKS/dm-crypt.
Then setup LVM on it.
Used fdisk to create a parition on my USB stick & made it bootable & create an ext4 filesystem

While booted into the Live Arch USB enviorment....
mounted the LVM lvol-root to /mnt
mounted the LVM lvol-home to /mnt/home
mounted the /dev/sdc1 to /mnt/boot
>Note: the Arch USB is /dev/sdb, so the /boot is on device /dev/sdc
>This causes a problem you need to fix

The only thing I changed to /etc/default/grub was this...

/etc/default/grub

GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root:allow-discards"

Now just install the Kernel and GRUB2 as you normaly would, and it will set it up all correctly for you.

except...

Then becuase the Live Arch USB was /dev/sdb and the /boot USB was on /dev/sdc

I had to edit /boot/grub/grub.cfg

Change all the:
set root='hd2,msdos1'

To:
set root='hd1,msdos1'

Also in the search --no-floppy .... line change
--hint-bios=hd2,msdos1 --hint-efi=hd2,msdos1 --hint-baremetal=ahci2,msdos1

To:
--hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1

Also....

You will want to edit /etc/fstab so /boot will not auto-mount. This way you can just pull out the USB stick after it is done booting and your at the login prompt.

/etc/fstab .... Add the "noauto"

/dev/sdb1               /boot           ext4            rw,noauto,noatime,nodiratime,stripe=128,data=ordered 0 2

Now just configure your BIOS to first try to boot from USB, then fall back to your internal HDD.

Last edited by hunterthomson (2012-11-03 11:47:27)


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

Board footer

Powered by FluxBB