How can I increase the size of my /var und shrink it from /home or other patition?

7,355

Some filesystems allow hot (as in during operation) size adjustments (expand & shrink), others do not, and I can't comment on your fs (filesystem) as I don't know what it is (nor your host-image or host service sorry).

There are other ways to accomplish your desired result anyway; from links (hard ideally, soft if desired; ln command), but for some uses this is easy, others no so, and I don't fully know what you need.

Another solution requiring less work is to create a directory in your /home that is then mounted to an appropriate directory in your existing structure with something like

mkdir /home/space mount --bind /home/space /wherever/youneed/thespace

note: i'm ignoring permissions as I don't know what you'll require; which may be as little as sudo for each command, plus of course your testing to ensure it'll work with your use-case. This will only work if the /wherever/youneed/thespace is useful to you, so adjust to suit your needs

Share:
7,355

Related videos on Youtube

Crypto
Author by

Crypto

Updated on September 18, 2022

Comments

  • Crypto
    Crypto over 1 year

    first of all I'm a newbie with ubunutu servers or generell with linux. So I'll be glad if someone can explain it very simple. ^^'

    My Server is a Ubuntu 16.04 LTS Server 64bit + Plesk Onyx from Strato (German Hoster).

    I've the problem that my FTP webspace is on my /var directory and I've just 70GB on this /var of 2*240GB SSD.

    Unfortunately the server was preset with the webinterface installation (however I've a dedicated server).

    My /home on the one hard disk of 240GB has 118GB and I'm still using 500MB ... Can I shrink this /home for example to 25GB and give the 'free space' my /var? (If it's possible without shutting down the server?)

    Hopefully I've explained my problem well enough. I hope anyone can give me accurate instructions to do this task. :|

  • Crypto
    Crypto almost 7 years
    My goal is to increase the size of my /var directory. Because my FTP is under: /var/www/vhosts/ ... My problem is that my space in /var is limited to 70GB and I already have ~25GB in use and it will be more. Or if there is another way to 'give' my FTP more space, it will also be welcome. (Filesystem is ext4)
  • guiverc
    guiverc almost 7 years
    cp -pvr /var/www/vhosts/* /home/space; mount --bind /home/space /var/www/vhosts then assuming all of /var/www/vhosts will fit in your /home; and the data will then be stored in /home/space on the space partition|drive. adjust to fit you circumstances. ie. any limitations can be overcome
  • guiverc
    guiverc almost 7 years
    what my last cp ..;mount --bind is about is (1) copy data from your directory to a created directory on your /home partition or drive; then you mount that directory somewhere you'll use it. if it's mounted where you already have files/directories, it'll "hide" the real files until you umount (unmount). its more of a 'hack', with the expectation you'll adjust to suit your needs