April 2, 2012

Using Knoppix - Reinstall or restore GRUB / Bootloader

grub-install does not work?
No problem.

In this example we have one disk sda with 3 partitions:

sda1 = /boot
sda2 = swap
sda3 = /

Grub has a different namespace.
The first disk is hd0 and partitions are named for example hd0,0 for sda1.

To install grub to the first disk with sda1 as its boot partition run:

# grub
root (hd0,0)
setup (hd0)
quit

Before that, do this :

Boot Knoppix
$ mkdir /mnt/root
$ mount -t ext3 /dev/sda3 /mnt/root
$ mount -t ext3 /dev/sda1 /mnt/root/boot
$ mount -t proc none /mnt/root/proc
$ mount -o bind /dev /mnt/root/dev
$ chroot /mnt/root

P.s:

- To wipe out bootloader, run : dd if=/dev/zero of=/dev/sda bs=446 count=1

- To wipe out bootloader (with Partition Table), run : dd if=/dev/zero of=/dev/sda bs=512 count=1
- To backup partiton table, run : sfdisk -d /dev/sda > part.txt
- To restore partiton table, run : sfdisk /dev/sda < part.txt

Knoppix - Mount LVM

# modprobe dm-mod
# vgscan --mknodes
# vgchange -ay
# lvscan
#
# mkdir /mnt/somename
# mount /dev/VolGroup00/LogVol00 /mnt/somename