Installing to USB messed up grub - SOLVED

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
dontworryaboutit

Installing to USB messed up grub - SOLVED

Post by dontworryaboutit »

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 LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
pbear
Level 16
Level 16
Posts: 6569
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear »

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.
dontworryaboutit

Re: Installing to USB messed up grub

Post by dontworryaboutit »

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.
pbear
Level 16
Level 16
Posts: 6569
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear »

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.
fabien85
Level 7
Level 7
Posts: 1877
Joined: Tue Mar 11, 2014 4:30 pm

Re: Installing to USB messed up grub

Post by fabien85 »

+! 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

Re: Installing to USB messed up grub

Post by dontworryaboutit »

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.
pbear
Level 16
Level 16
Posts: 6569
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear »

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.
vansloneker

Re: Installing to USB messed up grub

Post by vansloneker »

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!)
fabien85
Level 7
Level 7
Posts: 1877
Joined: Tue Mar 11, 2014 4:30 pm

Re: Installing to USB messed up grub

Post by fabien85 »

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

Re: Installing to USB messed up grub

Post by dontworryaboutit »

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!
pbear
Level 16
Level 16
Posts: 6569
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear »

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.
vansloneker

Re: Installing to USB messed up grub

Post by vansloneker »

pbear wrote: Sun Nov 11, 2018 12:56 pmFirst, 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.
dontworryaboutit

Re: Installing to USB messed up grub - SOLVED

Post by dontworryaboutit »

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.
pbear
Level 16
Level 16
Posts: 6569
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Installing to USB messed up grub

Post by pbear »

vansloneker wrote: Sun Nov 11, 2018 1:19 pm
pbear wrote: Sun Nov 11, 2018 12:56 pmFirst, 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.
vansloneker

Re: Installing to USB messed up grub - SOLVED

Post by vansloneker »

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.
green_dragon34
Level 1
Level 1
Posts: 14
Joined: Tue Jul 10, 2018 9:43 am

Re: Installing to USB messed up grub - SOLVED

Post by green_dragon34 »

From Windows 10 Pro I installed Live Mint Linux 19 Tara to a Flash drive using "Universal USB Installer." I guess there are several tools to do install the ISO to a Flash drive from Windows.

I took the hard drive out of an older Dell Laptop with a 4th generation I3 processor/2 GB RAM. I booted the Mint Linux, with a second blank USB Flash drive. I ran the installer, which could not get confused with a partition on the hard drive. Let it do the install to the second flash drive, did the basic updates.

What I have not yet determined is how to get the laptop to boot from a external portable hard drive on a USB port. That is which piece of software does that. I think the OP might have that same question. (Not trying to hijack the thread)
vansloneker

Re: Installing to USB messed up grub - SOLVED

Post by vansloneker »

green_dragon34 wrote: Fri Nov 23, 2018 8:35 amI guess there are several tools to do install the ISO to a Flash drive from Windows.
Yes there are. But if it works you did the right thing.
green_dragon34 wrote: Fri Nov 23, 2018 8:35 amWhat I have not yet determined is how to get the laptop to boot from a external portable hard drive on a USB port.
Basically, you go into the bios and set the boot preference to 1st boot from USB. However, many biosses ignore this and still boot from the internal HD. But, most of the computers and laptops have a boot override. By pressing a particular key during boot, a menu shows up which enables you to select from which medium to boot. The key is different for different computers. It could as well as Escape, F2, F8, F9, F10 or F12, or any other key. Often during the first stage of boot it is displayed on the screen as a message like "press xx for BBS popup" or "press xx for boot menu". Also you should be able to find it in the manual of your computer, or with help form Google.
Trongbach

Re: Installing to USB messed up grub

Post by Trongbach »

fabien85 wrote: 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
You're awesome!!! You save my time, I must register new account just for say thank you!
Btw, in my case, old config file in location: (hdo,gpt3)/boot/grub/grub.conf.
Locked

Return to “Installation & Boot”