sudo grub-install --root-directory ?

Asked by YannUbuntu

Dear all,

If I boot on a live-CD, then enter in a terminal the following commands:
sudo mount /dev/sda1 /mnt
sudo grub-install --root-directory=/mnt /dev/sda
sudo umount /mnt

..does it install Grub-pc in /dev/sda1 ? even if Grub was already installed in /dev/sda1 ?

Furthermore, are the 3 above commands equivalent to the below ones ?

sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /sys /mnt/sys
sudo mount -t proc /proc /mnt/proc
sudo chroot /mnt
sudo grub-install /dev/sda
exit
sudo umount /mnt/dev /mnt/proc /mnt/sys
sudo umount /mnt

Thanks in advance for your answers.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu grub2 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

It will install it to the MBR of the disk, or /dev/sda. The commands are pretty equivalent. The second one simply mounts the partition then chroots to the installed OS and acts like when the installed OS boots and you open a terminal. This is VERY handy when updates fail and your OS is unusable, you can use a chroot to get a boot then snoop around to see what happened / fix.

Revision history for this message
YannUbuntu (yannubuntu) said :
#2

Thank you!
Remains unanswered this part of my question : "even if Grub was already installed in /dev/sda1 ?"
(if there were already Grub configuration files on sda1, will they be modified ?)

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

No you will simply reinstall the grub loader to the MBR

Can you help with this problem?

Provide an answer of your own, or ask YannUbuntu for more information if necessary.

To post a message you must log in.