Linux centos7 增加root分区容量
#操作前查看磁盘空间大小
[root@192 /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 50G 6.0G 44G 12% / devtmpfs 2.8G 0 2.8G 0% /dev tmpfs 2.8G 0 2.8G 0% /dev/shm tmpfs 2.8G 9.1M 2.8G 1% /run tmpfs 2.8G 0 2.8G 0% /sys/fs/cgroup /dev/mapper/centos-home 967G 33M 967G 1% /home /dev/sda1 1014M 180M 835M 18% /boot tmpfs 568M 4.0K 568M 1% /run/user/42 tmpfs 568M 40K 568M 1% /run/user/0 [root@192 /]# clear #查看 文件内容 [root@192 /]# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
# 备份 home 分区 [root@192 /]# cp -r /home/ homebak
# 卸载home 目录 [root@192 /]# umount /home/
# 查看 文件情况 [root@192 /]# ls bin boot dev etc home homebak lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
# 删除 home 所在的 lvm逻辑卷 [root@192 /]# lvremove /dev/mapper/centos-home Do you really want to remove active logical volume centos/home? [y/n]: y Logical volume "home" successfully removed
#增加 root 所在lvm逻辑卷的容量 [root@192 /]# lvextend -L +200G /dev/mapper/centos-root Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 250.00 GiB (64000 extents). Logical volume centos/root successfully resized. # 同步 root 文件系统 [root@192 /]# xfs_growfs /dev/mapper/centos-root meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=13107200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=6400, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 13107200 to 65536000 [root@192 /]#
#查看文件 容量 [root@192 /]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 250G 6.4G 244G 3% / devtmpfs 2.8G 0 2.8G 0% /dev tmpfs 2.8G 0 2.8G 0% /dev/shm tmpfs 2.8G 9.1M 2.8G 1% /run tmpfs 2.8G 0 2.8G 0% /sys/fs/cgroup /dev/sda1 1014M 180M 835M 18% /boot tmpfs 568M 4.0K 568M 1% /run/user/42 tmpfs 568M 56K 568M 1% /run/user/0 [root@192 /]# cd /root [root@192 ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 250G 6.4G 244G 3% / devtmpfs 2.8G 0 2.8G 0% /dev tmpfs 2.8G 0 2.8G 0% /dev/shm tmpfs 2.8G 9.1M 2.8G 1% /run tmpfs 2.8G 0 2.8G 0% /sys/fs/cgroup /dev/sda1 1014M 180M 835M 18% /boot tmpfs 568M 4.0K 568M 1% /run/user/42 tmpfs 568M 56K 568M 1% /run/user/0
#重新 创建 home lvm 逻辑卷 可以 vgdisplay 查看剩余空间大小 [root@192 ~]# lvcreate -L 660G -n home centos Logical volume "home" created.
#创建home 文件系统 [root@192 ~]# mkfs.xfs /dev/centos/home meta-data=/dev/centos/home isize=512 agcount=4, agsize=43253760 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=173015040, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=84480, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
#挂载 home分区 [root@192 ~]# mount /dev/centos/home /home [root@192 ~]# ls anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg Music Pictures Public Templates Videos [root@192 ~]# cd / [root@192 /]# ls bin boot dev etc home homebak lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
#将之前备份的文件拷贝回来 [root@192 /]# cp -r /homebak/* /home [root@192 /]# cd /home [root@192 home]# ls postgers [root@192 home]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 250G 6.4G 244G 3% / devtmpfs 2.8G 0 2.8G 0% /dev tmpfs 2.8G 0 2.8G 0% /dev/shm tmpfs 2.8G 9.1M 2.8G 1% /run tmpfs 2.8G 0 2.8G 0% /sys/fs/cgroup /dev/sda1 1014M 180M 835M 18% /boot tmpfs 568M 4.0K 568M 1% /run/user/42 tmpfs 568M 52K 568M 1% /run/user/0 /dev/mapper/centos-home 660G 33M 660G 1% /home [root@192 home]#
#查看磁盘空间剩余情况
[root@192 home]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
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 <1023.00 GiB
PE Size 4.00 MiB
Total PE 261887
Alloc PE / Size 234432 / 915.75 GiB
Free PE / Size 27455 / <107.25 GiB
VG UUID dhl6Zn-hE2n-ffTU-EsDj-6mYK-lpCD-Hu1JFY
[root@192 home]#
学问:纸上得来终觉浅,绝知此事要躬行
为事:工欲善其事,必先利其器。
态度:道阻且长,行则将至;行而不辍,未来可期
.....................................................................
------- 桃之夭夭,灼灼其华。之子于归,宜其室家。 ---------------
------- 桃之夭夭,有蕡其实。之子于归,宜其家室。 ---------------
------- 桃之夭夭,其叶蓁蓁。之子于归,宜其家人。 ---------------
=====================================================================
* 博客文章部分截图及内容来自于学习的书本及相应培训课程以及网络其他博客,仅做学习讨论之用,不做商业用途。
* 如有侵权,马上联系我,我立马删除对应链接。 * @author Alan -liu * @Email no008@foxmail.com
转载请标注出处! ✧*꧁一品堂.技术学习笔记꧂*✧. ---> https://www.cnblogs.com/ios9/