zeldor.biz

Linux, programming and more

Copyright © 2018 · on Genesis Framework · WordPress · Log in

Install Grub from chroot

December 21, 2010 by Igor Drobot 6 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 backup bash Cisco Debian Debian squeeze DIY Exim4 Fedora FTP Fun GIT Icinga IMAP Ipv6 Juniper KVM Linux LVM MAC OS X Monitoring Munin MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy qemu RAID raid1 rsync Samba security ssh SSL Ubuntu virtualization Windows Windows 7 Wordpress Xen

Comments

  1. Michael says

    March 1, 2016 at 22:48

    Thank you very very much

  2. 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.

  3. SoseR says

    January 26, 2015 at 22:34

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

  4. Grateful Reader says

    September 15, 2014 at 06:53

    Thank you. Very helpful.

  5. 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 Cancel reply

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