linux lvm損壞導致開機emergency mode修復

異常關閉linux電源容易導致啓動失敗進入emergency mode。


進入emergency mode的原因很多,通常是磁盤關機出現問題,可以通過用linux引導盤到rescue模式下查看原因並修復。

如果是lvm卷出現問題,可以用如下方式嘗試修復:

1, lvm vgscan查看有哪些vg
# lvm vgscan
  Reading volume groups from cache.
  Found volume group "centos_master" using metadata type lvm2

2, 激活vg
# lvm vgchange -ay 
  2 logical volume(s) in volume group "centos_master" now active

3, 查看邏輯卷
# lvm lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos_master/swap
  LV Name                swap
  VG Name                centos_master
  LV UUID                XAhwdw-yLyi-JDXx-NwGF-QDJv-c06h-Jm7iYD
  LV Write Access        read/write
  LV Creation host, time master, 2018-12-05 23:49:56 +0800
  LV Status              available
  # open                 2
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos_master/root
  LV Name                root
  VG Name                centos_master
  LV UUID                ozZUmD-fyQE-TakK-MQgH-6Dvt-4Tdj-783S70
  LV Write Access        read/write
  LV Creation host, time master, 2018-12-05 23:49:57 +0800
  LV Status              available
  # open                 1
  LV Size                <17.00 GiB
  Current LE             4351
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0


4,查看時哪個 lv掛載有問題,比如 mkdir /root/disk; mount /dev/centos_master/root /root/disk。 如果失敗則mount會報錯。
5,嘗試修復有問題的邏輯卷
# fsck /dev/centos_master/root
fsck,來自 util-linux 2.23.2
If you wish to check the consistency of an XFS filesystem or
repair a damaged filesystem, see xfs_repair(8).

6, 按照嚮導用xfs_repair進行修復。通常是metatdata與卷journallog不一致,可以用如下方式嘗試修復。
# xfs_repair -L  /dev/centos_master/root

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章