前言,在Linux中由于磁盘使用不恰当,导致空间使用分配合理,但不能随意修改已有资源,只能扩展磁盘
[root@localhost Cloudreve]# df -hl Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.9M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/mapper/centos-root 50G 46G 4.4G 92% / /dev/sda2 1014M 194M 821M 20% /boot /dev/mapper/centos-home 3.6T 53M 3.6T 1% /home tmpfs 783M 0 783M 0% /run/user/0
可以看出,根目录严重不够,home还有3.6T,此时需要home空间到根
先安装,否则使用不了fuser命令
yum install -y psmisc
查看home是否被使用
[root@localhost Cloudreve]# fuser -m /home [root@localhost Cloudreve]#
备份home
[root@localhost Cloudreve]# tar -cvf home.tar home tar: home: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors [root@localhost Cloudreve]# [root@localhost Cloudreve]# tar -cvf home.tar /home tar: Removing leading `/' from member names /home/ /home/shuchengyang/ /home/shuchengyang/.bash_logout /home/shuchengyang/.bash_profile /home/shuchengyang/.bashrc /home/shuchengyang/cloudreve_3.5.3_linux_amd64.tar.gz /home/shuchengyang/Cloudreve-3.5.3.tar.gz
卸载home
[root@localhost Cloudreve]# df -hl Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.9M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/mapper/centos-root 50G 46G 4.3G 92% / /dev/sda2 1014M 194M 821M 20% /boot tmpfs 783M 0 783M 0% /run/user/0
移除逻辑盘
[root@localhost Cloudreve]# lvremove /dev/mapper/centos-home
给根路径分配空间
lvextend -L +450G /dev/mapper/centos-root
lvextend -L +3072G /dev/mapper/centos-root
创建home
[root@localhost Cloudreve]# lvcreate -L 448G -n home centos
[root@localhost Cloudreve]# mkfs.xfs /dev/mapper/centos-home
[root@localhost Cloudreve]# mount /dev/mapper/centos-home /home
还原备份数据
[root@localhost Cloudreve]# tar -xvf home.tar home/ home/shuchengyang/ home/shuchengyang/.bash_logout home/shuchengyang/.bash_profile home/shuchengyang/.bashrc home/shuchengyang/cloudreve_3.5.3_linux_amd64.tar.gz home/shuchengyang/Cloudreve-3.5.3.tar.gz
[root@localhost Cloudreve]# 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@localhost Cloudreve]# lvextend -L +450G /dev/mapper/centos-root Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 500.00 GiB (128000 extents). Logical volume centos/root successfully resized. [root@localhost Cloudreve]# [root@localhost Cloudreve]# lvextend -L +3072G /dev/mapper/centos-root Size of logical volume centos/root changed from 500.00 GiB (128000 extents) to <3.49 TiB (914432 extents). Logical volume centos/root successfully resized. [root@localhost Cloudreve]# 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 936378368 [root@localhost Cloudreve]# [root@localhost Cloudreve]# lvcreate -L 448G -n home centos Volume group "centos" has insufficient free space (32256 extents): 114688 required. [root@localhost Cloudreve]# [root@localhost Cloudreve]# lvcreate -L 31G -n home centos Logical volume "home" created. [root@localhost Cloudreve]# mkfs.xfs /dev/mapper/centos-home meta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=2031616 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=8126464, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=3968, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@localhost Cloudreve]# [root@localhost Cloudreve]# mount /dev/mapper/centos-home /home [root@localhost Cloudreve]# [root@localhost Cloudreve]# df -hl Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.9M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/mapper/centos-root 3.5T 46G 3.5T 2% / /dev/sda2 1014M 194M 821M 20% /boot tmpfs 783M 0 783M 0% /run/user/0 /dev/mapper/centos-home 31G 33M 31G 1% /home [root@localhost Cloudreve]# tar -xvf home.tar home/ home/shuchengyang/ home/shuchengyang/.bash_logout home/shuchengyang/.bash_profile home/shuchengyang/.bashrc home/shuchengyang/cloudreve_3.5.3_linux_amd64.tar.gz home/shuchengyang/Cloudreve-3.5.3.tar.gz [root@localhost Cloudreve]# [root@localhost Cloudreve]# [root@localhost Cloudreve]# df -hl Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.9M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/mapper/centos-root 50G 46G 4.4G 92% / /dev/sda2 1014M 194M 821M 20% /boot /dev/mapper/centos-home 3.6T 53M 3.6T 1% /home tmpfs 783M 0 783M 0% /run/user/0
还没有评论,来说两句吧...