Portable install on external SSD with (or without) UEFI - Possible?

Ask for help with issues regarding the Installations of the Debian O/S.
Post Reply
Message
Author
mabian
Posts: 6
Joined: 2024-08-17 13:36
Has thanked: 2 times

Portable install on external SSD with (or without) UEFI - Possible?

#1 Post by mabian »

Hello,

please be kind, getting back to Linux after a while, and it's not smooth sailing at all - really disappointed so far.

My target: installing Debian 12 on an external SSD so that can be used on any computer I connect the SSD to.
I'm literally fighting since two days already, without not much result so far.

My HP Pavilion has a UEFI compatible boot loader with Windows 10.
I managed to install Debian on the SSD, I have an ESP partition, a swap and a / partition on the SSD.
I want Windows to be automatically loaded when the SSD is not connected, and Linux otherwise (or, be able to choose in this case).

Any change I try with efibootmgr to amend items even in the internal drive ESP bootloader is lost after reboot.

The BIOS "sees" only boot items in the internal HD, and any attempt to tell it to boot from the external SSD results in a screen with "This is not a bootable disk".

If I direct the BIOS to use a specific EFI File, like /EFI/Debian/grubx64.efi in the external SSD then Debian boots, but I really wouldn't want to do enter BIOS every time I want to use Debian.

So, two problems:

1) I cannot seem to change the internal HD EFI settings to add an item for Debian on the external HD
2) I cannot seem to make the BIOS boot from the SSD like it was a Live CD.

The second point would be perfect for me, but can it be done? Is it possible to use the Debian installer to achieve on an SSD a setup similar to a Live CD so it works automagically whenever the drive is connected - and there's no need for any UEFI-related dramas?

Thanks!

- Mario
Last edited by mabian on 2024-08-17 21:50, edited 1 time in total.

Aki
Global Moderator
Global Moderator
Posts: 3698
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 100 times
Been thanked: 486 times

Re: Portable install on external SSD with (or without UEFI) - Possible?

#2 Post by Aki »

Hello,

Yes, it is possible.

Note that not all of your computer's USB ports may be enabled to boot an external disk. You may need to experiment a little.

Can you please tell us exactly what model of HP you have?
So, two problems:
1) I cannot seem to change the internal HD EFI settings to add an item for Debian on the external HD
2) I cannot seem to make the BIOS boot from the SSD like it was a Live CD
If you have installed Debian on the external disk with a GPT partition scheme, you can only boot it in UEFI mode.

On the contrary, if you have installed Debian on the external disk with a MBR partition scheme, you can only boot in "legacy mode".

Then you need to set up your computer's BIOS; check your user manual:
  • to set the order of the boot disks in the BIOS, if possible
  • to configure the type of boot method: it should be convenient to use the same boot method (legacy / UEFI) when booting multiple operating systems for the same computer
If I remember correctly, you have to press a key (maybe F9 on an HP notebook, I don't remember exactly - see user's manual) after powering up, when the screen is black (but before booting any OS), which allows you to manually select the boot device to choose from (the external UEFI USB HDD or SDD).

Finally, the grub boot loader can be also installed as a "fallback bootloader" (useful with weak EFI implementation); you can see here: Hope this helps.
--
[1] Debian Wiki - Grub EFI Reinstall
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

juribel
Posts: 50
Joined: 2024-03-03 06:30
Location: Rheinland, Germany
Been thanked: 12 times

Re: Portable install on external SSD with (or without UEFI) - Possible?

#3 Post by juribel »

Another alternative I managed to install is the follwing:

1. Prepare your external drive with Ventoy, making it persistent, use only as much space as you need, and leave as much as you can free.
2. Cope a Debian live ISO to the Ventoy partition. Being persistent, you can install or delete software and adjust your settings.
3. The space that you left free can be used for an ext4 partition. I use it for my daily backup with rsync.

The advantage is: I can boot from the SSD on any computer, have my installed software and settings, and have access to my backup data. It is not for doing your daily work, rather for emergency cases. As it is a live ISO, i can also install the operating system from it on any computer.

On another external SSD, I installed Debian and can boot from it. Both installations work well. The boot sequence of the installed version is easier to handle, but it is not possible to install the OS from it.

mabian
Posts: 6
Joined: 2024-08-17 13:36
Has thanked: 2 times

Re: Portable install on external SSD with (or without UEFI) - Possible?

#4 Post by mabian »

Hello, and thanks for replying so quick.

About the exact laptop model, will check, I'm not seeing an easy way to tell and there's no label on the PC - I got it on 2016.

I just tried a brand new external USB 3.0 HD (not SSD), formatted completely from scratch using GPT scheme; an UEFI boot item was added to the internal hard drive ESP and I can boot from there (yes I know about the boot options and bios, ESC + F9 / F10).
But still, even from this new installation, I cannot delete/edit with efibootmgr any items from the ESP boot options - they seem changed or deleted when I try efibootmgr -v, but they come back untouched after reboot.

The SSD I was trying to use had MBR partition scheme and I cannot wipe it because I have data on some partitions.
Enabling BIOS Legacy mode I can see an option to boot from the SSD but then I get the "Disk is not bootable" error.

Same exact thing with the new HD: if I enable legacy mode I get the option to boot from the HD but then the "Disk is not bootable" error shows.
Secure boot is disabled, to rule it out from the equation, same for Windows Fast Boot which I disabled after reading around.

How can Live CDs boot this easy and doing the same for a regular install is such a nightmare? :(

Any further suggestion is truly appreciated.
Thanks,
Mario

mabian
Posts: 6
Joined: 2024-08-17 13:36
Has thanked: 2 times

Re: Portable install on external SSD with (or without UEFI) - Possible?

#5 Post by mabian »

juribel wrote: 2024-08-17 15:41 Another alternative I managed to install is the follwing:

1. Prepare your external drive with Ventoy, making it persistent, use only as much space as you need, and leave as much as you can free.
2. Cope a Debian live ISO to the Ventoy partition. Being persistent, you can install or delete software and adjust your settings.
3. The space that you left free can be used for an ext4 partition. I use it for my daily backup with rsync.

The advantage is: I can boot from the SSD on any computer, have my installed software and settings, and have access to my backup data. It is not for doing your daily work, rather for emergency cases. As it is a live ISO, i can also install the operating system from it on any computer.

On another external SSD, I installed Debian and can boot from it. Both installations work well. The boot sequence of the installed version is easier to handle, but it is not possible to install the OS from it.
Hi juribel, I see but I'm afraid that with such an "expanded" Live CD I won't achieve the performance and flexibility of a full installation.
About your external SSD install, can you boot from it to any computer you connect the SSD? Because maybe I'm there - almost - but it will only boot in the PC where I made the install it because it touched the internal boot loader. And I would like to avoid it on any PC I would need to use with it...

In short, I see that UEFI is difficult because the name of the devices could change on any PC and most BIOSes don't seem to be able to refer to an ESP different than the internal one.
But so far I haven't found a way to have the boot work without touching the internal UEFI and/or without enabling legacy BIOS boot (CSM or whatever is called...).

- Mario

Aki
Global Moderator
Global Moderator
Posts: 3698
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 100 times
Been thanked: 486 times

Re: Portable install on external SSD with (or without UEFI) - Possible?

#6 Post by Aki »

Hello,
mabian wrote: 2024-08-17 15:51 About the exact laptop model, will check, I'm not seeing an easy way to tell and there's no label on the PC - I got it on 2016.
You can use the command (the inxi package must be installed):

Code: Select all

inxi -Ma
mabian wrote: 2024-08-17 15:51 I just tried a brand new external USB 3.0 HD (not SSD), formatted completely from scratch using GPT scheme; an UEFI boot item was added to the internal hard drive ESP and I can boot from there (yes I know about the boot options and bios, ESC + F9 / F10).
But still, even from this new installation, I cannot delete/edit with efibootmgr any items from the ESP boot options - they seem changed or deleted when I try efibootmgr -v, but they come back untouched after reboot.
The UEFI variables are entries in the computer's NVRAM (non-volatile RAM), and they are not in the ESP disc partition.
mabian wrote: 2024-08-17 15:51 The SSD I was trying to use had MBR partition scheme and I cannot wipe it because I have data on some partitions.
Enabling BIOS Legacy mode I can see an option to boot from the SSD but then I get the "Disk is not bootable" error.
Probably the SDD with the MBR partition layout is missing the boot loader. Remember that you cannot boot it on a UEFI configured machine.
mabian wrote: 2024-08-17 15:51 How can Live CDs boot this easy and doing the same for a regular install is such a nightmare? :(
This is because Live ISOs use a so-called "ISO-HYBRID" partition format and, unlike HDD/SDD, they cannot be changed.

Hope this helps.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

mabian
Posts: 6
Joined: 2024-08-17 13:36
Has thanked: 2 times

Re: Portable install on external SSD with (or without UEFI) - Possible?

#7 Post by mabian »

Hello,

thanks I installed inxi and this is the output:

Machine:
Type: Laptop System: HP product: HP Pavilion Notebook
v: Type1ProductConfigId serial: 5CD6165GKQ Chassis: type: 10 serial: N/A
Mobo: HP model: 80A4 v: 91.1C serial: <omitted> UEFI: Insyde v: F.77
date: 12/18/2015

Anyway, in the meanwhile I progressed big time.

1) I found that the /etc/fstab in the SSD drive was mounting partitions from the internal HD - probably a glitch or something in the standard grub installer - I corrected the file contents so that the mounts of / and /boot/efi refer to the UUIDs of the proper partitions in the external drive

2) Looking at various source I tried putting together this script using various info that seemed to work in similar cases

sudo mount /dev/sdb4 /mnt # root partition of external drive
sudo mount /dev/sdb2 /mnt/boot/efi # ESP partition of external drive
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install --no-nvram --force-extra-removable /dev/sdb # external drive
update-grub

And after that I incredibly have not one but two drives, one GPT and one the infamous MBR, both recognized as UEFI by the BIOS and they boot, even if both connected (one wins of course).

If none are connected the internal drive boots Windows.

I also have legacy boot disabled and secure boot enabled, so the most future proof configuration.
I still have to check what happens on a different PC but so far so (very!!!) good.

Thank you guys for your help, will report about further testing.

- Mario

juribel
Posts: 50
Joined: 2024-03-03 06:30
Location: Rheinland, Germany
Been thanked: 12 times

Re: Portable install on external SSD with (or without) UEFI - Possible?

#8 Post by juribel »

As far as I have seen, the purpose of a Debian Live ISO is exactly to be startable on every computer (so far) that Debian can be installed on. And to me, it seems to be fully functional. Apart from the speed loss caused by the USB connection, why should it be less performant than a "real" installation? Using persistence, you can make your own changes and configurations on it, and they will be saved.

Just one disadvantage comes to my mind in case you use Ventoy: Even if you leave free space, installing Ventoy kills all partitions on this drive, and you will have to create new ones. So all data that were on the drive will be lost. You will have to restore them from your backup.

The result will be: a small boot partition (Ventoy doesn't care for BIOS or UEFI, both work), the Ventoy partition (exfat file system) and the space you left free which you can format into an ext4 filesystem or something else.

It is all described in the Ventoy README file.

As I mentioned before, this is very usable but most probably not the optimal way to do your daily work.

mabian
Posts: 6
Joined: 2024-08-17 13:36
Has thanked: 2 times

Re: Portable install on external SSD with (or without) UEFI - Possible?

#9 Post by mabian »

The speed loss for the USB connection is a major factor for me, together with not having all the flexibility of tweaking the file system (partitioning, mounting and so on).

And, I can think of fitting my daily work environment in a 500GB/1TB drive, not in a 64/128GB one :)

Thanks,
Mario

DebianFox
Posts: 149
Joined: 2024-05-05 14:11
Has thanked: 20 times
Been thanked: 8 times

Re: Portable install on external SSD with (or without) UEFI - Possible?

#10 Post by DebianFox »

If you do plan to use an external USB connected SSD for linux then can i suggest that you install grub only on the external USB SSD drive? And not on your internal Windows 10 drive. Then if you change your boot options to boot from an external drive first, your requirement of booting directly into Windows 10 if external USB SSD drive is not attached will be fulfilled. Do not touch or install anything on the Windows 10 drive.

Just my 2 cents.

mabian
Posts: 6
Joined: 2024-08-17 13:36
Has thanked: 2 times

Re: Portable install on external SSD with (or without) UEFI - Possible?

#11 Post by mabian »

Hi @DebianFox, sure but the main problem in my case was that it's not easy to set grub to install only on the removable drive unless the internal drive can be physically disconnected, so the external is the only one and in this situation it's easy.

This is what I couldn't figure out how to do, but in the end, I managed to do it.
Now that I have the full removable drive, how can I remove grub from the internal drive, once it's been installed there?

Thanks,
Mario

Aki
Global Moderator
Global Moderator
Posts: 3698
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 100 times
Been thanked: 486 times

Re: Portable install on external SSD with (or without) UEFI - Possible?

#12 Post by Aki »

Hello,
mabian wrote: 2024-08-20 06:58 Now that I have the full removable drive, how can I remove grub from the internal drive, once it's been installed there?
As far I know, there's not a single command to do it.

The instructions here seem correct to me (first answer), but I never tested it: Use it at your own risk (or simulate it first, e.g. in a virtual machine).

Hope this helps. Please let me know.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Post Reply