Montaje de Linux – reescritura del MBR – Boot

Montando una instalación de Linux con CHROOT

Recuperación de menu GRUB

1) Arrancar con Live CD o Live USB de ubuntu, explorar particiones y buscar instalacion de disco de arranque: ejemplo: /dev/sda1

Nota: sda1 contiene una instalacion de Windows

2) Se arranca con un Linux de rescate

3) Buscar instalacion existente a recuperar boot en disco, ej: /dev/sdb2

4) Montar el sistema de archivos y una consola del linux a recuperar

# mkdir /mnt/custom
# mount /dev/sdb2 /mnt/custom/
# mount –bind /proc /mnt/custom/proc/
# mount –bind /sys /mnt/custom/sys
# mount –bind /dev /mnt/custom/dev
# chroot /mnt/custom/

5) Correr comando “grub” para recuperar menu de arranque sobre disco y particion primaria de disco seleccionado para arrancar

update-grub
grub-install /dev/sda

6) Desmontar sistemas de archivos de linux antes utilizados

# umount /dev/sdb2 /mnt/custom/
# umount –bind /proc /mnt/custom/proc/
# umount –bind /sys /mnt/custom/sys
# umount –bind /dev /mnt/custom/dev

7) Reiniciar

Alternativa con LVM

HOWTO: install grub with a chroot
Tags: Installation Issues.

I had somehow corrupted my MBR / bootloader, when trying to move a server from lilo to grub. To make matters more complicated, I was using LVM.

here is the setup of the system:
/dev/hda1 is /boot
/dev/hda5 is swap
/dev/hda6 is lvm

on the lvm:
/dev/mapper/volgroup00-root
/dev/mapper/volgroup00-home
/dev/mapper/volgroup00-usr

I booted the system with a Knoppix livecd, and switched to a command line. (ctrl+alt+f2)

To install the bootloader, it was necessary to “chroot” into my existing linux system.

all commands are run as root:
vgchange -ay # initialise lvm volumes
mkdir /mnt/root
mount /dev/mapper/volgroup00-root /mnt/root
mount /dev/mapper/volgroup00-usr /mnt/root/usr
mount /dev/mapper/volgroup00-home /mnt/root/home # not strictly necessary
mount -o bind /dev /mnt/root/dev
mount -t proc none /mnt/root/proc
mount -t sysfs none /mnt/root/sysfs

chroot /mnt/root /bin/bash
mount /dev/hda1 /boot
grub-install /dev/hda
/usr/sbin/update-grub

grub should now be installed on /dev/hda

Comment are closed.