Linux - Rescue/Recovery
Grub Lines
Emergency boot:
Start execution step by step with confirmation:
Disable SELinux:
Procedures
Rescue from Grub
Start rescue from Grub menu:
# Depuis le menu Grub:
[e]
# Edit line with linux16 and add:
init=/bin/bash
# Save with:
[ctrl-x]
# After boot, Remount /:
mount -o rw,remount /
Rescue from Boot CD-Rom
Rescue Mode after CD-Rom Boot:
# Change keyboard to FR
loadkeys fr
# Enable rootvg
vgchange -ay rootvg
# Create target directory
mkdir -p /target{,/usr,/home,/dev,/proc,/sys}
# Mount system FS
mount /dev/mapper/rootvg-root /target
mount /dev/mapper/rootvg-usr /target/usr
mount /dev/sda1 /target/boot
mount --bind /dev /target/dev
mount -t proc none /target/proc
mount -t sysfs none /target/sys
# Change root to target dir
chroot /target
Force FSCK in boot
RedHat 7|8
Edit this file:
Add fsck.mode=forceand fsck.repair=yes options to GRUB_CMDLINE_LINUX vars:
# /etc/default/grub
...
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet fsck.mode=force fsck.repair=yes"
Rebuild grub2 file:
Scripts
Filesystem Corrupt
file -s /dev/dm* |grep errors |awk '{print $1}' |sed 's|:||'|sed 's|^.*/dm-||' |while read DM; do
LV=$(dmsetup ls |grep "(253:$DM)" | awk '{print $1}')
FS=$(df -ThP |grep -w $LV |awk '{print $NF}')
[[ -z $FS ]] && FS=NOTMOUNTED
echo $LV $FS
done
file -s /dev/dm* |grep errors |awk '{print $1}' |sed 's|:||'|sed 's|^.*/dm-||' |while read DM; do
LV=$(dmsetup ls |grep "(253:$DM)" |awk '{print $1}')
FS=$(df -ThP |grep -w $LV |awk '$NF != "NOTMOUNTED" {print $NF}')
[[ -z $FS ]] && FS=NOTMOUNTED ;echo $LV $FS
done |awk '{print $NF}' |xargs -i lsof {} |awk '{print $2}' |sort -u |grep -v PID |xargs -i kill -9 {}
file -s /dev/dm* |grep errors |awk '{print $1}' |sed 's|:||'|sed 's|^.*/dm-||' |while read DM; do
LV=$(dmsetup ls |grep "(253:$DM)" |awk '{print $1}')
FS=$(df -ThP |grep -w $LV |awk '$NF != "NOTMOUNTED" {print $NF}')
[[ -z $FS ]] && FS=NOTMOUNTED ;echo $LV $FS
done |awk '{print $NF}' |xargs -i umount {}
file -s /dev/dm* |grep errors |awk '{print $1}' |sed 's|:||'|sed 's|^.*/dm-||' |while read DM; do
LV=$(dmsetup ls |grep "(253:$DM)" |awk '{print $1}')
FS=$(df -ThP |grep -w $LV |awk '{print $NF}')
[[ -z $FS ]] && FS=NOTMOUNTED ;echo $LV $FS
done |awk '$2 == "NOTMOUNTED" { print "fsck -y /dev/mapper/"$1 }' |sh