今天本地的一台服务器根目录占用显示为100%,查了一下,还是暂时先把home目录下的一部分划给/目录
一、目录占用查看
可以看到红色部分的/目录占用为100%,而绿色部分的/home下还有865G,虽然不建议划给/目录,但还是想快速处理一下
二、备份
# mkdir /tmp/home
# cp -r /home/* /tmp/home
三、卸载
[root@aaa ]# umount /home
umount: /home: target is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
卸载过程中出现了target is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
那我们先解除占用
[root@aaa ]# fuser -mv -k /home
USER PID ACCESS COMMAND
/home: root kernel mount /home
git 1447 F.ce. gogs
再次卸载,查询,就会发现已经卸载
[root@aaa ]# umount /home
[root@aaa ]# df -h
三、调整分区
按照以前的resize2fs方式来卸载分区,报了个错
[root@aaa ]# resize2fs -p /dev/mapper/centos-home
e2fsck 1.42.9 (28-Dec-2013)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/mapper/centos-home
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
查了一下,文件系统是xfs,不支持resize2fs,所以换一种方式
[root@aaa ]# cat /etc/fstab | grep centos-home
/dev/mapper/centos-home /home xfs defaults 0 0
删除home的逻辑卷
[root@aaa ]# lvremove /dev/mapper/centos-home
Do you really want to remove active logical volume centos/home? [y/n]: y
Couldn't create temporary archive name.
还是有一些问题,是因为/为100%,满了,所以需要删一些东西才能释放
删除逻辑卷,重新调整/的大小,刷新xfs,把剩下的划分到/home中
[root@aaa ]# lvremove /dev/mapper/centos-home
Logical volume "home" successfully removed
[root@aaa ]# lvextend -L 365G /dev/mapper/centos-root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 365.00 GiB (93440 extents).
Logical volume centos/root successfully resized.
[root@aaa ]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks
= sectsz=4096 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=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 95682560
格式化分区,mount装载,查看
[root@aaa ]# lvcreate -l +100%free -n home centos
Logical volume "home" created.
[root@ayc local]# mkfs.xfs /dev/mapper/centos-home
meta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=36033024 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=144132096, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=70377, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
mount /dev/mapper/centos-home /home
[root@aaa ]# mount /dev/mapper/centos-home /home
[root@aaa ]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 20K 16G 1% /dev/shm
tmpfs 16G 795M 15G 5% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/mapper/centos-root 365G 50G 316G 14% /
/dev/sda1 1014M 205M 810M 21% /boot
tmpfs 3.2G 12K 3.2G 1% /run/user/42
tmpfs 3.2G 0 3.2G 0% /run/user/0
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/81f0e164187b58b5a6f86e14f573fd1b8971a7b013cd9a9b2f00b34ca4427c62/merged
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/199e2290380e1820ff43ec0603010930cb45998392719fdc10ff4bfb7d2205a6/merged
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/ca1b3a953378767f0fe4510617b3162abe2165f72aa3de20595ae860ea0d9466/merged
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/3408eb97e4b4aac2956f6e67cec14334e11dfc5d677025a20d607a1f4ea883a3/merged
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/4740e11acbe59cae037c4da113e0382e95b465b02cda081b0086102c9a28911a/merged
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/7b331ea8c4ea05f2d7a55c59e8da35c23b3d8ed6adff3ec742a93f5cff388d33/merged
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/cb138904b6c6b96a8112a0b41278dea5cae4b8e4e736052a961362248297f0d8/merged
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/ba061d20b9d880a341fd2bfff961979ffbdec01ef0f081a13c15273c7f80efd4/merged
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/25c4efcfe602b6e3e6c161cefec067bd5fbf456258fa5379eece87de21db606e/merged
overlay 365G 50G 316G 14% /var/lib/docker/overlay2/f01ef666ef64b484e40b518a663a3e5ad9c51b6a175680135ba6e0e27d2e599e/merged
/dev/mapper/centos-home 550G 33M 550G 1% /home
恢复备份就ok啦
# cp -r /tmp/home* /home/