how to cleanup root file system

General support questions including new installations
zogthegreat
Posts: 36
Joined: 2007/11/26 14:09:20
Location: Montreal, CANADA
Contact:

how to cleanup root file system

Postby zogthegreat » 2010/01/31 23:00:07

Hi everyone;

I have a problem that is probably simple, but have not yet found the answer on any forums or by Googling. First my system specs:

Tyan 2610 motherboard w/ 2 x PIII 933
4 gig PC133 SDRAM
1 x 5 gig hd (system)
4 x 500 gig hds w/ 3Ware 7500 controller set to RAID 5, (1.5 TB) mounted as /home
CentOS 5.3 running my smb and nfs mounts

My problem is that I have run out of space on my / (root) file system, (the 5 gig). Since I am planing to rebuild my file server with larger hard drives, (2 x's 60 gig SATA's set to RAID 1, 6 x's 1.5 TB at RAID 5), within the next 2 months, I would like to try to clean out any unneeded crap rather than adding a hard drive and expanding my root file system. I have done the following:

Removed old unused kernels
cleaned up /var/log/
cleaned up /tmp

I have tried to check my disk space usage with the following commands: (output included)

Code: Select all

[root@hydra]$  df -h
\Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      3.9G  3.2G  490M  87% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                 1.5G     0  1.5G   0% /dev/shm
/dev/sdb1             1.4T  1.1T  340G  76% /home

[root@hydra]$  du -ks /var/* | sort -nr | head
75556   /var/cache
60136   /var/lib
31296   /var/log
30364   /var/clamav
18380   /var/spool
9640    /var/www
224     /var/run
84      /var/webmin
36      /var/lock
32      /var/empty

[root@hydra /]$  du --max-depth=1 -x -h /
8.0K    /selinux
0       /misc
8.0K    /mnt
78M     /lib
0       /net
0       /proc
128M    /etc
8.0K    /media
132M    /opt
5.3M    /root
194M    /var
2.7G    /usr
84K     /tmp
29M     /sbin
8.0K    /srv
4.0K    /home
0       /sys
7.2M    /bin
2.0K    /boot
16K     /lost+found
0       /dev
3.2G    /

Going into my /usr and running du --max-depth=1 -x -h / gives me this:

[root@hydra usr]$  du --max-depth=1 -x -h /
8.0K    /selinux
0       /misc
8.0K    /mnt
78M     /lib
0       /net
0       /proc
128M    /etc
8.0K    /media
132M    /opt
5.3M    /root
194M    /var
2.7G    /usr
84K     /tmp
29M     /sbin
8.0K    /srv
4.0K    /home
0       /sys
7.2M    /bin
2.0K    /boot
16K     /lost+found
0       /dev
3.2G    /


I have gone through /var/cache and and /var/log and deleted anything that I felt would not break my OS by deleting, I did not touch /usr yet, (I want to do more research before tampering there!!), but I am still getting this error:

[root@hydra VM Ware]$ rpm -ivh VMware-server-2.0.2-203138.i386.rpm
Preparing... ########################################### [100%]
installing package VMware-server-2.0.2-203138.i386 needs 233MB on the / filesystem

Does anyone have any suggestions on how I can clean up about 300 MB more of disk space?

Thanks

zog
[ Moderator edit: Added code tags to improver readability. ]

User avatar
AlanBartlett
Forum Moderator
Posts: 9317
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: how to cleanup root file system

Postby AlanBartlett » 2010/02/01 14:09:12

132M /opt

I wonder what you have in your /opt directory?

I'll toss this idea into the thread and see if anyone would like to comment --

Suppose you copy the contents of both the /var/ and /opt/ directories to your /home/ directory (i.e. create populated /home/var/ & /home/opt/ directories), boot the install medium into rescue mode (or use a LiveCD), delete both of your true /var/ & /opt/ directories and replace them with symlinks to /home/var/ & /home/opt/ respectively?

If it works, you should be able to gain ~300 MB in your root file system.

cry4dawn
Posts: 108
Joined: 2009/09/23 01:48:56

Re: how to cleanup root file system

Postby cry4dawn » 2010/02/01 14:42:39

I see no problem with opt but with I had problems the other day (help moving /var) With selinux permisions with the latest version of selinux policies from centos.

pjwelsh
Posts: 2589
Joined: 2007/01/07 02:18:02
Location: Central IL USA

Re: how to cleanup root file system

Postby pjwelsh » 2010/02/01 15:27:13

Lets more closely address the "how to cleanup..." question. Your output comes close to helping, for example, as root, run (assuming "/" is the problem mount point):

Code: Select all

du -x /|sort -rnb|more

In your case, /var/cache is big, but what is making it big? Assuming /var/cache is where you want to focus:

Code: Select all

find /var/cache -type f -size +2048 -mount -exec ls -lad {} \; |sort -rnb -k 5|more

If you have done a recent CentOS update, you should like consider running

Code: Select all

yum clean all
to free up some space.
The first 2 commands are adaptable to any dir or size limitations.

To address the moving of /var or other file system, I would suggest the "rsync" command. Something like "rsync -avP SOURCE DEST". Make sure to read the man page to figure out the difference in trailing "/" or no slash!

User avatar
TrevorH
Forum Moderator
Posts: 22566
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: how to cleanup root file system

Postby TrevorH » 2010/02/02 00:13:49

Where is your / partition located? You said it's on a 5GB disk but I've never heard of such a thing - common sizes were 4GB, 6.4GB and 9GB and you have to go back a long way to find one of those (though I guess P-III 933MHz are of the same vintage as that sort of size disk). So are you sure there is no space available on that first disk? The output of `fdisk -l` might help. Also, since your / partition is an LVM volume, perhaps there is more space available in the volume group? Output from `vgdisplay` would help answer that too.

zogthegreat
Posts: 36
Joined: 2007/11/26 14:09:20
Location: Montreal, CANADA
Contact:

Re: how to cleanup root file system

Postby zogthegreat » 2010/02/05 20:53:59

Hi everyone,

First, Wow! Thanks for all of the responses! Sorry about the delay in my reply, I have been sick with a lung infection for the last week, (the joy's of living in Montreal, low crime, because it's too bloody cold for even criminals!!!). I will try to answer everyone's questions even though I have found the answer already, here we go:

TrevorH wrote:
Where is your / partition located? You said it's on a 5GB disk but I've never heard of such a thing - common sizes were 4GB, 6.4GB and 9GB and you have to go back a long way to find one of those (though I guess P-III 933MHz are of the same vintage as that sort of size disk). So are you sure there is no space available on that first disk? The output of `fdisk -l` might help. Also, since your / partition is an LVM volume, perhaps there is more space available in the volume group? Output from `vgdisplay` would help answer that too.


Hi TrevorH,

Your question answered my problem, the output of fdisk -l is as follows;

[root@hydra ~]$ fdisk -l

Disk /dev/sda: 6495 MB, 6495068160 bytes
255 heads, 63 sectors/track, 789 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 789 6233220 8e Linux LVM

Disk /dev/sdb: 1500.3 GB, 1500317024256 bytes
64 heads, 32 sectors/track, 1430813 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 1430813 1465152496 83 Linux


Don't know why I thought I had a 5 gig, however AlanBartlett's comment:

AlanBartlett wrote:
132M /opt

I wonder what you have in your /opt directory?


made me think, so I did the following:

[root@hydra ~]$ rpm -qa
pkgconfig-0.21-2.el5
beecrypt-4.1.2-10.1.1
zlib-devel-1.2.3-3
libXdmcp-1.0.1-2.1
libattr-devel-2.4.32-1.1
checkpolicy-1.33.1-4.el5
libpfm-3.2-0.060926.4.el5
.....
.....
sudo-1.6.9p17-3.el5_3.1
acpid-1.0.4-7.el5_3.1
sos-1.7-9.16.el5_3.5
prelink-0.4.0-2.el5
audit-1.7.7-6.el5_3.3
rpm-libs-4.4.2.3-9.el5
kudzu-1.2.57.1.21-1.el5.centos
cups-1.3.7-8.el5_3.6
intltool-0.35.0-2
dvd+rw-tools-7.0-1.el5
festival-1.95-5.2.1
libgsf-1.14.1-6.1
hal-cups-utils-0.6.2-5.2.el5
gnome-media-2.16.1-3.el5
file-roller-2.16.0-2.fc6
urw-fonts-2.3-6.1.1
gnome-backgrounds-2.15.92-1.fc6
NetworkManager-0.7.0-9.el5
gnome-python2-gnomeprint-2.16.0-3.el5
gimp-print-utils-4.2.7-22.2.el5
gkrellm-2.2.7-0.el5.rf

So obviously, I have Gnome desktop installed! At this point, I would like to pause and state that I am not a total idiot, (I actually been involved with technoloy for about 20 years, just not with Linux!!), however, I can offer no explanation on how I installed my SMB server with a GUI and forgot!!

I have started to remove some gnome packages that I don't think will break anything, (gnome-backgrounds, NetworkManager, gnomeprint, gimp-print-utils, gkrellm, etc.

Thanks to everyone for helping me sort this out. Maybe I should make a list of everything that I am installing on the new server, and keep it in the server case, so that I won't have a similar problem a year from now!!

zog

btw, for informational purposes, this is my uptime on this server..

[root@hydra ~]$ uptime
15:51:36 up 268 days, 18:38, 3 users, load average: 0.70, 0.68, 0.45

Once again, Linux Rocks!!

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: how to cleanup root file system

Postby pschaff » 2010/02/05 21:30:37

zogthegreat wrote:
...
[root@hydra ~]$ uptime
15:51:36 up 268 days, 18:38, 3 users, load average: 0.70, 0.68, 0.45
...


Uptime is great, but it indicates that you must be running a kernel with known security problems. Might want to schedule an update/reboot.

Thanks for reporting back and glad you're feeling better. You must have sent some of that Montreal weather down to Virginia - We're getting more cold/snow than we have in a decade! :-)

zogthegreat
Posts: 36
Joined: 2007/11/26 14:09:20
Location: Montreal, CANADA
Contact:

Re: how to cleanup root file system

Postby zogthegreat » 2010/02/06 03:06:42

Hi pschaff,

If I could ask a question about the updates. I have not been updating this server due to the fact that it is only on my home network and the firewall, (iptables), is set to only allow ssh, smb and nfs traffic from the local area.

I know on a Windows machine to fail to update is BAD, but on a Linux box, when configured in this manner, is it really "necessary" to due regular kernel updates?

My reason for not doing update is that I didn't want a kernel update messing up anything, (i.e. if it is working, don't mess with it unless you need to). Even though I only use this machine for my local network, when I need my data on the server, I NEED THE DATA!!

As for your weather, I don't understand, your only getting between 20" and 30". Honestly, thats not that much! (Believe it or not, I was actually born in California and grew up in Arizona, think I have been up here way to long!). Hope you can stay inside during the storm and you don't lose power, (or even worse, Internet!). Stay safe and be careful shoveling you driveway. Also, avoid fools who think they can drive in that kind of storm!

zog

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: how to cleanup root file system

Postby pschaff » 2010/02/06 13:24:16

Even on a well-secured home network (which I also run) I'm a stickler for updates - which provide bug-fix as well as security patches. If a kernel causes an issue you can easily fall back to the next earlier version at boot time. If you want to keep more versions around that can be configured, but is contrary to the original objective of the thread. If you get too far behind in updates it tends to be problematic when you do find the need. My $0.02 - (US$ and CDN$ are not too different :-) ) is stay up to date; however, I understand if it ain't broke...

As far as the weather - etc. I'm also a transplanted SouthWesterner and grew up driving in the mountains in a day when 50"+ was not as unusual as it is in the 21st century, and we have plenty of those drivers in coastal VA who never learned to deal with the white stuff well. Now if all that salty water out back, that's looking like high tide even though it's time for low. will leave my house alone this time around we'll deal with the snow! Cheers. :pint: