Sub topics
Useful boot time parameters
Grub2
Backup MBR
The first 512b contains partition table and the MBR. First 448b contains the MBR only.ref http://www.tuxation.com/mbr-tricks-with-linux.html
dd if=/dev/sda of=mbr.img bs=448 count=1
Rescue / emergency boot disc
It is a good idea to make such a boot disc especially when you have custom kernel with extra filesystem and storage controllers enabled. On your running system, run the following to create an iso, which can then be cut to a cd disc:mkbootdisk --device /rescue.iso --verbose --iso 2.6.28.1
Fixing boot record
Sometimes, MBR (master boot record) may be messed up if you have a dual-boot system. Do the followings and get your boot loader fixed:# boot up your system with your installation CD, enter **linux rescue** at boot prompt. Most Linux LiveCD (like Ubunto) will do.
mkdir /mnt/mysys
# My root partition is on /dev/vg0/lv_root
mount -t ext3 /dev/vg0/lv_root /mnt/mysys
mount -t proc none /mnt/mysys/proc
mount -o bind /dev /mnt/mysys/dev
# chroot to the mysys mount point
chroot /mnt/mysys /bin/bash
# mount the boot partition
mount -t ext3 /dev/hda2 /boot
# run grub install to fix the boot loader
grub-install /dev/hda
grub-install --recheck /dev/dev/hda
# Reboot
mkdir /mnt/mysys
# My root partition is on /dev/vg0/lv_root
mount -t ext3 /dev/vg0/lv_root /mnt/mysys
mount -t proc none /mnt/mysys/proc
mount -o bind /dev /mnt/mysys/dev
# chroot to the mysys mount point
chroot /mnt/mysys /bin/bash
# mount the boot partition
mount -t ext3 /dev/hda2 /boot
# run grub install to fix the boot loader
grub-install /dev/hda
grub-install --recheck /dev/dev/hda
# Reboot
Fix grub in grub prompt
[root@www root]# grub grub> find /boot/grub/stage1 (hd0,0) grub> root (hd0,0) Filesystem type is ext2fs, partition type 0x83 grub> setup (hd0)
Boot from grub prompt
The key is to point grub to the right partition. If the root parameter points to a partition other than /, system will halt with a kernel panic error.grub> root (hd0,1) grub> kernel /vmlinuz root=/dev/cciss/c0d0p1 ro vga=791 grub> boot
Setting up a boot-once grub session
It's very useful to setup grub to boot to a specific kernel only once, to perhaps test out a newly compiled kernel. Setup your grub.conf like thisdefault saved # This is important!!! timeout 10 title the old kernel root (hd0,0) kernel /old_kernel savedefault title the new kernel root (hd0,0) kernel /new_kernel savedefault 0 # This is important!!!
Essentially, when entry #1 is booted, it will instruct grub to boot from entry #0 on next boot. Save grub.conf and then do a
grub-set-default 1
You can also configure grub to do fallback boot. See Grub's manual http://www.gnu.org/software/grub/manual/grub.html#Booting-once_002donly
Messing with initrd
If you clone / migrate your system to a different box which uses a different storage card, you may need to edit the initrd file to add load the necessary modules.# back it up first!! cp initrd-2.x.x.img initrd-2.x.x.img-bak # extract the image to temp mkdir temp cd temp zcat ../initrd-2x.x.img | cpio -idmv # do what you have to. e.g. edit init to load a certain module, copy that module to temp/lib # then pack the image find . | cpio --create --format=newc > /boot/initrd-2.x.x-new.img
There are no comments on this page. [Add comment]