Resize LVM partition size
[root@amastest RPM2]# df -Th
?? % 瞜
/dev/mapper/centos-root xfs 1.6T 10G 1.6T 1% /
devtmpfs devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs tmpfs 7.7G 82M 7.7G 2% /run
tmpfs tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 235M 780M 24% /boot
tmpfs tmpfs 1.6G 12K 1.6G 1% /run/user/42
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/1000
/dev/mapper/centos-home xfs 100G 2.6G 98G 3% /home
1 dump /home to /
xfsdump -l 0 -L boot_all -M boot_all -f /home.dump /home
2 umount /home
fuser -muv /home
/home: root kernel mount (root)/home
amas 8367 ..c.. (amas)sftp-server
[root@amastest /]# cd /
[root@amastest /]# kill -9 8367
[root@amastest /]# umount /home
3 remove home
LVMボリューム(lv path)を非活性化する
lvchange -an /dev/mapper/centos-home
LVMボリューム(lv path)を削除する
lvremove /dev/mapper/centos-home
4 create /home
lvcreate -L 100G -n home centos
mkfs.xfs /dev/centos/home
mount /dev/centos/home
5 restore /home
xfsrestore -f /home.dump -L boot_all /home
#空いたサイズをrootに割当
lvextend -l +100%FREE /dev/centos/root
#rootを拡張
xfs_growfs /dev/mapper/centos-root
#確認
df -Th
from http://hogem.hatenablog.com/entry/20120711/1342018292
linux LVM でextパーティションのサイズ変更(拡大/縮小)
- man lvm
- man lvextend
- man lvreduce
- man resize2fs
あんましlvm使わないので勉強。実験した環境
VG Name | vg_hoge | |
LV Name | lv_home | |
LV Size | 400.00 GiB | |
device | /dev/vg_hoge/lv_home |
準備
色々確認しておく
from https://www.linuxtechi.com/reduce-size-lvm-partition/
How to reduce LVM partition size in RHEL and CentOS
Sometimes when we are running out of disk space in our Linux box and if partition created on LVM , then we can make some free space in the volume group by reducing the LVM using lvreduce command.In this article we will discuss the required steps to reduce the size of LVM safely on CentOS and RHEL Servers, Below steps are eligible when the LVM partition is formated either as ext
Scenario : Suppose we want to reduce /home by 2GB which is on LVM partition & formated as ext4.
Step:1 Umount the file system
Use the beneath umount command
Step:2 check the file system for Errors using e2fsck command.
Note: In the above command e2fsck , we use the option ‘-f’ to forcefully check the file system, even if the file system is clean.
Step:3 Reduce or Shrink the size of /home to desire size.
As shown in the above scenario, size of /home is 12 GB , so by reducing it by 2GB , then the size will become 10GB.
留言
張貼留言