Prevent Windows boot from breaking Grub on USB

Hello Manjaro Forum,

I was not really sure in which technical category this would belong and as I am a new user I felt it was right to post this here.

I tried to come up with a solution by myself but right now I have no idea left but to post here. I would be really grateful if you could point me to the solution of the problem.

If you need additional infos not listed I’d be happy to provide them, just ask.

Prerequisite

  • USB1: Removable flash drive with Manjaro Installer created with Rufus (working)
  • USB2: Live installation of Manjaro KDE (17.0.1) on removable flash drive (-> see problem)
  • Secure Boot is disabled
  • Boot order is correct

I have a live installation of Manjaro USB flash drive (USB2). I did this using the graphical installer USB1. After installation the system works and rebooting into Grub and Manjaro works fine.

The problem

(At least how i understand it after some research and debugging)

Removing(!) USB2 and booting into Windows (installed on the notebook’s internal drives) breaks something. Afterwards booting into Manjaro is no longer possible. The EFI boot manager no longer lists USB2 as a bootable option.

What I tried to fix the problem

  • Using Grub from USB1 to boot into Manjaro on USB2 works fine but is not really a long term solution.

  • Following the Manjaro Wiki: Restore the GRUB Bootloader: the console output looked fine but the problematic behavior persists.

  • Step 1 from this Forum Post: This fixes the problem. However after booting into Windows grub seems to break again. Note: I didn’t try step 2 & 3 because I’m not sure what step 2 is supposed to do and I don’t want to corrupt my Windows system. (See “Output from efibootmgr” below for more infos)

More infos

Output from "efibootmgr"

After Windows boot & shutdown and booting into Manjaro (USB2) with Grub on (USB1):

# efibootmgr
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 2001,0001,2002,2003
Boot0000* USB HDD: Intenso Rainbow Line
Boot0001* Windows Boot Manager
Boot2001* EFI USB Device
Boot2002* EFI DVD/CDROM
Boot2003* EFI Network

After grub-install

# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Grub
Installing for x86_64-efi platform.
Installation finished. No error reported.
# efibootmgr
BootOrder: 0002,2001,0001,2002,2003
Boot0000* USB HDD: Intenso Rainbow Line
Boot0001* Windows Boot Manager
Boot0002* Grub
Boot2001* EFI USB Device
Boot2002* EFI DVD/CDROM
Boot2003* EFI Network

Intenso Rainbow Line is my installation flash drive (USB 1). You can see that Grub is now detected (on USB2).

My partition layout

Overview:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465,8G  0 disk
├─sda3   8:3    0 442,6G  0 part
└─sda4   8:4    0  23,2G  0 part
sdb      8:16   0 232,9G  0 disk
├─sdb1   8:17   0   450M  0 part
├─sdb2   8:18   0   100M  0 part
├─sdb3   8:19   0    16M  0 part
├─sdb4   8:20   0 208,2G  0 part
└─sdb5   8:21   0   821M  0 part
sdc      8:32   1  57,9G  0 disk
├─sdc1   8:33   1   300M  0 part /boot/efi
├─sdc2   8:34   1  48,8G  0 part /
└─sdc3   8:35   1   8,8G  0 part [SWAP]

Details on sdc (USB2):

Model: SanDisk Ultra Fit (scsi)
Disk /dev/sdc: 62,1GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name  Flags
 1      2098kB  317MB   315MB   fat32                 boot, esp
 2      317MB   52,7GB  52,3GB  ext4
 3      52,7GB  62,1GB  9449MB  linux-swap(v1)

As you can see sdc2 is where Manjaro is installed and sdc1 where Grub is located.

Related Links

Edit 1:

(As requested by @gohlip)

Output from "sudo parted -l"
$ sudo parted -l
Model: ATA ST500LT012-9WS14 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size    File system  Name  Flags
 3      1049kB  475GB  475GB   ntfs               msftdata
 4      475GB   500GB  24,9GB  ntfs               hidden


Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sdb: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size    File system  Name                          Flags
 1      1049kB  473MB  472MB   ntfs         Basic data partition          hidden, diag
 2      473MB   578MB  105MB   fat32        EFI system partition          boot, esp
 3      578MB   595MB  16,8MB               Microsoft reserved partition  msftres
 4      595MB   224GB  224GB   ntfs         Basic data partition          msftdata
 5      224GB   225GB  861MB   ntfs                                       hidden, diag


Model: SanDisk Ultra Fit (scsi)
Disk /dev/sdc: 62,1GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name  Flags
 1      2098kB  317MB   315MB   fat32                 boot, esp
 2      317MB   52,7GB  52,3GB  ext4
 3      52,7GB  62,1GB  9449MB  linux-swap(v1)
  • sda is an internal hard disk drive inside my notebook.
    • sda1 is a data partition for the installed Windows system…
    • sda2 is a hidden recovery partition that can be used with “power button reset” to factory reset the notebook.
  • sdb is an internal solid state drive. This is where Windows is installed and the partitions where created by the Windows installer itself so I’m not really sure what they are in detail (I could dig that up if necessary).
    • sdb1 I have no idea what this is.
    • sdb2 seems to be the EFI partition created by and for Windows
    • sdb3 I think this is the recovery partition that modern Windows creates during its installation.
    • sdb4 is the system partition (C:) of Windows
    • sdb5 Again, no idea.
  • sdc is the removable flash drive (USB2) where Manjaro is installed
    • sdc1 is the EFI partition, mounted at /boot/efi.
    • sdc2 is where Manjaro is installed, mounted at /.
    • sdc3 is obviously swap
Output from "findmnt /boot/efi"
$ findmnt /boot/efi
TARGET    SOURCE    FSTYPE OPTIONS
/boot/efi /dev/sdc1 vfat   rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro

(Note: Line is cut of at the end, I couldn’t get this to output a longer line.)

Output from "cat /etc/fstab"
$ cat /etc/fstab                                                                         
# /etc/fstab: static file system information.                                                          
#                                                                                                      
# Use 'blkid' to print the universally unique identifier for a device; this may                        
# be used with UUID= as a more robust way to name devices that works even if                           
# disks are added and removed. See fstab(5).                                                           
#                                                                                                      
# <file system>                           <mount point>  <type>  <options>  <dump>  <pass>             
UUID=6A38-774F                            /boot/efi      vfat    defaults,noatime 0       2            
UUID=fce6eb09-be03-4dce-b1e3-fe5f73149e65 /              ext4    defaults,noatime 0       1            
UUID=a2387a69-90ef-439a-b55c-e088d200b023 swap           swap    defaults,noatime 0       0
Output from "sudo blkid"
$ sudo blkid
/dev/sda3: LABEL="Data" UUID="2E0266670266344D" TYPE="ntfs" PARTUUID="faefe6f8-49df-4cec-974c-99e600e78a6d"                                                                                                       
/dev/sda4: LABEL="Push Button Reset" UUID="A8AA1DEFAA1DBB30" TYPE="ntfs" PARTUUID="7189faf6-b532-45c5-b1f0-4b56c203e069"                                                                                          
/dev/sdb1: UUID="EA0457330457024D" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="084aac93-3f4a-466d-9a19-0b13f0cceeb0"                                                                                   
/dev/sdb2: UUID="9EC4-C8F3" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="f2110403-a604-4f36-8aa3-01c4cec24531"                                                                                          
/dev/sdb4: LABEL="Windows" UUID="3E3CC73E3CC6F047" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="1bea13af-1de0-4b2e-b318-ab2b1cd445b7"                                                                   
/dev/sdb5: UUID="AE28925528921C81" TYPE="ntfs" PARTUUID="39c304f5-ad9b-4e6f-b676-eef47c118724"                                                                                                                    
/dev/sdc1: UUID="6A38-774F" TYPE="vfat" PARTUUID="51cc0527-a312-45c9-b5b7-34045b84bdee"                                                                                                                           
/dev/sdc2: UUID="fce6eb09-be03-4dce-b1e3-fe5f73149e65" TYPE="ext4" PARTUUID="32253f6b-1d83-48d7-a595-5631c74d63a3"                                                                                                
/dev/sdc3: UUID="a2387a69-90ef-439a-b55c-e088d200b023" TYPE="swap" PARTUUID="5b4c7ed2-8142-4b60-aaf1-ad979f74e9ff"                                                                                                
/dev/sdb3: PARTLABEL="Microsoft reserved partition" PARTUUID="d43dabca-839b-4d4f-9de7-a4a63dd4696c" 
1 Like

Boot up manjaro, provide (do not omit anything or modify output)

sudo parted -l

This time , provide in your own words, what these devices and partitions are.
eg, sda1 is (where’s sda1 and sda2 ??) windows $esp
eg, sda2 is …
sdb2 is data for windows

Also,

findmnt /boot/efi
cat /etc/fstab
sudo blkid

ps: I assume sdc (65 GB (65?) Sandisk Ultra Fit) is an internal drive. If it is not, shout out now. And if it is external, explain if you want to pull it out occasionally (because this is important! - when you pull it out, boot is gone). This description (you used ‘installer’ or ‘live’) does not fit usb1 or usb2 (or is it?)
If sandisk sdc is usb2, then the problem is obvious, but I cannot assume it to be so. Be clear.

I have added the requested information in the top post (Edit 1).

I’m sorry that I wasn’t clear enough and hope that is no longer the case. Even on the danger to repeat myself:

No, sdc is and external flash drive (USB2).

Furthermore:

  • Yes I want to pull it out occasionally!
  • I describe USB1 as “installer” because I used Rufus to burn an ISO of Manjaro KDE 17 in DD mode to the USB drive.
  • I use “live” to describe USB2 (where Manjaro is installed) because I couldn’t think of a better short description. If there is one I’d be happy to use it from now on.

Thank your for your quick reply.

Okay. sdc is usb2 then.
Boot to Manjaro

sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=manjaro --recheck --debug --removable

Repeat, make sure “–removable” is in above command.
Repeat, each time you want to boot Manjaro, you must go to boot setup (usually F10, can be F11 or F12), and choose “UEFI:San Disk xxxx” to boot.

ps: some (only a few) uefi firmware is not good, but hope yours is okay.

1 Like

Thank you! That worked like a charm. :smile:

If you or someone else has the time I’d like to ask an additional question: So the flag --removable is necessary to survive booting Windows. Is this Windows specific or would any other OS break this as well? And what exactly is breaking?

Furthermore the weird thing is this installation flag gives an additional entry inside the bootloader named after the USB stick. This entry persists even after booting Windows. However the bootloader-id manjaro disappears after the first Windows boot. I’d really like to know what is going on here…


Edit:

I tried looking up some information on the flag --removable but the manual doesn’t provide an explanation for what is going on.

Welcome. good to hear.

The ‘–removable’ has nothing to do with windows.

Yes I want to pull it out occasionally!

That’s the …uhm… only matter.

https://www.gnu.org/software/grub/manual/html_node/Installing-GRUB-using-grub_002dinstall.html

For removable installs you have to use --removable and specify both --boot-directory and --efi-directory:
# grub-install --efi-directory=/mnt/usb --boot-directory=/mnt/usb/boot --removable

That’s because you haven’t pulled out the stick yet and booted (to other OS).

That’s coincidental. That’s because you have pulled out the stick and booted to Windows. :slight_smile:

Cheers.

Okay, I’ll just accept it as a requirement for installs on a removable USB flash drive. Now I’ll only have to figure out how to get suspension and hibernation working. :slight_smile:

And thanks again for your quick help.

1 Like

In this context, I’d like to ask an additional question.

Is it possible to use hibernate and / or sleep with this setup. I tried both some times and got problems with the file system when leaving hibernation and issues with login when waking up from sleep. Is it worth it to investigate the bugs or is it very unlikely for hibernation / sleep to work from a live usb flash drive?

I would think that hibernate/sleep would be a separate matter and would not be in any way connected with this ‘setup’. That is of course the external disk is not disconnected anytime during hibernate/sleep.

You may want to start a new topic for your hibernate/sleep problem.
Good luck.

[edit] - @cuAtom
Check that you have resume=UUID=xxxxxxxxxxxx in your grub linux line,
swap in your fstab and ‘resume’ in your HOOKS line in mkinitcpio.conf.
If you edit to add these in, redo your ‘update-grub’ and/or ‘mkinitcpio -P’.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by Bytemark