3

So here's what I'm trying to do:

I've left some free space on the main ssd of my laptop so I want to install a second distro there in an encrypted LVM and put the /boot partition on a USB stick so that the stick is needed to boot the system, otherwise it boots into the main Debian system on the ssd without any indication that there is another OS on this computer...

I'm using Parrot OS which is based on Debian so has a very similar installer. I've created a new partition with encrypted LVM in the free space on the ssd for / and swap in logical volumes and created a 1GB partition on a USB stick for /boot and set the mount points accordingly in the partitioner. And I did set the bootable flag on /boot. During install, I'm asked if I want to install GRUB to the MBR of the first disk. I choose 'no' and get a list of devices to choose manually where to put it. I choose the USB drive with /boot on it...

Trying to boot the system after install, I open the boot menu in the firmware and choose the USB drive. From here, apparently, no bootable device is found so it boots the main Debian system instead...

I've read of systems being setup this way in the past and thought it wouldn't be problematic but something isn't working and the computer will not boot the new OS. Did I miss something or is it not possible to boot a system configured this way?

Thanks in advance.

2

First off, MBR (Legacy) is becoming less common these days and is gradually being replaced with EFI. As your question doesn't explicitly say you know you are using legacy boot and not EFI, I'll suggest you check which you are actually using. To do this boot into your working (main) Debian system and look for:

ls /sys/firmware/efi/efivars/

If this exists then you will have booted via EFI. You should also notice you have a directory there /boot/efi/ which is where the EFI partition is mounted.


Setting up a recovery environment.

You have a working environment so to fix your problem you might want to use the working environment to bootstrap into the "broken" one.

You've mentioned you are using encrypted LVM. That makes this a bit more complex. The first thing you would need to do is unlock your encrypted drive with your encryption recovery password:

# Assuming your LVM is /dev/vg/encrypted
# This will create a decrypted block device /dev/mapper/decrypted

cryptsetup open /dev/vg/encrypted decrypted

Then mount your "broken" system to /mnt and chroot into it (assuming your USB boot partition is /dev/sdb1):

mount /dev/mapper/decrypted /mnt
mount /dev/sdb1 /mnt/boot

mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
mount --bind /run /mnt/run

# chroot into the recovery environment
chroot /mnt

This should leave you with a command line inside your "broken" system.

If you are definitely using legacy boot

From inside your recovery system (described above), you need to install the bootloader to the MBR of your USB drive, NOT the /boot/ partition. If your /boot on the USB drive is /dev/sdb1 then you need to install MBR to /dev/sdb NOT /dev/sdb1

grub-install /dev/sdb

For good measure you should also run through and update grub config and initramfs:

update-grub
update-initramfs -uk all

Watch out for any errors here.

If you are really using EFI

Some BIOS firmware will only use one or the other, so if you booted your main system from EFI then you will need to boot your USB from this way too. From inside your recovery environment (described above)...

First ensure you have an EFI partition on your USB drive. If you don't it may be easiest to copy /boot somewhere safe and re-format the USB drive. Use this to interactively start again from scratch on USB /dev/sdb:

cp -r /boot ~/old_boot
umount /boot
cfdisk -z /dev/sdb

Using cfdisk, create a new GPT partition table, create two partitions - one "EFI" one "Linux".

Then format them:

mkfs.fat -F 32 -n EFI /dev/sdb1
mkfs.ext4 -L BOOT /dev/sdb2

Mount and restore /boot

mount /dev/sdb2 /boot
cp -r ~/old_boot/* /boot

Check /etc/fstab (eg cat /etc/fstab), make sure the UUID matches /boot/ and add an entry for /boot/efi if necessary too, you can find the new UUIDs with:

blkid /dev/sdb1 /dev/sdb2

Then finally setup EFI.

mount /dev/sdb1 /boot/efi

# If you've not already done so install grub efi:
apt-get install grub-efi-amd64-bin 

grub-install /dev/sdb
update-grub
update-initramfs -uk all
0

[1] Change the 1st Booting Sequence to USB from BIOS

[2] Use Rufus to make a Booting USB.

To Do so, you need a Windows platform to run Rufus properly. Get your desier Linux Distro ISO then make the Booting USB using rufus.

Hope it will work.

There are many tools are there to make a Booting USB that run on linux. But I couldnt find any of them flawless. So, I trust on Rufus and it never failed me.

  • Thanks for the answer but I'm afraid this isn't what I need. I'm not booting an ISO from this USB stick. The installer ISO is already bootable on another stick. I've done the install and now have a /boot partition on the stick I want the bootloader for the distro to load from.. Also, this computer has a firmware that allows me to press 'esc' as the firmware loads to get a boot menu where I can choose the USB drive from.. No need for a windows machine here... – rijo79 Sep 4 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.