How to Reinstall GRUB | Repair Boot on Linux

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today I'll be showing you how to reinstall grub and repair boot on Linux now a few years ago I made a video showing you how to reinstall grub on Ubuntu using a tool called boot repair however that process only works on Ubuntu and Ubuntu based distributions the process that I'm going to be showing you today will one work on any grub based Linux distribution which is pretty much every Linux distribution at this point and doesn't involve the use of any third party tools so I'm just going to be interfacing directly with the operating system all right so now I'm at my Ubuntu desktop right now this is in a virtual machine by the way and I'm just going to do something to break my grub so let's just say we go do something really dumb like delete our entire SL boot SLG grub folder you don't want to do this obviously well let's just completely kill grub in this virtual machine and then reboot ooh okay so now we've completely killed our grub as you can see we got this grub rescue so that means that there's a lot of stuff missing from our grub and no amount of things we do in here will do much of anything and by the way if you get a screen where it just says grub and not grub rescue then that means that there's only minor damage to your grub like for example you're missing your config file in which case you can just skip the timestamp that I'll have in the description but what we're going to have to do is boot into our Linux install media all right so now I'm in my Ubuntu install media first thing I'm going to do from here is do a pseudo Fisk DL and find our Dev SDA this is our main drive it could be Dev nvme if you have an mvme drive but this is where we'll find our partitions so now we've got a bios SP partition we don't need to worry about that NE fi system partition and this is our main partition our Linux file system this will most likely be our biggest one so now what we got to do is first of all Mount our root Linux partition which in my case is Dev sda3 so pseudo Mount SL Dev SL sda3 SL MNT I'm mounting it to SL MNT because that's the convention and then if you have an EFI system partition then you have to mount that in my case it's slev SL sda2 but for you it'll probably be SDA 1 and then Mount that to SL mn/ Boot slfi and if you have a separate boot partition that will have to be mounted to SL mn/ Boot and by the way you can use a graphical application like gnome diss to find these device labels however in this video I'm going to be working entirely from the command line because I want this to be Universal for any grub based Linux distribution but anyway now that we've got these partitions mounted now what we've got to do is do a sudo grub-install D- root directory equals SL MNT and we got to specify our device which is /dev/sda yeah now make sure you do not put any numbers after this because we're doing this to the device not the partition so pseudo grub-install D- root directory equals SL MNT /dev SDA in my case if you have an mvme drive it might be something like slev nvme just make sure you're doing it to the dis not to a partition and then hit enter there you go installation finished no error reported so now we can reboot okay so now we've got this screen where it just says grub at the prompt here that means that now we've fixed our grub to the point where our system is bootable even though it's not 100% fixed so now you've got to do a few things here so first of all we're going to do an LS just to figure out our drives so now you've got these devices here here this is our device these are partitions so now we got to figure out what what our root partition is because my root partition is slev sda3 I'm almost positive that my root partition is going to be hd0 gpt3 so let's test this by doing an LS hd0 GPT 3 and the brackets do matter here and then slash and then there you go this looks like our root partition and if you have a separate boot partition then you need to use your boot partition instead of your root partition but anyway I'm going to set root equals hd0 gpt3 now if we we do an LS slash yep that's now our root partition so now what we're going to do is Linux SL boot slvm Linz and then tab to CR our files in my case it is SL boot slvm Linux depending on your distribution it could be VM lz- Linux or you might even need to specify a current version but in my case SL boot slvm Linz is fine and now we need to specify our root Partition by typing root equals and then our root partition in my case /dev sda3 and then enter and now we going to do init Rd SL boot SL init Rd and then tab to look at our files in my case it's init Rd . IMG so it actually just autocom completed the right one/ boot initrd.img so let's go use that all right and now we can just Boot and by the way if you have full disk encryption set up then your root partition might be something like /dev slash mapper slash VG kbuntu Das root all right now we're back in our Ubuntu desktop now important thing to know this did not fix our grub this is only a temporary fix in order to make this permanent what we've got to do is open up a terminal and do a pseudo update-grub to remake our grub configuration file all right there you you go now our grub is repaired and this is also where it'll detect other operating systems if you for example have this installed on a dual boot with Windows then it'll detect that assuming you have the OS prober package and it's active which in You buun Tube by default it is and by the way if you're on Arch Linux then instead of pseudo update-grub you would do pseudo grub DMK config - o SL MNT SL boot slash grub slash grub.cfg right from the arch ISO and by the way if after booting with your newly reinstalled grub you get into emergency mode what this could be is that your uuid for your EFI system partition is changed to fix this we're going to boot back into our installation media all right now what we're going to do is lsblk d o uid and that'll print The UU IDs of our partitions going in order so this is SDA 1 and sda2 for me your EFI system partition will probably be the first one it looks similar to this so now what we're going to do is copy that uu ID if you're not sure you can do a pseudo f dis- l and figure out that yep sda1 is our EFI system partition so again we're GNA copy that uu ID number and then what we're going to do is Mount our Linux file system so pseudo mount in my case it's Dev SDA 2/ MNT and we don't need to worry about mounting the EFI system partition but now what we're going to do is it do pseudo Nano slash MNT SLC slf tab to get into our F tab file and then we're going to find The UU ID for our boot EFI partition which is down here we're going to get rid of that uu ID and then paste in our new U ID and then press contrl X to saveing can close the file and then we can reboot into our system Again by the way you can do this directly from the emergency mode prompt I prefer to use alive ISO because that provides the advantage of being able to copy and paste The UU ID and as you can see we are booted into our system and that's it for this video be sure to give it a like if you liked it dislike if disliked it comment share subscribe all that good stuff and see you next time
Info
Channel: Drew Howden Tech
Views: 14,222
Rating: undefined out of 5
Keywords: Linux, Boot Repair, GRUB
Id: ZhxBJ3yh2OY
Channel Id: undefined
Length: 11min 35sec (695 seconds)
Published: Sun Jan 28 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.