next up previous contents
Next: xfs lv 放大 Up: XFS 檔案系統 Previous: ext4 lv 放大縮小   Contents

xfs lv 縮小

  1. 查看 v7 的檔案系統,家目錄 /home 的分割區為 xfs。
    [root@kvm7 ~]# df -Th /home
    Filesystem                 Type  Size  Used Avail Use% Mounted on
    /dev/mapper/vg_kvm7home-vo xfs    97M  5.3M   92M   6% /home
    
  2. 先卸載家目錄 /home,家目錄忙錄中無法卸載。
    [root@kvm7 ~]# umount /home
    umount: /home: target is busy.
            (In some cases useful info about processes that use
             the device is found by lsof(8) or fuser(1))
    
  3. 使用 lsof 查看家目錄 /home 使用狀況,為自動掛載程式掛載在 /home/guests。
    [root@kvm7 ~]# lsof | grep /home
    automount 1539         root   16r      DIR               0,37         0      18663 /home/guests
    automount 1539 1540    root   16r      DIR               0,37         0      18663 /home/guests
    automount 1539 1541    root   16r      DIR               0,37         0      18663 /home/guests
    automount 1539 2032    root   16r      DIR               0,37         0      18663 /home/guests
    automount 1539 2068    root   16r      DIR               0,37         0      18663 /home/guests
    automount 1539 2096    root   16r      DIR               0,37         0      18663 /home/guests
    
  4. 先關閉自動掛載,再卸載家目錄 /home。
    [root@kvm7 ~]# systemctl stop autofs.service 
    [root@kvm7 ~]# umount /home
    
  5. 使用 lvresize 將 /dev/vg_kvm7home/vo 由 100M 縮小為 50M,出現 Xfs 檔案系統不支援縮小的訊息,表示 lvm 中 xfs 檔案系統格式的 lv 無法直接縮小,若真有必要縮小,必須建一個新的較小的 lv,將資料移過去後再刪除目前的 lv。
    [root@kvm7 ~]# lvresize -L 50M /dev/vg_kvm7home/vo -r
    Phase 1 - find and verify superblock...
    Phase 2 - using internal log
            - scan filesystem freespace and inode maps...
            - found root inode chunk
    Phase 3 - for each AG...
            - scan (but don't clear) agi unlinked lists...
            - process known inodes and perform inode discovery...
            - agno = 0
            - agno = 1
            - agno = 2
            - agno = 3
            - agno = 4
            - process newly discovered inodes...
    Phase 4 - check for duplicate blocks...
            - setting up duplicate extent list...
            - check for inodes claiming duplicate blocks...
            - agno = 0
            - agno = 1
            - agno = 2
            - agno = 3
            - agno = 4
    No modify flag set, skipping phase 5
    Phase 6 - check inode connectivity...
            - traversing filesystem ...
            - traversal finished ...
            - moving disconnected inodes to lost+found ...
    Phase 7 - verify link counts...
    No modify flag set, skipping filesystem flush and exiting.
    fsadm: Xfs filesystem shrinking is unsupported
      fsadm failed: 1
      Filesystem resize failed.
    



2015-12-04