Installing to USB messed up grub - SOLVED

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
Post Reply
dontworryaboutit
Level 1
Level 1
Posts: 5
Joined: Fri Nov 09, 2018 7:56 pm

Installing to USB messed up grub - SOLVED

Post by dontworryaboutit » Fri Nov 09, 2018 8:06 pm

I currently have Mint19 installed on my laptop. I was playing around with installing Mint19 onto a bootable USB flash drive. Since then, if I have the USB inserted, my system boots directly to that USB and it works. However, I cannot boot to the Mint installation that is on my hard drive anymore. If I remove the USB and reboot, I end up at a "grub>" prompt instead of the usual grub screen with my Mint installation listed as I used to get. It's as if grub doesn't recognize my original installation any longer. Any help would be appreciated!

Here is the procedure that I followed to create the USB installation:
* Make live DVD/USB to use for running the installer
* Have another USB to install to.

-- delete anything on it currently
-- use GParted from the live DVD/USB to make and format partitions for install
-- make one for Root partition, Ext4 formatting
-- make a small Swap partition (500MB - 1GB) if you don't have a lot of RAM on computer

* Run the installer program and choose "Something else" install method
* On partitioning page, select Root partition you made on the USB stick:

-- click "Change" button
-- Use as = Ext4 file system
-- Mount point = /
-- Size = leave as you already made it
-- Format box = doesn't matter if you check it or not (you already formatted it in GParted)
-- Swap partition: no need to do anything with it -- it will be automatically used.
-- Device for boot loader installation = /dev/sdX (substitute correct letter for the USB stick in place of "X"), not /dev/sda (which will be the default value shown).
-- Click "Finish" installation.
Last edited by dontworryaboutit on Sun Nov 11, 2018 1:12 pm, edited 1 time in total.

User avatar
pbear
Level 5
Level 5
Posts: 596
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear » Sat Nov 10, 2018 12:38 am

Hey dontworry, welcome to the Forum.

I'm pretty sure the problem is that you installed to USB on a UEFI machine, which unfortunately triggered a bug in the installer. Not something you could be expected to know, but whoever wrote the instructions you followed should have. Of which speaking, please give us a link to the source. I've researched this extensively and don't recall having seen those instructions before.

The good news is that this should be fixable, though I wouldn't call it simple. Actually, you need two fixes, one for the laptop and the other for the USB drive. Before going any further, though, I'd like to confirm my hunch that yours is a UEFI system. Boot the laptop (with USB inserted, of course). Open Terminal. Copy the following command and paste into Terminal:

Code: Select all

[ -d /sys/firmware/efi ] && echo "Currently in UEFI mode" || echo "Currently in Legacy mode"
In case you don't know, paste in Terminal is Ctrl-Shift-V, rather than the usual Ctrl-v. Or use the Edit menu, where Paste is one of the options on the drop-down. Anyhoo, run the command and report which "Currently in ... " gets echoed back.
Time flies like an arrow. Fruit flies like a banana.
Running Mate 18.3 64 bit (by upgrade from 18.1-2)

dontworryaboutit
Level 1
Level 1
Posts: 5
Joined: Fri Nov 09, 2018 7:56 pm

Re: Installing to USB messed up grub

Post by dontworryaboutit » Sat Nov 10, 2018 9:05 am

Currently in UEFI mode.

While reading about this process, I sort of suspected this was related to the problem, but when making the USB drive, nothing jumped out at me as suspicious. I was researching persistence because it would be somewhat useful to me to have a persistent USB drive when I came across this post:

viewtopic.php?t=186040

Just for reference, i've used Linux for awhile and would say that my knowledge level is a little above novice but nowhere near expert. And obviously not enough to be clear about what is wrong! Also, I have the USB drive (which i'm using right now) as well as a separate Live USB at my disposal if that matters. My system only runs Linux Mint, I do not dual boot any other OS. I do not have any life critical stuff on my hard drive but it'd be nice to get my system back without wiping it out because it would save me the hassle and time of setting up a completely new install so I appreciate any help you can offer.

User avatar
pbear
Level 5
Level 5
Posts: 596
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear » Sat Nov 10, 2018 12:52 pm

As I said, this should be fixable. BTW, in gold_finger's defense, UEFI was still relatively new four years ago, the installer bug had only just been discovered and wasn't widely known. And I do agree full install is preferable to persistence in most cases.

Anyhoo, I'm pretty sure all you need to do to fix the laptop is reinstall Grub. I've never had to do it, but senior user Pjotr has a detailed guide on his Linux tips website. If you run into trouble, post back. If I can't spot the solution, hopefully someone else can.

As for the USB drive, you're going to have to do that over. I know two methods which get around the bug. See here for links, plus a discussion of pros and cons of each. Since then, I've written up Option 2 myself here. I'd like to emphasize there's no point doing full install to a 2.0 flash drive (you probably have a 3.0, but I want to make sure). I've done Option 1 in LM19, so that still works, and can't think of any reason Option 2 wouldn't.

Note: When fabien85 and I wrote our posts, the prevailing version was Mint 18.x, which requires a swap partition. LM19 does not (by default, uses a swap file instead), though swap partition is still supported optionally. Mainly useful if you want to be able to hibernate. I wouldn't bother with a swap partition on a flash drive unless is was at least 64 GB, but that's your choice. If not using, adjust partition scheme accordingly. Rest of the instructions stay the same.
Time flies like an arrow. Fruit flies like a banana.
Running Mate 18.3 64 bit (by upgrade from 18.1-2)

fabien85
Level 6
Level 6
Posts: 1391
Joined: Tue Mar 11, 2014 4:30 pm

Re: Installing to USB messed up grub

Post by fabien85 » Sat Nov 10, 2018 2:00 pm

+! on everything pbear said.

I just want to add that regarding the repair of the USB, it also depends on what kind of system(s) you want to boot it. The tutos by pbear and I will make something bootable on hopefully any x86 64-bit computer, both in Legacy and UEFI mode. They are a bit complicated though.
If you just intend to boot on UEFI systems, you could take the simpler route of just reinstalling grub at the fallback bootloader location. The simplest way to do this is to boot the USB, find out the drive name that is assigned to it (e.g. with blkid or gparted ; in the following I'm going to assume you find /dev/sdb), then open a terminal and run

Code: Select all

sudo grub-install --removable --no-nvram /dev/sdb

dontworryaboutit
Level 1
Level 1
Posts: 5
Joined: Fri Nov 09, 2018 7:56 pm

Re: Installing to USB messed up grub

Post by dontworryaboutit » Sat Nov 10, 2018 2:06 pm

Well, when I try to mount the EFI partition, I get the following error:

Code: Select all

mint@mint:~$ sudo mount /dev/sda1 /mnt/boot/efi
mount: /mnt/boot/efi: mount point does not exist.
Also, my main partition is encrypted. So I can't mount it. However, there is also an EXT2 partition. Would this be considered the root partition then? I've attached a pic of GParted for reference. Thanks for the help so far.
Attachments
Screenshot from 2018-11-10 18-00-34.png

User avatar
pbear
Level 5
Level 5
Posts: 596
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear » Sun Nov 11, 2018 1:07 am

Alas, I'm not able to help much with the Grub reinstall problem. As mentioned, it's not something I've had to do. Also, my main Mint install is on a BIOS rather than UEFI machine, so I'm not able to test Pjotr's instructions to see how they're supposed to work. Moreover, I don't use system encryption, so while I'm sure there's a way to mount the encrypted partition in a live session, I have no idea what that may be. The one thing I can say with confidence is that sda2 is not your root partition. It's much too small, for one thing, and would be noted as "/" in GParted. Rather, root is inside sda3.

Don't give up yet. Someone with relevant experience may click into the thread. If not, as you mentioned earlier, reinstall is the ultimate fallback.
Time flies like an arrow. Fruit flies like a banana.
Running Mate 18.3 64 bit (by upgrade from 18.1-2)

User avatar
vansloneker
Level 4
Level 4
Posts: 279
Joined: Sat Mar 17, 2018 6:10 am

Re: Installing to USB messed up grub

Post by vansloneker » Sun Nov 11, 2018 4:56 am

sda2 is the unencrypted pre-boot partition. It is the part where the unlock password is entered. From there the operating system on or inside sda3 is booted, if the correct key is entered.
Normally, if you would mount sda3 from e.g. the live Linux a password is asked and you could access it.

I am also unexperienced with UEFI as I don't want to use it.
First things I would do is install Grub Customizer to see if that can point to the correct partition.
Next I would try Boot Repair Disk.

But you may best begin with the page suggested by pbear in his good replies (+1!)
Unless stated otherwise Mint 18.3-64 XFCE

fabien85
Level 6
Level 6
Posts: 1391
Joined: Tue Mar 11, 2014 4:30 pm

Re: Installing to USB messed up grub

Post by fabien85 » Sun Nov 11, 2018 8:01 am

sda2 is the /boot partition containing the kernel and the grub.cfg file that defines the grub menu.

I dont know how to reinstall manually grub for an encrypted system. However, your grub.cfg should still be present, so you can tell grub to use it (instead of unsuccessfully searching for the one on the USB), boot to your Linux system and reinstall from there.
Steps :
- unplug the USB, boot, you should get to the grub> prompt
- we are now going to follow troubleshooting advices from https://help.ubuntu.com/community/Grub2 ... #grub.3E-1
- your /boot partition should normally be (hd0,gpt2) in grub language, we are going to check that. Do

Code: Select all

ls (hd0,gpt2)
you should see several files (including the kernel vmlinuz-somenumber-generic), a directory called efi and one called grub.
If it's not the case, try other drive and partition numbers (ie hd0,gpt1 or gpt3, or hd1...) until you find the good partition, then adapt instructions below with the good numbers
- now let's check that the file defining the grub menu is still there

Code: Select all

ls (hd0,gpt2)/grub
the output should contain several files and directories, and most importantly one file called grub.cfg
If that's the case, then run

Code: Select all

configfile (hd0,gpt2)/grub/grub.cfg
You should get to the usual grub menu where you can boot Mint.
- boot Mint, login, open a terminal and reinstall grub:

Code: Select all

apt install --reinstall grub-efi-amd64
- shutdown and reboot and you should now be able to boot normally to your installed Mint

dontworryaboutit
Level 1
Level 1
Posts: 5
Joined: Fri Nov 09, 2018 7:56 pm

Re: Installing to USB messed up grub

Post by dontworryaboutit » Sun Nov 11, 2018 12:01 pm

Success! You guys/gals are damn good. The grub cfg was indeed on sda2. Very interesting to find out what sda2 was actually for.

Fabian, thank you so much for walkthrough.
pbear, thank you for the info on the USB drives.

I owe both of you!

User avatar
pbear
Level 5
Level 5
Posts: 596
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear » Sun Nov 11, 2018 12:56 pm

Kudos for patience and perseverance. Please go back to the first post in the thread, hit edit (the little pencil icon) and add "Solved" to the thread title.

As regards the USB project, I'll mention two additional thoughts. First, be aware the installer doesn't support system encryption for USB installs. You can encrypt the home folder, but that entails a significant performance hit. Or you can use file container encryption, e.g., Veracrypt, which is what I use for all my systems. With the latter, you don't try to keep everything in the encrypted container, just the files which are actually sensitive. In fact, I keep mine on a separate USB drive (backed up to a similarly encrypted USB drive) which I can move freely among all my systems. Works for me. YMMV.

Second, I didn't mention originally because it's advanced and complicated, but maybe you're up to it. fabien85 did a tutorial on how to create a sort of swiss army knife USB drive. So that's three USB installation options in all. Which to use depends on what you're trying to achieve.
Time flies like an arrow. Fruit flies like a banana.
Running Mate 18.3 64 bit (by upgrade from 18.1-2)

User avatar
vansloneker
Level 4
Level 4
Posts: 279
Joined: Sat Mar 17, 2018 6:10 am

Re: Installing to USB messed up grub

Post by vansloneker » Sun Nov 11, 2018 1:19 pm

pbear wrote:
Sun Nov 11, 2018 12:56 pm
First, be aware the installer doesn't support system encryption for USB installs.
Well I have successfully installed an encrypted Mint on an USB stick. It is treated just like any other hard disk.
Unless stated otherwise Mint 18.3-64 XFCE

dontworryaboutit
Level 1
Level 1
Posts: 5
Joined: Fri Nov 09, 2018 7:56 pm

Re: Installing to USB messed up grub - SOLVED

Post by dontworryaboutit » Sun Nov 11, 2018 1:20 pm

I don't really need encryption on the USB. I travel occasionally with a work laptop and it would be useful to have a persistent Linux install with which I can do some minor work of my own. The work laptop is not UEFI (so I'll definitely be reading your links) and I don't want to dual boot or install any other software on it (such as VMware). A persistent Linux drive seemed like a good way to occasionally have access to my own "separate" machine without actually carrying another machine around.

Basically I'm just tinkering around right now. Nothing monumentally important.

User avatar
pbear
Level 5
Level 5
Posts: 596
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear » Mon Nov 12, 2018 12:26 am

vansloneker wrote:
Sun Nov 11, 2018 1:19 pm
pbear wrote:
Sun Nov 11, 2018 12:56 pm
First, be aware the installer doesn't support system encryption for USB installs.
Well I have successfully installed an encrypted Mint on an USB stick. It is treated just like any other hard disk.
Bear in mind I said the installer doesn't support, not that it can't be done. As dontworry isn't interested, I don't want to hijack his thread, but would appreciate if you could give me a link or two to the method you use. The issue comes up from time to time. Thanks.
Time flies like an arrow. Fruit flies like a banana.
Running Mate 18.3 64 bit (by upgrade from 18.1-2)

User avatar
vansloneker
Level 4
Level 4
Posts: 279
Joined: Sat Mar 17, 2018 6:10 am

Re: Installing to USB messed up grub - SOLVED

Post by vansloneker » Mon Nov 12, 2018 3:23 am

I would sent this to you in PM but you have that disabled.
Anyway I just installed it on a laptop with no HD but with the 16GB USB in and as little RAM as possible so that as little as possible space would be assigned to the swap partition. Just followed the normal encrypted procedure from the Mint 18.3 XFCE32 installer. I did 32bit for reasons of compatibility.
I boots well but once up and running it does not always respond immediately. Apparently though that seem to happen more often with Kingston Data Travelers.
It's not something you would want to run all day but a tool that comes in handy for all kinds of things that involves accessing another system.
Unless stated otherwise Mint 18.3-64 XFCE

Post Reply

Return to “Installation & Boot”