4

First question:

When I run df -h I can see this:

# df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ad4s1a    9.7G    8.0G    918M    90%    /
devfs          1.0K    1.0K      0B   100%    /dev
/dev/ad4s1d    1.8T    6.7G    1.6T     0%    /home
procfs         4.0K    4.0K      0B   100%    /proc
linprocfs      4.0K    4.0K      0B   100%    /usr/compat/linux/proc
devfs          1.0K    1.0K      0B   100%    /var/named/dev

Why doesnt it show directories like:

/var /etc /usr

? On my earlier dedicated server, I was able to view every partition size available, but here I got only /home and /...

Second question:

How I can increase the /var partition size? Because after 2 hours of working, this partition is became full...

5 Answers 5

7

The df command reports disk space usage by file system. Your /var /etc and /usr are not separate file systems, they are part of the / file system. You only have 2 file systems, / and /home.

If you can reinstall the system you could change the partitions to create a /var file system of a suitable size.

If you can't then you could try creating a link /var ->/home/var but the specifics of how to do this depend on the access you have to the system.

0
4

Why doesnt it show directories like:

Because they don't have their own file system on this machine, but are subdirectories of /.

On my earlier dedicated server, I was able to view every partition size available, but here I got only /home and /...

Because you only have those, presumably.

How I can increase the /var partition size? Because after 2 hours of working, this partition is became full...

Youy can't, because you don't have a /var partition.

If you add another disk, you could move all the stuff under /var to this disk and mount it as /var.

Edit: I just saw that /home/ is nearly empty. So, move all your stuff under /var to /home/var and replace /var by a symlink there. It's possible that you may need to do this in single-user mode or from a rescue system.

3
  • Its a dedicated server. I need more size under the /var directory, basicly for the mysql. If I cant increase the partition size, I guess I'll have to change the default mysql directory from /var/db to the something like /home/db ?
    – Cyclone
    Mar 14, 2012 at 22:38
  • Either my approach from the edit or yours will work, but I would move just the MysQL directory if I need to avoid downtime to the rest of the system since this can be done with just shutting down MySQL, move the data over and symlink or reconfigure the data dir.
    – Sven
    Mar 14, 2012 at 22:41
  • @SvenW fBSD will keep humming along if you destroy the /var folder, can't speak for whatever daemons/programs he's go running, but the OS doesn't need to be in single-user mode or anything special.
    – Chris S
    Mar 16, 2012 at 13:58
4

As mentioned above, you can't increase /var as far as it is not a seperate FS. But you can move it from / to larger FS like /home. The only suggestion - use dump/restore to move current content of /var to new location instead mv or tar voodoo. That saves not only ownerships and permissions but also so-called 'flags' like schg/uchg for /var/empty. Also, I want to prevent you from creating hardlink /home/var -> /var as far, as /home and / are on different partitions. Generally all can be done this way:

  # mkdir /home/var
  # cd /home/var
  # dump 0af - /var | restore rf -
  # chflags -R nouchg,noschg /var
  # rm -r /var
  # ls -s /home/var /var

Sure, all above needs single-user mode or, if it's unavailable, you first have to stop all daemons that uses /var - like sendmail or mysql.

The other good practice - move out not the whole /var but only dirs that tends to grow. Such are /var/db/mysql, /var/log and /var/mail. I prefer to create a seperate homes for them - /usr/home/log, /usr/home/mysql and /usr/home/mail and so on. Thus dirs are linked to their usual locations in /var to prevent software configuratons.

1
  • dump works on filesystems, not directories, so this won't work. You could, however, use a tar pipeline instead. Mar 16, 2012 at 22:03
2

I would take a slightly different approach to what's been proposed so far, simply because I don't like symlinking inside /var. As before, create a new directory under /home to hold the data you want to move, and copy the data across.

You can use a nullfs mount point to mount the real directory (e.g., /home/var/db/mysql) to the location the software expects it:

mount -t nullfs /home/var/db/mysql /var/db/mysql

In /etc/fstab, you'd want this:

/home/var/db/mysql  /var/db/mysql  nullfs  rw   0    0

Note that for this approach to work, you need either options NULLFS in your kernel, or you need to have the nullfs kernel module available.

As far as the system is concerned, it can access the contents of /home/var/db/mysql through /var/db/mysql exactly as normal. This approach also means that utilities like stat(1) and realpath(1) will report paths as being under /var, and not under /home/var.

2

You can do this by using the simple command.

Please note below commands only allocate free space to VAR folder only.

First, check disk space using the below command

df -h

Filesystem              Size  Used Avail Use% Mounted on
/dev/mapper/system-var  9.1G  4.1G  4.5G  48% /var

Now run the below command to check free space

root@abc: vgs
VG     #PV #LV #SN Attr   VSize  VFree
system   1   6   0 wz--n- 79.52g 28.30g

It shows free spaces in the system, and run below command to increase size

lvextend -L +1G /dev/mapper/system-var

this command will increase 1 GB space in VAR folder

Extending logical volume var to xxx.xx GiB

Logical volume var successfully resized

Now run below command

resize2fs /dev/mapper/system-var

Now check VAR folder size bu running the below command

df -h

Output will be

Filesystem              Size  Used Avail Use% Mounted on
/dev/mapper/system-var   11G  4.1G  5.5G  43% /var

Hope this will work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .