I have a huawei laptop (matebook D) it doesn't support selecting external hdd as boot medium (it's really crazy) just from pen-drives. When hdd is connected it won't show in bios menu. Is it possible to add option to boot from external hdd to grub or other software (I don't know any). I mean to do it always regardless of installed system on external hdd. I simply want to point out external hdd as boot drive.
-
This is not related to Ubuntu. It is a BIOS issue. – Pilot6 Sep 30 '20 at 15:17
-
How is system booting UEFI or BIOS? And then is HDD configured for that type of boot. If BIOS, you need boot loader in MBR, if UEFI, you need boot loader files in the ESP - efi system partition. – oldfred Sep 30 '20 at 16:16
-
Have you run sudo update-grub to pick up the OS on the external disk? Grub booting off the first disk should be able to run root on the external -- no boot of external really involved as far as system is concerned. – ubfan1 Sep 30 '20 at 16:19
-
@oldfred My laptop only support EFI – Christopher S Sep 30 '20 at 16:42
-
@ubfan1 of course, added entries appeared in grub – Christopher S Sep 30 '20 at 16:43
1 Answers
You can try to add a menuentry to /etc/grub.d/40_custom
. Keep the header with exec tail ...
, otherwise it won't work.
menuentry "External drive on (hd1) [hd{0,1,2,3} edit if necessary]" {
insmod part_msdos
insmod part_gpt
insmod fat
insmod ext2
set root='(hd1)'
drivemap -s (hd0) ${root}
chainloader +1
}
Then run
sudo update-grub
and when you reboot there should be a menuentry to boot whatever is in a USB port.
Edit 1:
After a dialogue in the comment field, I suggest that you try to boot into your external HDD in BIOS mode. (This means that you need a way to make the computer boot in BIOS mode. either from a temporary menu or via a setting in the UEFI/BIOS system.)
Edit 2:
After more feedback I understand that we must skip the alternative with BIOS boot.
If you have Ubuntu installed in the external drive, and you have another instance of Ubuntu in the internal drive, it should be possible to boot into Ubuntu in the internal drive and run sudo update-grub
, when the external drive is connected, to get a specific menuentry for Ubuntu in the external drive. This is likely to work. The same method should work also for the Ubuntu flavours (Kubuntu, Lubuntu ... Xubuntu), and maybe also for other linux distros.

- 46,324
- 5
- 88
- 152
-
#!/bin/sh exec tail -n +3 $0 menuentry "External drive on (hd1) [hd{0,1,2,3} edit if necessary]" { insmod part_msdos insmod part_gpt insmod fat insmod ext2 set root='(hd1)' drivemap -s (hd0) ${root} chainloader +1 }
This file provides an easy way to add custom menu entries. Simply type the
menu entries you want to add after this comment. Be careful not to change
the 'exec tail' line above.
– Christopher S Sep 30 '20 at 15:39 -
-
@ChristopherS, I think so, but the formatting is lost in comments, so it is hard to see. Please edit your original question and indent each line [of this code snippet] 4 spaces to render the text as 'code' and it will be easier to read. – sudodus Sep 30 '20 at 15:41
-
@ChristopherS, I wrote 'You can try' because there is no guarantee, that it will work. But the same method works with some old HP computers, that won't boot directly from USB with grub, so it is worth trying. – sudodus Sep 30 '20 at 16:03
-
Please forgive me my atrocious formatting. I got error. can't find command 'drivemap' invalid EFI file path – Christopher S Sep 30 '20 at 16:06
-
@ChristopherS, What is the internal operating system: distro, version? And what is the version of grub (that is supposed to use '/etc/grub.d/40_custom' ?
drivemap
works for me with the current versions of Ubuntu (as internal systems). I have tested both with grub 2.02 (of Ubuntu 2.02) and grub 2.04 (of Ubuntu 20.04). But I have only used it in BIOS mode. Maybe it does not work in UEFI mode. – sudodus Sep 30 '20 at 18:17 -
@ChristopherS, I did a quick test in UEFI mode, and it seems to lack
drivemap
. So if you want to use the method I suggest, you must boot in BIOS mode (alias CSM alias legacy mode). I don't know if that is a working option for you. But it is also possible that there is another problem: Your external HDD might have a boot system for BIOS mode, but not for UEFI mode. In that case, there will be no boot option in the temporary menu for it in UEFI mode. – sudodus Sep 30 '20 at 18:45 -
Unfortunately Huawei Matebook D only supports EFI no bios emulation. I am using Ubuntu 20.04 and windows 10 . This laptop has the most primitive EFI settings I've ever seen. I can connect pendrive boot from it, install ubuntu or other os on external hdd, install os there but I can't book because Laptop doesn't boot from External HDD. I don't know if there are HDDs cases on the market which are visible to the laptops as pendrives. I guess the solution would be to add external OS to grub but I wanted to have universal solution and this way overcome limitations of this laptop. – Christopher S Oct 01 '20 at 09:20
-
@ChristopherS, I see, and I think you are on the right track. If you have Ubuntu installed in the external drive, and you have another instance of Ubuntu in the internal drive, it should be possible to boot into Ubuntu in the internal drive and run
sudo update-grub
to get a specific menuentry for Ubuntu in the external drive, that is likely to work. The same method should work also for the Ubuntu flavours (Kubuntu, Lubuntu ... Xubuntu), and maybe also for other linux distros. – sudodus Oct 01 '20 at 10:53