lvm extend 로 lvm 용량 확장 하는 법
1. ext4
[root@test1 test]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 xfs 6.9G 1001M 5.9G 15% /
devtmpfs devtmpfs 486M 0 486M 0% /dev
tmpfs tmpfs 496M 0 496M 0% /dev/shm
tmpfs tmpfs 496M 6.8M 490M 2% /run
tmpfs tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/sr1 iso9660 4.2G 4.2G 0 100% /media
/dev/sda1 xfs 187M 102M 86M 55% /boot
tmpfs tmpfs 100M 0 100M 0% /run/user/0
/dev/mapper/vg01-root ext4 7.8G 7.8G 0 100% /test
[root@test1 test]# ll
total 8068564
drwx------. 2 root root 16384 Oct 21 09:06 lost+found
-rw-r--r--. 1 root root 0 Oct 21 09:06 test
-rw-r--r--. 1 root root 8262189056 Oct 21 09:11 test.txt
[root@test1 test]# lvextend /dev/mapper/vg01-root -l +100%FREE
Size of logical volume vg01/root changed from <8.00 GiB (2047 extents) to 15.99 GiB (4094 extents).
Logical volume vg01/root successfully resized.
[root@test1 test]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root vg01 -wi-ao---- 15.99g
[root@test1 test]# resize2fs /dev/mapper/vg01-root
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/vg01-root is mounted on /test; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mapper/vg01-root is now 4192256 blocks long.
[root@test1 test]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 xfs 6.9G 1001M 5.9G 15% /
devtmpfs devtmpfs 486M 0 486M 0% /dev
tmpfs tmpfs 496M 0 496M 0% /dev/shm
tmpfs tmpfs 496M 6.8M 490M 2% /run
tmpfs tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/sr1 iso9660 4.2G 4.2G 0 100% /media
/dev/sda1 xfs 187M 102M 86M 55% /boot
tmpfs tmpfs 100M 0 100M 0% /run/user/0
/dev/mapper/vg01-root ext4 16G 7.8G 7.2G 52% /test
[root@test1 test]# ll
total 8068564
drwx------. 2 root root 16384 Oct 21 09:06 lost+found
-rw-r--r--. 1 root root 0 Oct 21 09:06 test
-rw-r--r--. 1 root root 8262189056 Oct 21 09:11 test.txt
ext 파일시스템의 경우 resize2fs을 이용하면 된다. 기존 파일은 그대로인 걸 볼 수 있다.
2.xfs
[root@test1 test]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 xfs 6.9G 1001M 5.9G 15% /
devtmpfs devtmpfs 486M 0 486M 0% /dev
tmpfs tmpfs 496M 0 496M 0% /dev/shm
tmpfs tmpfs 496M 6.8M 490M 2% /run
tmpfs tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/sr1 iso9660 4.2G 4.2G 0 100% /media
/dev/sda1 xfs 187M 102M 86M 55% /boot
tmpfs tmpfs 100M 0 100M 0% /run/user/0
/dev/mapper/vg01-root xfs 8.0G 8.0G 2.4M 100% /test
[root@test1 test]# ll
total 8338944
-rw-r--r--. 1 root root 8539078656 Oct 21 09:30 test
[root@test1 test]# lvextend /dev/mapper/vg01-root -l +100%FREE
Size of logical volume vg01/root changed from <8.00 GiB (2047 extents) to 15.99 GiB (4094 extents).
Logical volume vg01/root successfully resized.
[root@test1 test]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root vg01 -wi-ao---- 15.99g
[root@test1 test]# xfs_growfs /dev/mapper/vg01-root
meta-data=/dev/mapper/vg01-root isize=512 agcount=4, agsize=524032 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=2096128, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2096128 to 4192256
[root@test1 test]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 xfs 6.9G 1001M 5.9G 15% /
devtmpfs devtmpfs 486M 0 486M 0% /dev
tmpfs tmpfs 496M 0 496M 0% /dev/shm
tmpfs tmpfs 496M 6.8M 490M 2% /run
tmpfs tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/sr1 iso9660 4.2G 4.2G 0 100% /media
/dev/sda1 xfs 187M 102M 86M 55% /boot
tmpfs tmpfs 100M 0 100M 0% /run/user/0
/dev/mapper/vg01-root xfs 16G 8.0G 8.0G 50% /test
[root@test1 test]# ll
total 8338944
-rw-r--r--. 1 root root 8539078656 Oct 21 09:30 test
xfs 파일시스템의 경우 xfs_growfs을 이용하면 된다. 기존 파일은 그대로인 걸 볼 수 있다.
lvm 용량을 늘릴때는 mount를 안풀어도 된다.