LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-13-2012, 03:02 PM   #1
mlmack
LQ Newbie
 
Registered: Mar 2011
Posts: 15

Rep: Reputation: 1
need to clean up root partition


Am running opensuse 11.3. In the past few months the root partition has gone from 40% full to 97% full. It's 27G, which seemed like a lot at the time. Is there a tool to clear out the garbage? If not, can someone tell me how to do it by hand? Please keep it simple but detailed.
 
Old 01-13-2012, 03:16 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi mlmack,

I would suggest you to first find out the files that are using up the space on / . We cannot just delete the files which are needed by the system. Run the following commands which will help you to find out the files that are using up the space:

1.
Code:
 cd /
2.
Code:
du -ah | sort -nr > /root/list
I will explain the du command part. du command will list out all the files which are under / and display them in human readable format that is in bytes and KBs (h). We are then piping the output of this command to be sent to sort -nr where we are performing numeric sort in reverse order so that it will arrange the big files at top. The output of sort is then redirected to /root/list file where you can see the list of the files which are using up the space with bigger files at top.
 
Old 01-13-2012, 03:35 PM   #3
mlmack
LQ Newbie
 
Registered: Mar 2011
Posts: 15

Original Poster
Rep: Reputation: 1
Thanks for answering so quickly. I went to su and ran the command. The response was
du: cannot access `./.gvfs': Permission denied If permission is denied to root, what next. BTW, I understand that I can't just hack at it. That's why I asked for help.
 
Old 01-13-2012, 03:41 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Run su - root instead of su as su command does not import the root user PATH.
 
Old 01-13-2012, 03:53 PM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
du: cannot access `./.gvfs': Permission denied If permission is denied to root, what next.
http://forums.opensuse.org/english/g...nied-gvfs.html
Most common reasons for root filing up:
logfiles in /var/log and old kernels.

Kind regards

Last edited by repo; 01-13-2012 at 04:07 PM.
 
Old 01-13-2012, 03:59 PM   #6
celthunder
Member
 
Registered: Feb 2009
Location: Newton, WI
Distribution: Arch
Posts: 84

Rep: Reputation: 8
not sure in opensuse but in arch and a few others package files downloaded are saved in /var/cache those you can usually delete once installed. Not sure if that's mounted seperately or not for you or if they're stored at all in your distrobution. Hope that helps
 
Old 01-13-2012, 04:28 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
at this point i would not bother cleaning out /
OpenSUSE 11.3 will hit it's "End Of Life" in 3 days

on Jan 16 it dies

please stay current and install 12.1

11.4 hits End of life on "September 15th 2012
see
http://en.opensuse.org/Lifetime

I am betting that /var/log is huge and you have not set up cron to clean it out .
Also have a look at /tmp ,and set up cron to clean that out .
 
1 members found this post helpful.
Old 01-13-2012, 05:07 PM   #8
mlmack
LQ Newbie
 
Registered: Mar 2011
Posts: 15

Original Poster
Rep: Reputation: 1
To respond to all at once:

Running 'su root' makes no difference.I get: "du: cannot access `./.gvfs': Permission denied" either way.

cleaning out /var and /tmp helped a lot but not enough.

How do I clean out old kernels?

I'd rather not upgrade because I'm old (61) and set in my ways. I like what I have and don't want to go through a bunch of contortions to get it back. If possible at all.
 
1 members found this post helpful.
Old 01-13-2012, 05:19 PM   #9
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
it is not " su root"
it is " su -" a dash

there is a very big difference in " su " and " su - "

be warned there will NEVER be a update to firefox in 11.3 after the 16'th
there will NEVER be any security fixes
there will NEVER be any new programs and NO updates to the ones installed
11.3 will be dead
 
Old 01-13-2012, 05:22 PM   #10
JDebianV
Member
 
Registered: Nov 2010
Posts: 36

Rep: Reputation: 1
open source GUI tool - Bleach Bit can be used to free up disk space -

http://bleachbit.sourceforge.net/

They have Linux platforms w/ DL for Open Suse

Easy to use-

If you used a package manager to install kernels, they can be removed likewise.
 
Old 01-13-2012, 07:11 PM   #11
mlmack
LQ Newbie
 
Registered: Mar 2011
Posts: 15

Original Poster
Rep: Reputation: 1
Once I got su straight, "du -ah | sort -nr > /root/list" returned to the prompt with no output.

Bitbleach may be useful but made no difference in this case.

If old kernels can be removed with yast, I can't figure out how.
 
Old 01-14-2012, 01:51 AM   #12
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
Once I got su straight, "du -ah | sort -nr > /root/list" returned to the prompt with no output.
The output is in the file
Code:
/root/list
Code:
If old kernels can be removed with yast, I can't figure out how.
http://www.cyberciti.biz/faq/debian-...ernel-command/

Kind regards
 
Old 01-14-2012, 12:39 PM   #13
mlmack
LQ Newbie
 
Registered: Mar 2011
Posts: 15

Original Poster
Rep: Reputation: 1
The kernel link looks like it'll do it. My thanks to you all.
 
Old 01-15-2012, 02:15 PM   #14
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Rep: Reputation: 59
Hi!


Please log-in using your User Name / ID as you would usually and then change your log-in to that of root:

Code:
[demo@localhost bin]$ su - root
Password: 
[root@localhost ~]#
Please, note that hyphen "-" in between "su" and "root" separated by a space.

A simple note on the hyphen: Using a hyphen (-) before the user name when you use "su" command to take on the privileges of some other user, you effectively use a "Log-in Shell". Without the hyphen, the Log-in environment would be called "No Log-in Shell".

cd to any directory such /tmp:

Code:
cd /tmp
and then run this command:

Code:
[root@localhost tmp]# du -ah . | sort -nr | grep  -v ^0 | head
924K	./localhost-2012011502501326576035/proc/sys/net/ipv6
768K	./localhost-2012011502501326576035/sos_commands/process
724K	./localhost-2012011502501326576035/etc/sysconfig
684K	./localhost-2012011502501326576035/sos_commands/process/lsof_-b_M_-n_-l
584K	./localhost-2012011502501326576035/proc/sys/net/ipv6/conf
584K	./localhost-2012011502501326576035/etc/rc.d
524K	./localhost-2012011502501326576035/etc/rc.d/init.d
484K	./localhost-2012011502501326576035/proc/sys/net/ipv4/conf
388K	./localhost-2012011502501326576035/proc/sys/kernel
332K	./localhost-2012011502501326576035/var/log/messages-20111212
[root@localhost tmp]#
"du -ah ." = This part tells you the counts of each file and directory (-a). You get to know their sizes in KB/MB/GB (-h) as shown above. But I would not recommend "-h" as "sort" would not give us a realistic sorted list. For example, lines containing "M" in the first column may appear after "K". So, it is better to leave out "-h" and use only "du -a".

Examples:

Code:
[root@localhost ~]# du -ah /var/log | sort -nr | grep -v ^0 | tail -n 5
4.0K	/var/log/boot.log-20111212
4.0K	/var/log/boot.log-20111204
4.0K	/var/log/boot.log
3.9M	/var/log/audit/audit.log
3.9M	/var/log/audit
[root@localhost ~]#
So, using only "du -a" is what we want:

Code:
[root@localhost ~]# du -a /var/log | sort -nr | grep -v ^0 | tail -n 5
4	/var/log/boot.log-20120115
4	/var/log/boot.log-20120113
4	/var/log/boot.log-20111212
4	/var/log/boot.log-20111204
4	/var/log/boot.log

[root@localhost ~]# du -a /var/log | sort -nr | grep -v ^0 | head -n 5
7984	/var/log
3984	/var/log/audit
3980	/var/log/audit/audit.log
620	/var/log/wtmp
376	/var/log/gdm

"sort -nr" = We give the output of "du" to "sort" by piping "|". "sort -nr" sort the fist column that is the size field and gives a Descending List of the Size. So, the big sized files/directories appear at the top and the lowest ones at the bottom.

"grep -v ^0" = We are removing those entries that have "zero" sized files.

"head" = Top 10 lines are displayed.

You can replace "head" with "more" to navigate the entire output.

Or you can write the output to a file with the help of redirection operator ">" and then giving it a file name:

Code:
[root@localhost tmp]# du -a . | sort -nr | grep  -v ^0 > files_list
[root@localhost tmp]# ls -l files_list
-rw-r--r--. 1 root root 137849 Jan 16 01:16 files_list
[root@localhost tmp]# less files_list 
[root@localhost tmp]#
You can use "less", "more", or "vi", or "vim" or any other editor to view the file's contents.

You can then decide which files/directories you may want to delete.

"du -a ." = . (dot) means the current directory. You can replace the dot with any other directory's path:

Code:
du -a "/var/log"
Code:
[root@localhost tmp]# du -a /var/log | sort -nr | grep -v ^0 | head
You can alternately and more effectively use "find" command to list large files and delete them at the same time if you wish to:

Code:
[root@localhost tmp]# find /boot/ -type f -size +1M | xargs ls -lh
-rw-r--r--. 1 root root  13M Aug 12 16:12 /boot/initramfs-2.6.32-71.el6.i686.img
-rw-r--r--. 1 root root 1.7M Nov 12  2010 /boot/System.map-2.6.32-71.el6.i686
-rwxr-xr-x. 1 root root 3.5M Nov 12  2010 /boot/vmlinuz-2.6.32-71.el6.i686
[root@localhost tmp]#
You can replace "+1M" to any other value such as "+10M" or "+1G" meaning size greater than 10 MB or 1 GB respectively.

"xargs ls -lh" = We are long-listing each line processed by the find command. We can replace this command with "rm" to remove the file instead. Or "rm -rf" to remove forcefully and "r" for recursively if it is a directory. But we have already specified "-type f" to mean that only file names will appear. So, "rm -f" would be enough.

Example:

Code:
[root@localhost tmp]# find /boot/ -type f -size +1M | xargs echo "rm"
rm /boot/System.map-2.6.32-71.el6.i686 /boot/initramfs-2.6.32-71.el6.i686.img /boot/vmlinuz-2.6.32-71.el6.i686
[root@localhost tmp]#
You got it now? Remove "echo" and quotes of "rm" and simply make it look like as follows:

Code:
find /boot/ -type f -size +1M | xargs rm -f

or

find /boot/ -type f -size +1M | xargs rm
Please, be warned that "rm" or "rm -f" or "rm -r" is a destructive command and we cannot retrieve deleted files (unless some expert technique is used).

That is why I have used "echo" to see what is going to happen. It is good to save the output in a file:

Code:
[root@localhost tmp]# find /boot/ -type f -size +1M | xargs echo "rm" > output
[root@localhost tmp]# cat output 
rm /boot/System.map-2.6.32-71.el6.i686 /boot/initramfs-2.6.32-71.el6.i686.img /boot/vmlinuz-2.6.32-71.el6.i686
[root@localhost tmp]#
You can directly delete them if you are sure that you would not need those files:

Code:
/bin/bash output
The "output" file contains "rm" command and hence it acts as a script and you can run it easily.

See it in action:


Code:
[root@localhost tmp]# find /tmp/ -type f -size +1M | xargs echo "rm"
rm /tmp/localhost-2012011502501326576035/var/log/audit/audit.log

[root@localhost tmp]# find /tmp/ -type f -size +1M | xargs echo "rm" > output
[root@localhost tmp]# cat output 
rm /tmp/localhost-2012011502501326576035/var/log/audit/audit.log

[root@localhost tmp]# ls -lh /tmp/localhost-2012011502501326576035/var/log/audit/audit.log 
-rw-r--r--. 1 root root 3.8M Jan 15 02:51 /tmp/localhost-2012011502501326576035/var/log/audit/audit.log

[root@localhost tmp]# /bin/bash output 

[root@localhost tmp]# ls -lh /tmp/localhost-2012011502501326576035/var/log/audit/audit.log 
ls: cannot access /tmp/localhost-2012011502501326576035/var/log/audit/audit.log: No such file or directory
[root@localhost tmp]#
So, I have deleted the above file that I would not need any longer.


One more example for you:

Code:
[root@localhost tmp]# find /tmp/ -type f -size +1k | xargs echo "rm" > output
[root@localhost tmp]# ls -lh output 
-rw-r--r--. 1 root root 18K Jan 16 01:39 output
[root@localhost tmp]#
Oh! The output file itself is of 18K now that contains only the file names whose size is greater than 1KB!

How can we delete them all in one go?

Yes, executing the "output" file that contains the command "rm":

Code:
[root@localhost tmp]# /bin/bash output 
[root@localhost tmp]# find /tmp/ -type f -size +1k | xargs echo "rm" > output
[root@localhost tmp]# cat output 
rm
[root@localhost tmp]#
The file contains only the command name and no file names now because there is no file whose size would be greater than 1KB.

Notice "k" is small in the find command. "M" and "G" will be in capital letters.


Please Note: Do not use "/" after "find" because it will search the entire file system / Hard Disk that is visible to Linux/Unix on your system. Just try these areas/partitions/directories:

Code:
find /tmp -type f -size +1k | xargs ls -lh

find /var/log -type f -size +1k | xargs ls -lh

find /home -type f -size +1k | xargs ls -lh
As I said earlier, instead of "ls -lh" you can use '| xargs echo "rm" > files.txt'

Since, you are 61. I thought it would be nice to explain every piece of the commands I have given here. Please, excuse me if you were already familiar with them.

Do let me/us know if you need more help. You would not need to check "/boot" partition if never installed any other kernel. That is, you have had only one Linux Kernel that was there at the time of a fresh installation of your Linux Distro.

Just list the output of this command here so that we can tell you if you need to delete any file in "/boot" directory:

Command:
Code:
ls -ltrh /boot
Output on my System:
Code:
total 18M
-rw-r--r--. 1 root root 1.7M Nov 12  2010 System.map-2.6.32-71.el6.i686
-rw-r--r--. 1 root root 101K Nov 12  2010 config-2.6.32-71.el6.i686
-rwxr-xr-x. 1 root root 3.5M Nov 12  2010 vmlinuz-2.6.32-71.el6.i686
-rw-r--r--. 1 root root 155K Nov 12  2010 symvers-2.6.32-71.el6.i686.gz
drwx------. 2 root root  16K Aug 12 15:25 lost+found
drwxr-xr-x. 3 root root 4.0K Aug 12 15:49 efi
-rw-r--r--. 1 root root  13M Aug 12 16:12 initramfs-2.6.32-71.el6.i686.img
drwxr-xr-x. 2 root root 4.0K Aug 12 16:13 grub
I am using CentOS 6.0 and I do not have any huge files in "/boot" that I would consider deleting them.

So, do post what your "/boot" directory holds so that we can help you better. Remember, any messing up with /boot may result in a unusable system. You may not even be able to log-in to or even boot your system.


Cheers!

Last edited by devUnix; 01-15-2012 at 03:17 PM.
 
Old 01-18-2012, 11:52 PM   #15
aletta
Member
 
Registered: Dec 2011
Location: Vancouver, BC Canada
Distribution: Centos 6.3
Posts: 48

Rep: Reputation: Disabled
I wish they would make CrapCleaner for Linux however, bleachbit is not too shabby it worked well on my Centos 5.7.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
my / partition is getting loaded up....how to clean? joutlancpa Slackware 12 04-13-2009 07:07 PM
Clean install keeping /home partition. digger95 Slackware 10 04-19-2008 03:28 AM
clean data from partition sporty *BSD 5 07-04-2007 03:15 AM
How to clean up partition table noranthon Linux - Newbie 27 02-11-2007 04:32 PM
how do I clean my root dir out? i have no diskspace in it and i cant log in. ethereal27 Ubuntu 3 07-14-2006 10:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration