zeldor.biz

Linux, programming and more

Copyright © 2025
Log in

Install Grub from chroot

December 21, 2010 by Igor Drobot 16 Comments

The simple way to install grub/ grub2 from any linux live-CD or any other bootable medium.

Step 1: boot from linux live CD/DVD or even USB
Step 2: mount your hdd
Step 3: chroot in the mounted filesystem
Step 3: install grub
Step 4: reboot

1
2
3
4
5
6
7
8
9
fdisk -l
mount /dev/sda1 /mnt/
mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev
mount -t sysfs sys /mnt/sys
chroot /mnt/ /bin/bash
update-grub
/usr/sbin/grub-install --recheck --no-floppy /dev/sda
sync & reboot

fdisk -l mount /dev/sda1 /mnt/ mount -t proc none /mnt/proc mount -o bind /dev /mnt/dev mount -t sysfs sys /mnt/sys chroot /mnt/ /bin/bash update-grub /usr/sbin/grub-install --recheck --no-floppy /dev/sda sync & reboot

SUSE Syntax:
update-grub is debian and ubuntu little helper this execute the same as:

1
2
3
grub2-install --recheck --no-floppy /dev/sda
grub2-mkconfig -o /boot/grub2/grub.cfg
mkinitrd

grub2-install --recheck --no-floppy /dev/sda grub2-mkconfig -o /boot/grub2/grub.cfg mkinitrd

Filed Under: Bash, Debian, Ubuntu Tagged With: chroot, Debian, Grub, Grub2, install grub, MBR, openSUSE, Ubuntu

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Comments

  1. Akos says

    November 4, 2021 at 20:19

    Can I chroot and execute grub update when I only want to add another linux deployment to grub menu?
    I don’t want to make the working linux distro on another SSD go faulty because of this.
    Thanks.

  2. Igor Drobot says

    October 18, 2020 at 01:14

    Hi, I believe, in your case, is a linux live CD the best way to:
    1. verify the hdd for issue
    2. change the password over the chroot

    As a linux live CD, personally I prefer to use GRML

  3. Bob says

    October 15, 2020 at 17:50

    Thank`s but you don`t understand i can not get into a terminal, i can`t logon as it won`t take my password for either account-both sudo-admins. When i start up i have 2 options ** E ** or **Advanced Options ** but neither does any good. I changed the ro quiet to re quiet init=/bin/bash booted then nothing.
    Let me ask a more specific question, if i use a live debian 10.6 how do i get into the fixed hdd – sd1 on my desktop as root ? I just was able to change the password by using a different version in advanced options it was the second one down the list but with the first one i could not do anything. I just tried to login with the new password but i could not do it still. I`m thinking how do i remove any passwords so i can login w/o one to see how that works.
    Sorry for the choppy format but i`m trying to do two things at the same time w/o knowing the outcome.

  4. Igor Drobot says

    October 15, 2020 at 15:31

    Hi, have you already checked, if your boot device has any issues?
    Example: fsck -fyCV /dev/sda1

  5. Bill W. says

    October 15, 2020 at 01:31

    I have a problem after shutting my system down for several hours when i booted up i could not login like i normally do, debian 10.6 would not take my password. I created two accounts with the same privileges but the same thing with account 2. Recovery mode does not work and neither does e. Live OS does not work either if trying to chroot. I can sudo su and change the password but it will not take it on installed OS boot.
    Any suggestions so i don’t have to reinstall and loose everything ?

  6. Igor Drobot says

    April 8, 2020 at 11:28

    This already the correct syntax:
    sudo -t proc /mnt/proc
    In your commands is mount missing!

  7. Wayne says

    April 7, 2020 at 23:10

    mint 19.3 Mate installed SDA(1) – xfce4 desktop installed after Mate installed. Booted live mint 19.3 Mate. Machine has several OS’s installed. While using Grub-Customizer, grub-menu failed to show. Attempted your solution, but no success. Below is the first difficulty:

    mint@mint:~$ sudo mount /dev/sda1 /mnt/
    mint@mint:~$ sudo -t proc none /mnt/proc
    sudo: none: command not found
    mint@mint:~$ sudo -t proc /mnt/proc
    sudo: /mnt/proc: command not found
    mint@mint:~$ sudo -t /mnt/proc
    usage: sudo -h | -K | -k | -V
    usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
    usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
    [command]
    usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
    prompt] [-T timeout] [-u user] [VAR=value] [-i|-s] []
    usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
    prompt] [-T timeout] [-u user] file …
    mint@mint:~$

  8. Gnoki says

    September 11, 2019 at 15:12

    Thank you man !!

  9. Pavel says

    May 2, 2019 at 03:46

    Also for LVM to work in chroot
    mount -o bind /run /mnt/run

  10. KS says

    September 17, 2018 at 21:36

    I have broken grub2 countless times and this is the only distro agnostic guide that has enabled me to reach a solution. Thank you very much for this. I’d get this tattooed on my face if it were acceptable.

  11. Michael says

    March 1, 2016 at 22:48

    Thank you very very much

  12. DolfyCzech says

    September 20, 2015 at 13:13

    Hi. Very usefull, works for me. But with one notice: Can’t be uses ANY Live CD/DVD/USB. In my case, I have AMD64 (x86_64) OS on PC and i386 (x86) Live USB (Ubuntu 14.04). When I try to chroot, it said, that I can’t chroot to different architecture. Solved by create AMD64 Live USB flash.

  13. SoseR says

    January 26, 2015 at 22:34

    –force is required if have any error message
    ( grub-install –force /dev/sda )

  14. Grateful Reader says

    September 15, 2014 at 06:53

    Thank you. Very helpful.

  15. zeldor says

    October 11, 2011 at 15:20

    Problem: Cannot find list of partitions! (Try mounting /sys.)
    Solved: mount sysfs /sys -t sysfs

Trackbacks

  1. Debootstrap, creando una distribución artesana « Adventures of a distro (linux) developer says:
    January 22, 2012 at 12:48

    […] http://www.linuxcertif.com/man/1/cdebootstrap/ http://zeldor.biz/2010/12/install-grub-from-chroot/ http://wiki.debian.org/Xfce Share this:TwitterFacebookMe gusta:Me gustaSé el primero en decir que […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Yeaaah Cookie! We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok