当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
SAP Spartacus express checkout design
Post disaster reconstruction -- Floyd thought
[unreal] animation notes of the scene
阿里云SLS日志服务
2021-09-12
ue4材质的入门和原理笔记
Leetcode -- the nearest common ancestor of 236 binary tree
【避坑指南】使用UGUI遇到的坑:Text组件无法首行缩进两格
Summary of demand R & D process nodes and key outputs
Spatial interpretation | comprehensive analysis of spatial structure of primary liver cancer
Commutateur Multi - lentilles Blender
Postman -- use
pytest框架实现前后置
Metaclass type and using metaclass to implement model class ORM
【Unity3D】无法正确获取RectTransform的属性值导致计算出错
Remember the use of add method once
【Unity3D】制作进度条——让Image同时具有Filled和Sliced的功能
A model can do two things: image annotation and image reading Q & A. VQA accuracy is close to human level | demo can be played
Ctrip starts mixed office. How can small and medium-sized enterprises achieve mixed office?
虛幻AI藍圖基礎筆記(萬字整理)