当前位置:网站首页>lunix重新分配root 和 home 空间内存
lunix重新分配root 和 home 空间内存
2022-07-02 06:36:00 【lucky乐琪】
查看虚拟机磁盘分布
[root@data ~]# df -lh
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 4.7G 0 4.7G 0% /dev
tmpfs 4.7G 0 4.7G 0% /dev/shm
tmpfs 4.7G 13M 4.7G 1% /run
tmpfs 4.7G 0 4.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 44G 6.3G 88% /
/dev/mapper/centos-home 46G 33M 46G 1% /home
/dev/sda1 1014M 149M 866M 15% /boot
tmpfs 959M 0 959M 0% /run/user/0
overlay 50G 44G 6.3G 88% /var/lib/docker/overlay2/25621b52617632efeb043f119ed67c0a0b6c8328d7835d11fa74395d0090866d/merged
overlay 50G 44G 6.3G 88% /var/lib/docker/overlay2/4b60531fff0d2eb5abb3569ea4cd03c480b0562071782477a0da0f5bec14062c/merged
overlay 50G 44G 6.3G 88% /var/lib/docker/overlay2/00e04c30d59668fa38acee4cde5ffb17ba4783bc2a43901750199b5d6de309f9/merged
备份home分区所有文件
[root@singlelucky ~]# tar cvf /tmp/home.tar /home
--卸载/home,如果无法卸载,先终止使用/home文件系统的进程--
--最好重启虚拟机,使得虚拟机处于初始状态--
> /home/
> /home/zhaozuozuo/
> /home/zhaozuozuo/.bash_logout
> /home/zhaozuozuo/.bash_profile
> /home/zhaozuozuo/.bashrc
> ;
卸载home分区
[root@singlelucky ~]# yum install psmisc
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.njupt.edu.cn
* extras: mirrors.njupt.edu.cn
* updates: mirrors.njupt.edu.cn
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/primary_db | 63 kB 00:00:00
(2/2): updates/7/x86_64/primary_db | 9.6 MB 00:00:02
正在解决依赖关系
--> 正在检查事务
---> 软件包 psmisc.x86_64.0.22.20-17.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================================================
Package 架构 版本 源 大小
==================================================================================================================================
正在安装:
psmisc x86_64 22.20-17.el7 base 141 k
事务概要
==================================================================================================================================
安装 1 软件包
总下载量:141 k
安装大小:475 k
Is this ok [y/d/N]: y
Downloading packages:
psmisc-22.20-17.el7.x86_64.rpm | 141 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : psmisc-22.20-17.el7.x86_64 1/1
验证中 : psmisc-22.20-17.el7.x86_64 1/1
已安装:
psmisc.x86_64 0:22.20-17.el7
完毕!
[root@singlelucky ~]# fuser -km /home/
[root@singlelucky ~]# umount /home
删除/home所在的lv
[root@singlelucky ~]# 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增加40G,因为home只有账号文件,不存放其他的文件
[root@singlelucky ~]# lvextend -L +40G /dev/mapper/centos-root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 90.00 GiB (23040 extents).
Logical volume centos/root successfully resized.
扩展/root文件系统
[root@singlelucky ~]# 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 23592960
重建home分区
[root@singlelucky ~]# lvcreate -L 2G -n /dev/mapper/centos-home
Logical volume "home" created.
创建文件系统
[root@singlelucky ~]# mkfs.xfs /dev/mapper/centos-home
meta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=131072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=524288, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
挂载home
[root@singlelucky ~]# mount /dev/mapper/centos-home
home备份文件恢复
[root@singlelucky ~]# tar xvf /tmp/home.tar -C/
home/
home/wxl/
home/wxl/.bash_logout
home/wxl/.bash_profile
home/wxl/.bashrc
查看新的磁盘空间分布
[root@singlelucky ~]# df -lh
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 4.7G 0 4.7G 0% /dev
tmpfs 4.7G 0 4.7G 0% /dev/shm
tmpfs 4.7G 13M 4.7G 1% /run
tmpfs 4.7G 0 4.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root 90G 44G 47G 49% /
/dev/sda1 1014M 149M 866M 15% /boot
tmpfs 959M 0 959M 0% /run/user/0
/dev/mapper/centos-home 2G 33M 2G 2% /home
边栏推荐
- Project practice, redis cluster technology learning (16)
- Brief analysis of edgedb architecture
- 2021-10-04
- JS reduce accumulator
- 【UE5】AI随机漫游蓝图两种实现方法(角色蓝图、行为树)
- Junit5 supports suite methods
- [200 Shengxin literatures] 96 joint biomarkers of immune checkpoint inhibitor response in advanced solid tumors
- 2021-10-02
- Blender stone carving
- This article takes you to learn in detail what is fiber to home FTTH
猜你喜欢

2021-10-04

Message mechanism -- getting to know messages and message queues for the first time

JS reduce accumulator
![[ue5] two implementation methods of AI random roaming blueprint (role blueprint and behavior tree)](/img/dd/cbe608fcbbbdf187dd6f7312271d2e.png)
[ue5] two implementation methods of AI random roaming blueprint (role blueprint and behavior tree)

VLAN experiment

Application of rxjs operator withlatestfrom in Spartacus UI of SAP e-commerce cloud

2837xd code generation module learning (2) -- ADC, epwm module, timer0
![[Yu Yue education] University Physics (Electromagnetics) reference materials of Taizhou College of science and technology, Nanjing University of Technology](/img/a9/ffd5d8000fc811f958622901bf408d.png)
[Yu Yue education] University Physics (Electromagnetics) reference materials of Taizhou College of science and technology, Nanjing University of Technology

Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer

Junit5 supports suite methods
随机推荐
JS reduce accumulator
About the college entrance examination
Applet development summary
【Unity3D】制作进度条——让Image同时具有Filled和Sliced的功能
Project practice, redis cluster technology learning (16)
2837xd code generation module learning (2) -- ADC, epwm module, timer0
Alibaba cloud SLS log service
Webui automated learning
Leetcode -- the nearest common ancestor of 236 binary tree
SAP Spartacus express checkout design
How much is it to develop a system software in Beijing, and what funds are needed to develop the software
Blender camera surround motion, animation rendering, video synthesis
【虚幻】武器插槽:拾取武器
【Lua】常见知识点汇总(包含常见面试考点)
Centos7 one click compilation and installation of PHP script
Vscode set JSON file to format automatically after saving
Junit4 runs MVN test test suite upgrade scheme
Deep understanding of redis cache avalanche / cache breakdown / cache penetration
[IDL] Research
Alibaba cloud SMS service