Linux LVM格式磁盘调整

[root@h1 /]# vgs
  VG    #PV #LV #SN Attr   VSize  VFree
  vg_h1   1   3   0 wz--n- 99.51g    0

[root@h1 /]# lvs
  LV      VG    Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_home vg_h1 -wi-ao---- 47.57g
  lv_root vg_h1 -wi-ao---- 50.00g
  lv_swap vg_h1 -wi-ao----  1.94g
[root@h1 /]#
[root@h1 /]# vgdisplay
  --- Volume group ---
  VG Name               vg_h1
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               99.51 GiB
  PE Size               4.00 MiB
  Total PE              25474
  Alloc PE / Size       25474 / 99.51 GiB
  Free  PE / Size       0 / 0
  VG UUID               sazXpz-UgcQ-xAzt-c6zC-TR0U-nqcH-HiO3Zt

[root@h1 /]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg_h1/lv_root
  LV Name                lv_root
  VG Name                vg_h1
  LV UUID                PYbQnD-UWik-qZyU-3klo-CQv9-ERnv-eXqHJA
  LV Write Access        read/write
  LV Creation host, time h1, 2018-04-08 19:11:17 +0800
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/vg_h1/lv_home
  LV Name                lv_home
  VG Name                vg_h1
  LV UUID                vnfmaL-Owk1-9K1Q-sNWC-SGiv-Gcp5-fjEtC6
  LV Write Access        read/write
  LV Creation host, time h1, 2018-04-08 19:11:21 +0800
  LV Status              available
  # open                 1
  LV Size                47.57 GiB
  Current LE             12178
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Path                /dev/vg_h1/lv_swap
  LV Name                lv_swap
  VG Name                vg_h1
  LV UUID                2PYWdz-IC2s-dl3G-LRKj-5C21-cycx-uez8VD
  LV Write Access        read/write
  LV Creation host, time h1, 2018-04-08 19:11:22 +0800
  LV Status              available
  # open                 1
  LV Size                1.94 GiB
  Current LE             496
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

[root@h1 /]# umount /home
[root@h1 /]#
[root@h1 /]#
[root@h1 /]# df -lh
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/vg_h1-lv_root   50G  2.1G   45G   5% /
tmpfs                      4.9G     0  4.9G   0% /dev/shm
/dev/sda1                  485M   39M  421M   9% /boot
[root@h1 /]#

[root@h1 /]# e2fsck -f /dev/mapper/vg_h1-lv_home
e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/mapper/vg_h1-lv_home: 11/3121152 files (0.0% non-contiguous), 241933/12470272 blocks
[root@h1 /]#
[root@h1 /]#
[root@h1 /]#
[root@h1 /]# resize2fs -p /dev/mapper/vg_h1-lv_home 10G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_h1-lv_home to 2621440 (4k) blocks.
Begin pass 2 (max = 32768)
正在重定位块            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 381)
正在扫描inode表          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/vg_h1-lv_home is now 2621440 blocks long.

[root@h1 /]# mount /home
[root@h1 /]#
[root@h1 /]#
[root@h1 /]# df -lh
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/vg_h1-lv_root   50G  2.1G   45G   5% /
tmpfs                      4.9G     0  4.9G   0% /dev/shm
/dev/sda1                  485M   39M  421M   9% /boot
/dev/mapper/vg_h1-lv_home  9.9G  164M  9.2G   2% /home

[root@h1 /]# lvreduce -L 10G /dev/mapper/vg_h1-lv_home
  WARNING: Reducing active and open logical volume to 10.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
  Reducing logical volume lv_home to 10.00 GiB
  Logical volume lv_home successfully resized
[root@h1 /]#
[root@h1 /]#
[root@h1 /]#
[root@h1 /]# vgdisplay
  --- Volume group ---
  VG Name               vg_h1
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               99.51 GiB
  PE Size               4.00 MiB
  Total PE              25474
  Alloc PE / Size       15856 / 61.94 GiB
  Free  PE / Size       9618 / 37.57 GiB
  VG UUID               sazXpz-UgcQ-xAzt-c6zC-TR0U-nqcH-HiO3Zt

[root@h1 /]#
[root@h1 /]# lvextend -L +37.40G /dev/mapper/vg_h1-lv_root
  Rounding size to boundary between physical extents: 37.40 GiB
  Extending logical volume lv_root to 87.40 GiB
  Logical volume lv_root successfully resized
[root@h1 /]#
[root@h1 /]# resize2fs -p /dev/mapper/vg_h1-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_h1-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 6
Performing an on-line resize of /dev/mapper/vg_h1-lv_root to 22912000 (4k) blocks.
The filesystem on /dev/mapper/vg_h1-lv_root is now 22912000 blocks long.

[root@h1 /]# df -lh
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/vg_h1-lv_root   87G  2.1G   80G   3% /
tmpfs                      4.9G     0  4.9G   0% /dev/shm
/dev/sda1                  485M   39M  421M   9% /boot
/dev/mapper/vg_h1-lv_home  9.9G  164M  9.2G   2% /home
[root@h1 /]#
[root@h1 /]#
[root@h1 /]#

你可能感兴趣的:(运维)