LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-03-2020, 12:22 PM   #1
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,437

Rep: Reputation: 110Reputation: 110
How do I update grub in a secondary disk?


Let's say I have everything running hunky-dory on /dev/sda.

Then Grub gets damaged.

I boot up from another disk and connect the damaged one over USB. What used to be sda is now sdb.

I run:

# update-grub2
# grub-install /dev/sdb

The problem is, the two disks have differences between them and grub is going to reinstall itself on sdb with information scanned from sda. When I put the old disk back in its place and boot from it, Grub is going to complain that it couldn't find the root partition etc.

How do I tell update-grub2 ("a stub for grub-mkconfig" according to the man page) to scan sdb so that grub-install /dev/sdb updates sdb accordingly?

One way to do that is booting up from a Grub rescue CD, but that is very inconvenient when I am preparing a secondary disk to be ready to boot in case something evil happens to the primary one. I want to do the job right from the same command line, without having to reboot from a CD.

How do I do that?

TIA
 
Old 09-03-2020, 02:21 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,796

Rep: Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952
Basically, use chroot when running from the second disk
Code:
 
Mount the old root partition to /somewhere 

Bind mount the virtual files system i.e /proc, /dev , /dev/pts /sys to /somewhere/...

chroot to /somewhere

grub-install

update-grub2

exit (to switch back to the second disk)

unmount everything above.
There are howtos that go into more detail.

Last edited by michaelk; 09-03-2020 at 02:24 PM.
 
  


Reply



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
(Solved) Bumblebee "Cannot access Secondary GPU, secondary X is not active" Norgi Slackware 0 03-23-2013 11:45 PM
Booting grub from secondary hard disk ? Fezar Linux - Newbie 15 08-30-2007 05:02 AM
Booting my new ubuntu install = "GRUB GRUB GRUB GRUB GRUB" etc. dissolved soul Ubuntu 2 01-13-2007 12:55 PM
GRUB GRUB GRUB GRUB "Whats Going on?" Gaweph Linux - Newbie 6 03-26-2004 10:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:23 AM.

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
Open Source Consulting | Domain Registration