LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 02-24-2019, 04:15 PM   #1
piobair
Member
 
Registered: Aug 2013
Distribution: Debian, Ubuntu
Posts: 176

Rep: Reputation: Disabled
deleted grub


I had Stretch loaded on an AT-nano; did
Quote:
apt-get update
apt-get upgrade
apt-get dist-upgrade
then I edited /etc/apt/sources.list to replace stretch with buster.
Quote:
apt-get update
apt-get dist-upgrade
That ended up erasing grub.

I made a brand new live Buster DVD.
Ideally, I would boot up the live DVD and log into the hard disk root, since the only thing wrong with that system is a missing grub. Then I wouldn't have to worry about missing firmware to access the Internet.
Downloading the Debian package "grub-installer" onto a thumb drive and then dpkg that into the live-DVD requires 9 depends.

Isn't there a simple way to boot into a system with a missing grub?
 
Old 02-24-2019, 04:53 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,689

Rep: Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795
Amazing things, search engines - this came up as first hit.
The reference you need is chroot - which is required for both EFI and classic BIOS systems. Can be done from standard install media.
 
2 members found this post helpful.
Old 02-24-2019, 05:44 PM   #3
piobair
Member
 
Registered: Aug 2013
Distribution: Debian, Ubuntu
Posts: 176

Original Poster
Rep: Reputation: Disabled
Yeah, I found that. Problem is that it installs off of the Internet, and I don't remember what firmware I used to allow that. I didn't back up the entire system. Just the user data files.

Quote:
Originally Posted by syg00 View Post
Amazing things, search engines - this came up as first hit.
The reference you need is chroot - which is required for both EFI and classic BIOS systems. Can be done from standard install media.
 
Old 02-24-2019, 05:51 PM   #4
hemlocktree
Member
 
Registered: Aug 2018
Location: Northern Exposure
Distribution: 3 Bodhi 5's & 1 debian 9.8 LXDE
Posts: 552

Rep: Reputation: 235Reputation: 235Reputation: 235
thanks syg - useful link
 
Old 02-24-2019, 07:21 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,689

Rep: Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795Reputation: 2795
You don't need to download anything. You have UEFI firmware - which is good, leave it that way.
From that link I posted, click on the chroot link - it'll take you to a Ubuntu page. They usually have well written articles, and something like this is generic, so applies to Debian as well.
First, from the Debian page you'll need to do this
Code:
mount /dev/sdb1 /boot/efi
Note that is /dev/sdb1 as it shows in your pastebin output. Where-ever that VFAT partition shows up use that - could be /dev/sda1 depending on boot, but unlikely.
Now follow the "via chroot" section of the Ubuntu page (skip mdadm, LVM, bcache, /dev/md0 and /dev/md1 references). For step 7 use
Code:
sudo mount /dev/sdb4 /mnt
(same comment applies).
After the chroot, go back to the Debian page and follow their install steps. Note again
Code:
grub-install /dev/sdb
Looks complicated, but is pretty straight-forward.
 
Old 02-24-2019, 08:25 PM   #6
piobair
Member
 
Registered: Aug 2013
Distribution: Debian, Ubuntu
Posts: 176

Original Poster
Rep: Reputation: Disabled
I am hung up on the "grub-install" command. The Wiki has me apt-get install that package.

Quote:
Originally Posted by syg00 View Post
You don't need to download anything. You have UEFI firmware - which is good, leave it that way.
From that link I posted, click on the chroot link - it'll take you to a Ubuntu page. They usually have well written articles, and something like this is generic, so applies to Debian as well.
First, from the Debian page you'll need to do this
Code:
mount /dev/sdb1 /boot/efi
Note that is /dev/sdb1 as it shows in your pastebin output. Where-ever that VFAT partition shows up use that - could be /dev/sda1 depending on boot, but unlikely.
Now follow the "via chroot" section of the Ubuntu page (skip mdadm, LVM, bcache, /dev/md0 and /dev/md1 references). For step 7 use
Code:
sudo mount /dev/sdb4 /mnt
(same comment applies).
After the chroot, go back to the Debian page and follow their install steps. Note again
Code:
grub-install /dev/sdb
Looks complicated, but is pretty straight-forward.
 
Old 02-24-2019, 09:04 PM   #7
1nuxg33k
Member
 
Registered: Feb 2019
Location: PNW
Distribution: Debian, CentOS, OpenSuse, Mint, LMDE
Posts: 74

Rep: Reputation: 30
Wait how did apt-get update wipe grub?

Last edited by 1nuxg33k; 02-24-2019 at 09:11 PM.
 
Old 02-24-2019, 09:18 PM   #8
piobair
Member
 
Registered: Aug 2013
Distribution: Debian, Ubuntu
Posts: 176

Original Poster
Rep: Reputation: Disabled
Buster replaces grub with UEFI, which fixes a security hole. apt-get asked me where to put the new grub, and gave me options of sda or sda1. And then it wouldn't accept either one.

Quote:
Originally Posted by 1nuxg33k View Post
Wait how did apt-get update wipe grub?
 
Old 02-24-2019, 09:24 PM   #9
1nuxg33k
Member
 
Registered: Feb 2019
Location: PNW
Distribution: Debian, CentOS, OpenSuse, Mint, LMDE
Posts: 74

Rep: Reputation: 30
ooh okay. Short of doing it from a live cd I think is the only way. Or maybe https://www.supergrubdisk.org/ but I don't know how well or if that works.
 
Old 02-24-2019, 11:20 PM   #10
Brains
Member
 
Registered: Apr 2009
Distribution: Debian testing
Posts: 971

Rep: Reputation: 259Reputation: 259Reputation: 259
If this is a UEFI installation, I would download Ubuntu or Mint which both have great support for many wifi devices, assuming I have internet.
I would find the disk layout with command: fdisk -l, using the example in the code box below, I would then run the commands in the second code box below. In the 1st code box, my Debian partition is the last one.
Code:
Device             Start       End   Sectors  Size Type
/dev/nvme0n1p1      2048    616447    614400  300M EFI System
/dev/nvme0n1p2    616448    878591    262144  128M Microsoft reserved
/dev/nvme0n1p3    878800 416176127 415297328  198G Microsoft basic data
/dev/nvme0n1p4 416178176 418197503   2019328  986M Windows recovery environment
/dev/nvme0n1p5 418197504 500117503  81920000 39.1G Microsoft basic data
Code:
sudo mount /dev/nvme0n1p5 /mnt
sudo mount /dev/nvme0n1p1 /mnt/boot/efi
sudo mount --bind /dev /mnt/dev 
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo mount -o bind /run /mnt/run
sudo chroot /mnt
grub-install /dev/nvme0n1p5
exit
sudo umount /mnt/run
sudo umount /mnt/sys
sudo umount /mnt/proc
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt/boot/efi
sudo umount /mnt
First I mounted my Debian root partition to the /mnt of the live CD
Then I mounted the EFI partition to the Debian partition's /boot/efi which is /mnt/boot/efi, because Debian's partition is mounted at /mnt
syg00 suggested ----> mount /dev/sdb1 /boot/efi, which would mount the EFI partition to the Live CD's /boot directory, not Debian's
The "sudo mount -o bind /run /mnt/run" command gives internet access in the chroot environment
The grub-install command should automatically retrieve packages from repositories, install them and add necessary boot files in the EFI partition.
 
1 members found this post helpful.
Old 02-25-2019, 12:17 AM   #11
Brains
Member
 
Registered: Apr 2009
Distribution: Debian testing
Posts: 971

Rep: Reputation: 259Reputation: 259Reputation: 259
BTW: The "grub-installer" package does not exist in Buster.

Another way if you don't have internet:
From live CD or Debian install CD, do all the mounts in my example above, the mounting of /run not necessary, chroot into it and issue the grub-install command, it should try getting the packages and produce an error along with a failed hit to the repositories, those failed hits will also tell you which packages it went looking for including the version number. Go to a Debian mirror pool or Debian package search site and download those exact packages from another computer onto a USB key, plug the key in when in the chroot and mount it manually somewhere, copy all the packages to /var/cache/apt/archives of the non-booting Debian partition and proceed to install grub.

EDIT: You don't need to be in the chroot to copy the packages over, you can do it before.

Last edited by Brains; 02-25-2019 at 12:38 AM.
 
Old 02-25-2019, 06:52 AM   #12
piobair
Member
 
Registered: Aug 2013
Distribution: Debian, Ubuntu
Posts: 176

Original Poster
Rep: Reputation: Disabled
grub-installer_1.162_amd64.udeb
I said upthread that it has 9 dependencies. Which means that if I would need to install them manually to the live DVD.
It would be easier to install Internet support and then directly install the grub-installer.

And switching to Mint or Ubuntu is not an acceptable answer.

Quote:
Originally Posted by Brains View Post
BTW: The "grub-installer" package does not exist in Buster.

Another way if you don't have internet:
From live CD or Debian install CD, do all the mounts in my example above, the mounting of /run not necessary, chroot into it and issue the grub-install command, it should try getting the packages and produce an error along with a failed hit to the repositories, those failed hits will also tell you which packages it went looking for including the version number. Go to a Debian mirror pool or Debian package search site and download those exact packages from another computer onto a USB key, plug the key in when in the chroot and mount it manually somewhere, copy all the packages to /var/cache/apt/archives of the non-booting Debian partition and proceed to install grub.

EDIT: You don't need to be in the chroot to copy the packages over, you can do it before.
 
Old 02-25-2019, 10:15 AM   #13
Brains
Member
 
Registered: Apr 2009
Distribution: Debian testing
Posts: 971

Rep: Reputation: 259Reputation: 259Reputation: 259
Quote:
Originally Posted by piobair View Post
grub-installer_1.162_amd64.udeb
Warning: This package is intended for the use in building debian-installer images only. Do not install it on a normal Debian system.
Are you trying to get your computer to boot or are you a Debian developer in the wrong forum?
 
Old 02-25-2019, 04:35 PM   #14
piobair
Member
 
Registered: Aug 2013
Distribution: Debian, Ubuntu
Posts: 176

Original Poster
Rep: Reputation: Disabled
I missed that warning.
I have wiped the HD and loaded Buster ab initio. Then copied my backup files.
All of that took less time than I spent trying to fix the missing grub.
Marking this as "solved".

Quote:
Originally Posted by Brains View Post
Warning: This package is intended for the use in building debian-installer images only. Do not install it on a normal Debian system.
Are you trying to get your computer to boot or are you a Debian developer in the wrong forum?
 
Old 02-25-2019, 06:01 PM   #15
Brains
Member
 
Registered: Apr 2009
Distribution: Debian testing
Posts: 971

Rep: Reputation: 259Reputation: 259Reputation: 259
Quote:
Originally Posted by piobair View Post
I have wiped the HD and loaded Buster ab initio.
I was gonna re-post and suggest to do that since you had an install DVD on hand, but for some reason alot of folks seem to prefer the long route. So... decided to let you decide. Chances are you now have a much faster, clean Buster compared to an old OS dist-upgraded with excessive bloat.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Infinite Grub Loop: GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB... beeblequix MEPIS 2 11-02-2013 10:56 PM
Partitioned deleted by linux deleted ata.rehman Linux - General 3 04-16-2010 09:56 PM
Booting my new ubuntu install = "GRUB GRUB GRUB GRUB GRUB" etc. dissolved soul Ubuntu 2 01-13-2007 12:55 PM
Kmail crashes when deleted mail is deleted dufferin Slackware 0 03-21-2005 03:23 PM
deleted linux partition adn the boot loader was deleted also,now i have only gnu grub boris199 Linux - Laptop and Netbook 2 01-29-2005 04:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 02:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration