大网数据广告活动
服务器运维问答

How to resize main filesystem

· 52CE 我爱测

on my centos server I mounted a new volume /dev/sdb . I would like to add space to root filesystem /dev/vda1 . [user@prod current]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 30G 11G 18G 37% / devtmpfs 488M 0 488M…

问题原文

原帖链接 · mike927 · CC BY-SA 4.0

on my centos server I mounted a new volume /dev/sdb. I would like to add space to root filesystem /dev/vda1.

[user@prod current]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        30G   11G   18G  37% /
devtmpfs        488M     0  488M   0% /dev
tmpfs           497M     0  497M   0% /dev/shm
tmpfs           497M   50M  447M  11% /run
tmpfs           497M     0  497M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user/1000
/dev/sdb         50G   53M   47G   1% /mnt/volume_nyc3_01

Is there any way to decrease /dev/sdb and increase /dev/vda1? If possible without losing data on /dev/vda1.

已采纳解答

原帖链接 · mdfst13 · CC BY-SA 4.0

I very much doubt that this is literally possible. But what you could do is move files or folders from /dev/vda1 to /dev/sdb and then make them appear in the same place on /dev/vda1 afterward. This would have the effect of increasing the available space on /dev/vda1.

For example, a simple solution would be to move the contents of /var, /home, /opt, or /usr to /dev/sdb and then mount /dev/sdb as whichever folder you moved. That is a pretty common way to handle this. Be careful with /sbin and /root, as they may need to exist before /dev/sdb is mounted in your setup. You would do this by changing the fstab (which may be done via a tool in your setup).

You could also partition /dev/sdb (I presume). Then you could mount it as more than one directory. This would involve adding entries to the fstab.

A third option would be to move the files from /dev/vda1 to /dev/sdb and then symlink them such that they appear in the same place in the file structure. You would often put these symlinks at the folder level. E.g. something like

ln -s /mnt/volume_nyc3_01/usr /usr

You would do this as root (possibly with sudo). This would allow you to put arbitrary folders or files on /dev/sdb while still accessing them at the same place in the file system. I presume you already know how to use du to find which files and folders are taking up the most space.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-04-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。