0

I have a laptop running Windows (with BitLocker) that I use for work. I'd like to have the option to boot into Ubuntu using an external SSD (connected via USB) without touching anything in my existing Windows configuration. I'm already hearing the suggestion for running a live system and it may yet come to that but after some digging I believed it was possible to to achieve what I wanted. Here's what I did:

  1. Downloaded Ubuntu 20.10 onto a USB thumb drive
  2. Booted using this USB and selected 'install' Plugged in my external SSD, selected that as the target using the whole disk for the install and also as the bootloader install location. The logic was that if I have the SSD plugged in at boot it could boot off that, if not, the untouched Windows bootloader would come into play. I was prepared to press F9 to select an alternate boot device when I wanted to boot Ubuntu
  3. Once the install completed I removed the thumb drive, rebooted, pressed F9 and booted into Ubuntu - so far, so good
  4. Shut down, unplugged the SSD, powered up ... only to be greeted by a grub command prompt. After some digging exit allowed me to boot into Windows
  5. I did the Windows magic to restore the bootloader on my system to original (ie. rebooting with no keys pressed and no external media plugged in plops you straight into Windows).

So in all, mission not accomplished as I'm not able to selectively boot with my built-in SSD untouched. I still have the Ubuntu install on my external SSD that I'd like very much to boot but I'm stuck. Is what I'm trying to do possible? If so, what can I do to either salvage the install on the external SSD by making it bootable, or perform the install in such a way as to leave the integrated (Windows) SSD completely untouched? Is the only reliable way to achieve the latter to physically remove the internal SSD while installing?

I did find this but it's quite a bit over my head at this point as well as this, which is slightly different from my case. My primary objective would be to make the existing install on the external SSD bootable.

deak21
  • 1
  • You have to partition in advance and have an ESP on external drive. Then use one of these alternatives: https://askubuntu.com/questions/1296065/dual-booting-w10-ubuntu-with-2-separate-ssds-in-uefi-mode/1296153#1296153 Ubiquity installer only installs to first ESP. Old bug. Posted work around to manually unmount & mount correct ESP during install #23 & #26 https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1396379 – oldfred Dec 15 '20 at 16:15
  • OK, so there's no way to salvage the existing install on the external SSD, right? I'll give the workaround you posted a stab before disassembling the laptop and removing the internal SSD before installing. – deak21 Dec 15 '20 at 20:17
  • If you have gpt partitioning & and ESP, you just need to reinstall grub. You can add an ESP, I think it just has to be somewhere where UEFI can read it. They suggest first, but have seen it in various places. Only if very large drive may it be an issue to have it far into drive. Shrink some partition and add a FAT32 partition with boot/esp flags if using gparted. – oldfred Dec 15 '20 at 22:20

2 Answers2

0

I recommend you to follow these steps:

Extract your internal hard disk from your work latop. Insert the pendrive with Ubuntu installer and boot with Ubuntu live. Insert your external HD where you want to install Ubuntu. Install Ubuntu on your external HD from the pendrive.

Install boot repair wich contains utils to use UEFI with Ubuntu.

shut down the laptop.

Boot from the external HD

install boot re-pair and execute it, you will find in internet that will help you configure UEFi in Ubuntu.

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair

Now you can shutdown. Connect the internal harddisk and the external harddisk. Boot with F12 to configure uefi to use Windows 10 uefi and efi from the Ubutnu external hardisk too.

Reboot. Boot from Ubuntu external hard disk.

Now beging the magic to use Windows 10 internal installation from Ubuntu using Virtual Box in my case.

What you need to do is what is called "create a raw disk" file that points to the existing harddisk. Later, you create a new Virtual Box virtual machine using that file and you will boot Windows 10 from Ubuntu using an existing installation. Do not forget to click UEFI options on the Virtual Box virtual machine configuration.

Here is an example to create a raw file virtual harddisk from an existing one that Ubuntu maps to /dev/nvme0n1 :

VBoxManage internalcommands createrawvmdk -filename /home/luis/virtualmachines/Windows10/windows10.vmdk -rawdisk /dev/nvme0n1  -relative 

These is just a litlle help. You may find that perhaps you need to use Virtual Box using sudo, but with some lectures and some hours you may find the way to make it work with your normal user.

Luis
  • 1
  • I think this speaks to a different issue. For one, my external SSD is currently not bootable (but I would like to make is to). Secondly, I do not need a virtual Win10 box, my actual physical install is one I'd like to maintain (with no modifications to the boot loader), – deak21 Dec 15 '20 at 11:08
0

I resolved this by following these steps provided by ptetteh227. This is basically what oldfred was suggesting above but I needed the detail. These steps were provided for Ubuntu 15.10 but applying them to Ubuntu 20.10 worked flawlessly. Note that I did not follow the steps for 'Creating a custom boot entry for Ubuntu to point to efi on the external HD' so I can't speak to their continued validity.

Here are the steps if you don't want to follow the link above:

Installing Grub to an external hard drive that has Ubuntu installed

  1. Boot into an Ubuntu live USB and connect the external hard drive.

  2. List partitions of all devices:

     lsblk
    
  3. From the results of lsblk, identify the linux partition and also the efi partition of the external hard drive, i.e. /dev/sdXY1 and /dev/sdXY2 respectively. Replace XY1 and XY2 with your own partition names.

  4. Special mount the linux partition:

      sudo mount /dev/sdXY1 /mnt
    
  5. Mount critical virtual filesystems:

     for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
    
  6. chroot into the Linux partition you mounted:

     sudo chroot /mnt
    

    You are now in the external hard drive's linux filesystem.

  7. Create the directory where grub would install its files:

     mkdir -p /boot/efi
    

    If it already exists, then skip to step 8.

  8. Mount the efi partition from step 3:

     mount /dev/sdXY2 /boot/efi
    
  9. Install grub to the external hard drive:

     grub-install /dev/sdX
    
  10. Update grub:

    update-grub
    
  11. Find the UUID of the efi partition (aka 'vfat') and note it down:

    blkid
    

    or

    ls -l /dev/disk/by-uuid
    
  12. Now we need to tell fstab to mount that efi partition on boot:

    cp /etc/fstab /etc/fstab.bak  
    sudo nano /etc/fstab  
    

    Add the below two lines to fstab replacing xxxx-xxxx with the UUID from step 11:

    #my modified fstab to mount external hard drive's esp  
    UUID=xxxx-xxxx   /boot/efi   vfat   umask=0077   0   1  
    

    Make sure to comment out the fstab entry of the Windows esp so it doesn't conflict.

  13. Exit the chroot:

    exit
    
  14. Reboot the PC:

    sudo reboot
    

At this point when you reboot and choose your external device from the EFI boot manager, it will boot to grub.

To make Ubuntu automatically boot when you insert the external and Windows to automatically boot when the external is not inserted you would have to create a custom boot entry for Ubuntu to point to the efi on the external drive:

Creating a custom boot entry for Ubuntu to point to efi on the external HD

From Windows EasyUEFI can add or remove boot entries.

From Linux efibootmgr can add or remove boot entries.

Alternative #1 – using EasyUEFI

  1. In Windows download EasyUEFI, install it and run.

  2. Choose the EFI options manager

  3. Choose create 'new entry' with + sign

  4. Choose Linux or other OS and give it a name in the description box

  5. Select the FAT32 EFI partition on the external drive that contains the grub bootloader

  6. Choose browse

  7. Navigate to /efi/ubuntu/shimx64.efi or /efi/ubuntu/grubx64

  8. Save

  9. Move it to the top of the boot entries list

  10. Restart

Alternative #2 – using efibootmgr

  1. List boot menu entries:

     efibootmgr
    
  2. Create a boot entry:

     efibootmgr -c [-L label] [-d /dev/sdX]
    

    e.g.: efibootmgr -c -L myubuntu -d /dev/sdX

    This boot entry would automatically be the first entry.

    /dev/sdX is the external hard drive with the grub bootloader.

  3. You can now reboot and without your intervention Ubuntu would automatically boot when external hard drive is plugged in. When the external hard drive is not plugged in, the PC would skip our Ubuntu boot entry to the next entry which is probably Windows Boot Manager.

deak21
  • 1