LVM

利用硬碟外接盒在備份資料,因為分割區是 LVM,結果把硬碟拔掉之後,LVM 的指令就會提示錯誤:

[maple@maple-admin ~]$ sudo lvdisplay
  /dev/vg001/swap: read failed after 0 of 4096 at 7998472192: Input/output error
  /dev/vg001/swap: read failed after 0 of 4096 at 7998529536: Input/output error
  /dev/vg001/swap: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg001/swap: read failed after 0 of 4096 at 4096: Input/output error
  /dev/vg001/root: read failed after 0 of 4096 at 311942905856: Input/output error
  /dev/vg001/root: read failed after 0 of 4096 at 311942963200: Input/output error
  /dev/vg001/root: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg001/root: read failed after 0 of 4096 at 4096: Input/output error
  --- Logical volume ---
  LV Path                /dev/vg01/swap
  LV Name                swap
  VG Name                vg01
  LV UUID                E5f1kK-AqHK-4odK-VfLG-LRRd-JV7T-XYLDs5
  LV Write Access        read/write
  LV Creation host, time maple-admin, 2015-06-10 21:05:12 +0800
  LV Status              available
  # open                 2
  LV Size                952.00 MiB
  Current LE             238
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

查看了一下 /dev/vg001/

[maple@maple-admin ~]$ ls /dev/vg001/ -lh
total 0
lrwxrwxrwx 1 root root 7 Jul 15 15:13 root -> ../dm-3
lrwxrwxrwx 1 root root 7 Jul 15 15:13 swap -> ../dm-2

dmsetup 還可以看到 LVM 的存在

[maple@maple-admin ~]$ sudo dmsetup status
vg01-swap: 0 1949696 linear
vg01-root: 0 3904823296 linear
vg001-swap: 0 15622144 linear
vg001-root: 0 609263616 linear

但是 vg001-root 不應該存在,因為硬碟已經拔除了

Solution

既然 LVM 會 link 到 /dev/dm-X,那麼解決方法就是直接用 dmsetup remove [--force] <device> 就可以了

[maple@maple-admin ~]$ sudo dmsetup remove --force vg001-root
[maple@maple-admin ~]$ sudo dmsetup remove --force vg001-swap
[maple@maple-admin ~]$ sudo dmsetup status
vg01-swap: 0 1949696 linear
vg01-root: 0 3904823296 linear
[maple@maple-admin ~]$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg01/swap
  LV Name                swap
  VG Name                vg01
  LV UUID                E5f1kK-AqHK-4odK-VfLG-LRRd-JV7T-XYLDs5
  LV Write Access        read/write
  LV Creation host, time maple-admin, 2015-06-10 21:05:12 +0800
  LV Status              available
  # open                 2
  LV Size                952.00 MiB
  Current LE             238
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

Comments

comments powered by Disqus