Clean up / filesystem

Devin Teske dteske at vicor.com
Sat Oct 9 18:32:46 UTC 2010


On Oct 9, 2010, at 9:58 AM, Caleb Stein wrote:

> On Fri, 08 Oct 2010 22:46:55 -0700, Robert Huff <roberthuff at rcn.com> wrote:
> 
>> 
>> Caleb Stein writes:
>> 
>>> I'm constantly getting the message, ":/ write failed, filesystem
>>> is full", so I did df, and it said that my / filesystem was at
>>> 108%.  What files can I delete to free some space?
>> 
>> 	Start by checking the contents of /tmp.
>> 	Any *.core in /root you don't recognize is suspect.
>> 	After that?  Try:
>> 
>> 	du -x / | sort -n -r | head -n 40
>> 
>> 	Look in those directories.
>> 
>> 
>> 					Robert Huff
>> 
>> _______________________________________________
>> freebsd-questions at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
> 
> So is it safe to do "rm -rf /tmp/*"?


Generally yes, though it's always safest to check to make sure you're not deleting any files that actively held open by running processes. You can do this by:

	fstat -f /tmp

(or if /tmp is not it's own filesystem -- if it lives on the `/' partition that is)

	fstat | grep /tmp

If you a find a process that has open file descriptors in `/tmp', you can do two things:

1. You can kill the process (the third column in the output of fstat(1) is the process ID or PID). Continue until no processes are left holding open file-descriptors in `/tmp'. Then it would be safe to wipe everything in that directory.

2. You can avoid removing the files that are open. The sixth column in the output of fstat(1) is the inode/inum of the file on the device/mount (the device/mount column is the fifth column, just to the left of the inode/inum column). You can descend into `/tmp' and say `ls -li' to show the inode numbers, or you can say `find /tmp -inum INODE' to find the associated file. You would want to avoid deleting that file because a running process has it open.


In addition, there's an alternative way to clear the temporary files of a system (FreeBSD-5.0 and higher):

	
	(as root or with sudo(8)) sh -c 'clear_tmp_enable=YES; /etc/rc.d/cleartmp start'

NOTE: Unless you've customized your rc.conf(5) files to change the defaults, clear_tmp_enable defaults to "NO" and clear_tmp_X defaults to "YES" (see `/etc/defaults/rc.conf'), so passing a "start" to this rc.d script will (by default) only clear out the X related temporary files located in `/tmp', whereas the above command will get the rc.d script to a full cleanup of `/tmp' (regardless of whether you've customized rc.conf(5) or not).

The rc.d script (cleartmp) _does_ do a slightly more sophisticated clean-up of the `/tmp' directory in that it will not kill-off the `lost+found' directory if it exists, and will also ignore `quota.user'/`quota.group' files. Lastly, it will recreate the X11 socket directories (`.X11-unix', `.ICE-unix', `.XIM-unix', and `.font-unix').

In addition, the above command is better in that it will clean up files beginning with `.' whereas your command which only specified "rm -Rf /tmp/*" won't get files that begin with `.' (of which there may be numerous).

Last but not least, if your system is running XFree86 or Xorg, running either the "rm -Rf /tmp/*" -or- the cleartmp rc.d script is bad while the X server is running since it might cause the running X server to lose its mind (these are lock-files in `/tmp' that shouldn't be removed while the server is running). Again, fstat(1) is your friend. Though, alternatively you could bring the X server down temporarily, clear `/tmp' however you prefer, and then restart the `X' server.

If this is all too overwhelming, you could always safely just clear `/tmp' and then immediately reboot. Or, plop clear_tmp_enable="YES" into rc.conf(5), reboot, and the system will clear `/tmp' for you on boot-up.
--
Devin

(full sig at bottom)




> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"

--
Cheers,
Devin Teske

-> CONTACT INFORMATION <-
Business Solutions Consultant II
FIS - fisglobal.com
510-735-5650 Mobile
510-621-2038 Office
510-621-2020 Office Fax
909-477-4578 Home/Fax
devin.teske at fisglobal.com

-> LEGAL DISCLAIMER <-
This message  contains confidential  and proprietary  information
of the sender,  and is intended only for the person(s) to whom it
is addressed. Any use, distribution, copying or disclosure by any
other person  is strictly prohibited.  If you have  received this
message in error,  please notify  the e-mail sender  immediately,
and delete the original message without making a copy.

-> FUN STUFF <-
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GAT/CS d(+) s: a- C++(++++) UB++++$ P++(++++) L++(++++) !E--- W++ N? o? K- w O
M+ V- PS+ PE Y+ PGP- t(+) 5? X+(++) R>++ tv(+) b+(++) DI+(++) D(+) G+>++ e>+ h
r>++ y+ 
------END GEEK CODE BLOCK------
http://www.geekcode.com/

-> END TRANSMISSION <-



More information about the freebsd-questions mailing list