zeldor.biz

Linux, programming and more

Copyright © 2023
Log in

Backup your MBR

September 5, 2011 by Igor Drobot Leave a Comment

Master Boot Record (MBR), a small program that is executed when a computer boots up.

You can save your MBR with a simple DD-command to a file:

1
dd if=/dev/sda count=1 bs=512 > /var/backup/MBR

dd if=/dev/sda count=1 bs=512 > /var/backup/MBR

From this file you can restore your MBR very easy:

1
dd if=/var/backup/MBR of=/dev/sdb

dd if=/var/backup/MBR of=/dev/sdb

Filed Under: Linux Tagged With: Master Boot Record, MBR, Save MBR

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