---
# System prepended metadata

title: 删掉/home为/扩容

---

# 删掉/home为/扩容

很不幸，我的server空间满了。我没有存储空间了。
我发现装机的时候给/home了100g，都没怎么用。那就给/用吧。

本机系统为`openEuler 24.03Lts`，如您的机器为其它操作系统，请灵活参考。
先看看挂载状态
```bash!
sudo df -h
文件系统                    容量  已用  可用 已用% 挂载点
devtmpfs                    4.0M     0  4.0M    0% /dev
tmpfs                        47G   16K   47G    1% /dev/shm
tmpfs                        19G  861M   18G    5% /run
tmpfs                       4.0M     0  4.0M    0% /sys/fs/cgroup
/dev/mapper/openeuler-root  308G  238G   54G   82% /
tmpfs                        47G   55M   47G    1% /tmp
/dev/sda2                   974M  217M  690M   24% /boot
/dev/sda1                   599M  6.5M  593M    2% /boot/efi
/dev/mapper/openeuler-home   98G  8.6G   85G   10% /home
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/f80eb895c0d61a22e233fa98398323a5cd022c073be1fc8e74c87ea74375163b/merged
shm                         1.0G  421M  604M   42% /var/lib/docker/containers/c3379fd442c0a75604a951e276efbab4c5a987b27b51b17854fe076a13cdedf9/mounts/shm
tmpfs                       9.3G  2.4M  9.3G    1% /run/user/0
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/49f78753cff39c34e3121d091f393183d6e3afa6a5aa6490f7261c2950de5332/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/714c93f64204ae814ddcf2b430de7d386e67136a21e0cc7f603646a2c554a50c/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/eac0e52bc609d26cc613b5cc22dd698c2753657ea3cb09ef4cbf765b4122edb1/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/2b4d23a179ba4e73a82d227b9b5e8b892c599a21f77c68364a756f549f327674/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/dd0f1f8581e6499857700e253a82d3a7cc5bb7b11a48389746e730bc29187aea/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/8b60ebf7a3c0aa13a14a1727157f58931c4e3e0cc429bfcb0b64f2c1047a6dbb/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/1c113f09268de62f70273ee02f9f805f62edbd9911885b1353f6aca0425dad5e/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/f7f07e459a3de16513866deb7f7ff4fdfe9225547b069e95010b8f9c4638a952/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/40a1da14824c2202da3ae5b3bfefd047e0ca60a720feeb26993dfdf27ae4ffcb/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/947596aef10cd92ab248184f0f19cb8949735f0e733456c84e82771b8d0b3a1a/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/14efe5248c9370e2253dd4636d34c5f8e2dc41d0272c9f857f8b59dc09f75385/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/05b3e3bc71f0b3c3ffaba366d0c97cd73148b487c1c095275244e2816ca3c8d1/merged
overlay                     308G  238G   54G   82% /var/lib/docker/overlay2/acc4a4ec0ea4e9e356149de7c06e201d32af3bd5d0d0ec38f7734b44471fdb71/merged
```
## 备份home
```
mkdir -p /root/home_bak
rsync -avh --progress /home/ /root/home_bak/
```
## 删除home
查看/home的占用
```
fuser -vm /home
                     用户     进程号 权限   命令
/home:               root     kernel mount /home
                     root       4152 F..e. java
                     natfrp    975091 ...e. natfrp-service
                     natfrp    979877 ...e. frpc
                     root      1439851 F.ce. java
                     root      1441168 F.ce. java
                     root      1651774 F.ce. java
                     root      1652123 ..c.. soffice.bin
                     root      1652226 ..c.. soffice.bin
                     root      1693143 F.ce. java
                     root      2089643 F.ce. java
```
占用的还挺多的
解除占用
```
fuser -km /home
```
卸载
```
umount /home
```
彻底移除
```
lvremove /dev/mapper/openeuler-home
File descriptor 19 (/root/.cursor-server/data/logs/20250608T134038/ptyhost.log) leaked on lvremove invocation. Parent PID 3399681: /bin/bash
File descriptor 22 (/root/.cursor-server/data/logs/20250608T134038/remoteagent.log) leaked on lvremove invocation. Parent PID 3399681: /bin/bash
File descriptor 24 (/dev/ptmx) leaked on lvremove invocation. Parent PID 3399681: /bin/bash
File descriptor 25 (/dev/ptmx) leaked on lvremove invocation. Parent PID 3399681: /bin/bash
Do you really want to remove active logical volume openeuler/home? [y/n]: y
  Logical volume "home" successfully removed.
```
## 扩容

```
lvextend -l +100%FREE /dev/mapper/openeuler-root
File descriptor 19 (/root/.cursor-server/data/logs/20250608T134038/ptyhost.log) leaked on lvextend invocation. Parent PID 3399681: /bin/bash
File descriptor 22 (/root/.cursor-server/data/logs/20250608T134038/remoteagent.log) leaked on lvextend invocation. Parent PID 3399681: /bin/bash
File descriptor 24 (/dev/ptmx) leaked on lvextend invocation. Parent PID 3399681: /bin/bash
File descriptor 25 (/dev/ptmx) leaked on lvextend invocation. Parent PID 3399681: /bin/bash
  Size of logical volume openeuler/root changed from 313.00 GiB (80128 extents) to 413.00 GiB (105728 extents).
  Logical volume openeuler/root successfully resized.
```

```
lsblk -f
NAME               FSTYPE      FSVER    LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                                 
├─sda1             vfat        FAT32          4C4C-3E0C                               592.3M     1% /boot/efi
├─sda2             ext4        1.0            1301dcb7-5c02-448d-8ab9-351282efea34    689.7M    22% /boot
└─sda3             LVM2_member LVM2 001       FYmI3w-INHw-UBkk-dnht-LOON-IrR5-RAHnwJ                
  ├─openeuler-root ext4        1.0            4a5fe334-965f-45a9-91d9-4af4e589fa4e     53.5G    77% /
  └─openeuler-swap swap        1              d48ac596-1941-4691-b4c6-6c4c27119481                  [SWAP]
```
文件系统格式是ext4

```
resize2fs /dev/mapper/openeuler-root
resize2fs 1.46.4 (18-Aug-2021)
/dev/mapper/openeuler-root 上的文件系统已被挂载于 /；需要进行在线调整大小

old_desc_blocks = 40, new_desc_blocks = 52
/dev/mapper/openeuler-root 上的文件系统现在为 108265472 个块（每块 4k）。

```
看看扩容上没
```
df -h /
文件系统                    容量  已用  可用 已用% 挂载点
/dev/mapper/openeuler-root  406G  238G  148G   62% /
```

扩容成功了
## 恢复数据
创建/home,并复制备份文件过来
```
mkdir /home
rsync -avh /root/home_bak/ /home/
```
验证下恢复状况
```
ls -l /home
du -sh /home

```
如果输出没问题，那就对了
删除备份
```
rm -rf /root/home_bak
```
## 持久化
去看看fstab,删除多余的home挂载
```
nano /etc/fstab
```
找到`/dev/mapper/openeuler-home /home                   ext4    defaults        1 2`
改为`#/dev/mapper/openeuler-home /home                   ext4    defaults        1 2`
保存退出

完全免费社工库
下山虎社工库
https://t.me/MTTigerSGK
#社工库 #免费社工库