Tuesday, March 12, 2013

Linux Troubleshoot




MBR rebuild
- boot to rescue mode
- # chroot /mnt/sysimage
- # grub-install /dev/sda
- # exit

Fix Grub menu
symptom: boot stop at grub> (e.g. after remove /etc/grub.conf)
grub> root (hd0,
 Possible partitions are:
     Partition num: 0, Filesystem type is ext2fs, partition type 0x83

     Partition num: 1, Filesystem type is ext2fs, partition type 0x83
     Partition num: 2, Filesystem type is unknown, partition type 0x82
     Partition num: 4, Filesystem type is ext2fs, partition type 0x83
grub> root (hd0,0)
  Filesystem type is ext2fs, partition type -x83
grub> kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/sda2 quiet
     [Linux-bzImage, setup=0x1e00, size=0x1c31d4]
grub> initrd /initrd=2.6.18-164.el5.img
     [Linux-initrd 0xfcb400, 0x276090 bytes]
grub> boot
After boot, # vi /boot/grub/grub.conf
(:.!ls /boot to insert content under /boot), the file grub.conf will be like:
default=0
timeout=5
hiddenmenu
title linux
root (hd0,0)
kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/sda2 quiet
initrd /initrd-2.6.18-164.el5.img
# cd /etc
# ln -s ../boot/grub/grub.conf .

fstab error
Can only boot to readonly root system:
Give root password for maintenance
(or type Control-D to continue):

remount the root partition:
# mount -o rw,remount /

Recovering /boot, fstab
- boot to rescue mode
- # findfs LABEL=/ find root partition and other partition
- manual mount / and other partition to /mnt/sysimage
- # chroot /mnt/sysimage
- rebuild/recreate fstab
- re-install kernel
  # rpm -ivh kernel-2.6.18-8.e15.i686.rpm --root=/ --force
  This will install /boot
- # grub-install /dev/sda

disk performance
# smartctl -H /dev/sdb
# hdparm -t /dev/sdb
# vmstat
# iostat -x -k 5
# strace -c ls -R /



No comments:

Post a Comment