# Freeing up space in /var



## lfloyd (Feb 26, 2011)

{n00b questions}

Today I discovered that /var maxed out (i.e., 100% full).  The space hogs were MySQL database files and the contents of /var/db/pkg/.  So I did this to move the database files:

`# /usr/local/etc/rc.d/mysql-server stop`
`# cd /var/db`
`# mv mysql /usr/local/`
`# ln -s /usr/local/mysql mysql`
`# cd /usr/local`
`# chown -R mysql mysql`
`# /usr/local/etc/rc.d/mysql-server stop`

And this to move the pkg files:

`# cd /var/db`
`# mv pkg /usr/local/`
`# ln -s /usr/local/pkg pkg`

Then, back in /var I run `# du -sk *` and things look a LOT better.  However, when I run `# df`, it still shows that /var is (nearly) full.  I looked at `# man df` to see if it follows symbolic links, but I couldn't determine if it did.

So, two questions come from today's activities:

1.  Did I "properly" move the database and pkg files?  Is this a "best practice"?
2.  Can `# df` report usage without following links?

Thanks!

- Larry


----------



## Fred (Feb 27, 2011)

Did you stop MySQL before moving the files ? If you didn't, as the files are still opened by MySQL, the space they use on disk will not be reclaimed.


----------



## lfloyd (Feb 27, 2011)

Yes...

`# /usr/local/etc/rc.d/mysql-server stop`
snip
`# /usr/local/etc/rc.d/mysql-server stop`

And MySQL started back up with no complaints.


----------



## Galactic_Dominator (Feb 27, 2011)

lfloyd said:
			
		

> Then, back in /var I run `# du -sk *` and things look a LOT better.  However, when I run `# df`, it still shows that /var is (nearly) full.  I looked at `# man df` to see if it follows symbolic links, but I couldn't determine if it did.


http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/disks.html#DU-VS-DF


----------



## lfloyd (Feb 27, 2011)

Okay... I understand now.  I did the quick and dirty method: `# reboot`

Now everything appears in order.  I ordinarily don't like rebooting, but this server is just a week old and isn't used by many people yet.

Thanks!


----------



## Galactic_Dominator (Feb 27, 2011)

lfloyd said:
			
		

> Okay... I understand now.  I did the quick and dirty method: `# reboot`



Quick and dirty is right.  Use `# shutdown -r now` for proper procedure.  reboot() is only safe for use in single user mode.


----------

