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.


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.

| improve this answer | |

If we consider /dev/vda and /dev/sdb as different (physical) disks, this is not easily achievable, to the point that it would be much easier to reinstall the server from scratch and put / into a LVM volume from the start.

If absolutely necessary, this could be done with a lengthy downtime and lots of knowledge about what you need to do. It would be quite error-prone though and I would not recommend to even try.

/dev/vda suggests this is some kind of virtual system. Depending on what the underlying system allows, it might be possible to resize the disk image providing /dev/vda (and if necessary, delete/shrink the image providing /dev/sdb). Talk to your admin/provider. In that case, after the system picks of the larger size of /dev/vda, you could extend /dev/vda1 and then grow the / file system.

| improve this answer | |
  • Thank you for your reply. Not sure if you are familiar with digitalocean hosting but /dev/sdb it is just an additional volume I bought to my app. As it is an separate space I need to pass it to my root filesystem. Not sure if it is possible at all. – mike927 Apr 21 '19 at 18:17

Remember that you can mount volumes anywhere on the tree. Without modifying the root file system at /.

Create a LVM volume group then logical volumes out of /dev/sdb, create a file system on that, and mount that where you need the space. For example, this could be for a database, mount it at /var/lib/pgsql. (Your application will be different.)

Specific mount points like this isolate application data from the operating system. Which may make backups or capacity planning easier. At the cost of having to manage more than one file system.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.