LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-07-2011, 09:45 AM   #1
Robert.Thompson
Member
 
Registered: Nov 2009
Location: Montreal, Quebec, Canada
Distribution: LinuxMint 20 Cinnamon
Posts: 589

Rep: Reputation: 49
How can I tell if I have 'garbage' in my root partition?


Hello:

As a newbie, I have probably done a lot things that were wrong.

My root partition /dev/sda1 is 24.41 GiB with 10.48 GiB used.

How can I tell if I have inadvertently placed a bunch of garbage on this partition?

Also, should I, and I use the term loosely, 'move' certain directories to my home partition /dev/sda3? (118.77 GiB with 3.14 GiB used)

Right now I believe that, rightly or wrongly, if I screw up my system, all I need to do is install my Clonezilla image back to /dev/sda1 and I will have a 'mostly' working system. If I 'move' anything out of /dev/sda1 to /dev/sda3, will this hold true? Or am I out to lunch on this assumption anyway?

Thanks for any thoughts on these points.
 
Old 03-07-2011, 09:52 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
How can I tell if I have inadvertently placed a bunch of garbage on this partition?
Well, only you can tell :-)
10.48 GB used isn't that much, it all depends, did you installed software in /opt, did you saved sourcefiles in /
Look at the /var/log and /var/spool directories, you can delete rotated/compressed logfiles...

Kind regards
 
1 members found this post helpful.
Old 03-07-2011, 10:18 AM   #3
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
a full install of slackware 13.1 is about 8GB; add a bit of software, logfiles and some more and the 10G does not seem all that bad;
A point where I noticed many files appear is /tmp; you can delete most of those files; take a look and delete whatever does not seem important. Mind that there are also quite a few special files created there (e.g. sockets and named pipes) which may be important for the current running state of the machine; they should be possible to be recreated.

You can move directories to your home partition on /dev/sda3; However, if /dev/sda3 is mounted on /home, technically speaking you can move /usr/ to there (mind: technically speaking, as it is _NOT_ advised!);

if you do
Code:
mv /usr /home/usr
you must remember to create a symlink, like so:
Code:
ln -s /home/usr /usr
Much better would be to make a backup of /home; e.g. like so:
Code:
tar Jcvf /home.tar.xz
then use cfdisk to delete /dev/sda3 and create new partitions; something along the lines of 25G for /usr and the rest for /home (most of your additional files will get into your home directories, so most space should be allocated there; Expect little to no growth on the current install base)

After you did the repartitioning, you can make a filesystem on them (mke4fs from the top of my head for a ext4 filesystem; see the manpage for the parameters)
change /etc/fstab so you have valid mount points; fix the mountpoint for your /home, which wills till be in /etc/fstab on the old /dev/sda3 partition.

After that it's a simple matter of restore and move:
e.g. you can create a temporary directory /newusr and mv all that is in /usr to /newusr
you can then umount /usr and /newusr and then mount the new partition on /usr

voila; all the files have been moved;

NB: I used /usr as an example, you may want to do this but then on /tmp for example;
NB2: 10G out of 20G for everything but /home tells me you're on the safe side for a home-use system. The other 10G will hardly be filled up with extra stuff (not in the likes of Gigabytes) whereas the homedirectory will contain your movies, documents, music collection, photos, games, whatnot; thus that will very likely want to use the 120GB in the next few years. Nothing from what you told tells me you messed up your system, and I would advise you to go on without any changes.
 
1 members found this post helpful.
Old 03-07-2011, 10:19 AM   #4
Robert.Thompson
Member
 
Registered: Nov 2009
Location: Montreal, Quebec, Canada
Distribution: LinuxMint 20 Cinnamon
Posts: 589

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by repo View Post
Well, only you can tell :-)
10.48 GB used isn't that much, it all depends, did you installed software in /opt, did you saved sourcefiles in /
Look at the /var/log and /var/spool directories, you can delete rotated/compressed logfiles...

Kind regards
Hi repo:

Yikes, there is stuff in /opt!!!! (folders: dropbox, fremind, google, libreoffice) I think they have to stay, right?

As far as I know/see, I did not save sourcefiles in /

I guess I'm OK space-wise.

Thanks,
 
Old 03-07-2011, 10:39 AM   #5
Robert.Thompson
Member
 
Registered: Nov 2009
Location: Montreal, Quebec, Canada
Distribution: LinuxMint 20 Cinnamon
Posts: 589

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by Ramurd View Post
...Nothing from what you told tells me you messed up your system, and I would advise you to go on without any changes.
Thanks for the really great post, Ramurd, I appreciate your time and advice.

I'm going to leave things 'as they are' given your reassurance - as a newbie, I had no idea if I was running out of space in /dev/sda1 at a rapid rate or not. I feel much much better now.

I am printing your post for 'future reference'

Thanks again,
 
Old 03-07-2011, 10:40 AM   #6
tommcd
Senior Member
 
Registered: Jun 2006
Location: Philadelphia PA USA
Distribution: Lubuntu, Slackware
Posts: 2,230

Rep: Reputation: 293Reputation: 293Reputation: 293
If you have built a lot of packages with the slack-builds at http://slackbuilds.org/, the /tmp/SBo/ directory can fill up with with a lot of temporary directories and files for each package that is created. Once the package is built and installed you don't need these temporary files in /tmp/SBo/ any longer. I save the finished .tgz packages in case I ever need to reinstall them. Everything else that is created in the /tmp directory from running slack-builds I get rid of.

Last edited by tommcd; 03-07-2011 at 10:45 AM.
 
1 members found this post helpful.
Old 03-07-2011, 10:49 AM   #7
Robert.Thompson
Member
 
Registered: Nov 2009
Location: Montreal, Quebec, Canada
Distribution: LinuxMint 20 Cinnamon
Posts: 589

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by tommcd View Post
If you have built a lot of packages with the slack-builds at http://slackbuilds.org/, the /tmp/SBo/ directory can fill up with with a lot of temporary directories and files for each package that is created. Once the package is built you don't need these any longer. I save the finished .tgz packages in case I ever need to reinstall them. Everything else that is created in the /tmp directory from running slack-builds I get rid of.
Thanks tommcd:

I saw that and remembered gene's http://genek.net/LinuxAdventures/sys...ackconfig.html and his 'Cleaning Out the Junk' section, so I added the following to /etc/fstab:
Code:
tmpfs            /tmp             tmpfs       defaults         0   0
This seams to blow out most stuff but does leave a few things and I, of course, have no idea why it leaves anything.
 
Old 03-07-2011, 11:16 AM   #8
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
Well when you reboot it will be clean, but then apps start to use it and leave files.
 
Old 03-07-2011, 11:25 AM   #9
tommcd
Senior Member
 
Registered: Jun 2006
Location: Philadelphia PA USA
Distribution: Lubuntu, Slackware
Posts: 2,230

Rep: Reputation: 293Reputation: 293Reputation: 293
Quote:
Originally Posted by Robert.Thompson View Post
I added the following to /etc/fstab:

tmpfs /tmp tmpfs defaults 0 0

This seams to blow out most stuff but does leave a few things and I, of course, have no idea why it leaves anything.
That should clear out the /tmp directory just fine. Remember that some files are created in /tmp each time you boot the computer, so /tmp will never be totally empty.

EDIT: I see that Dive beat me to it here while I was reading the "Cleaning Out the Junk" link and composing my post.

Last edited by tommcd; 03-07-2011 at 11:31 AM.
 
Old 03-07-2011, 01:06 PM   #10
Robert.Thompson
Member
 
Registered: Nov 2009
Location: Montreal, Quebec, Canada
Distribution: LinuxMint 20 Cinnamon
Posts: 589

Original Poster
Rep: Reputation: 49
To dive & tommcd:

Oooooooooooooh!

Now, it makes sense.

Thanks,
 
Old 03-07-2011, 07:29 PM   #11
ivandi
Member
 
Registered: Jul 2009
Location: Québec, Canada
Distribution: CRUX, Debian
Posts: 528

Rep: Reputation: 866Reputation: 866Reputation: 866Reputation: 866Reputation: 866Reputation: 866Reputation: 866
Here is the script I use to check for junk left after removing/upgrading packages. It is not fool proof and supposes that the user knows what he does. For example it will list /boot/initrd.gz as not belonging to any package. It does not check /var, most of the stuff there is created during run time and it is easier to clean it manually.

Code:
#!/bin/bash

DIRS="/bin /sbin /lib /etc /opt /usr /boot /srv /mnt /media"

TMPDIR=/tmp

FILELIST=$(mktemp /$TMPDIR/filelist.XXXXXX)
DIRLIST=$(mktemp /$TMPDIR/dirlist.XXXXXX)
SYMLINKLIST=$(mktemp /$TMPDIR/symlinklist.XXXXXX)
PKGFILELIST=$(mktemp /$TMPDIR/pkgfilelist.XXXXXX)
PKGDIRLIST=$(mktemp /$TMPDIR/pkgdirlist.XXXXXX)
PKGSYMLINKLIST=$(mktemp /$TMPDIR/pkgsymlinklist.XXXXXX)

clean(){
	rm -f $FILELIST $DIRLIST $SYMLINKLIST $PKGFILELIST $PKGDIRLIST $PKGSYMLINKLIST
}

listfiles(){
	for d in $DIRS ; do
		find $d -type f 2>/dev/null | cut -b2-
    done | sort -u > $FILELIST
}

listdirs(){
	for d in $DIRS ; do
		find $d -type d 2>/dev/null | cut -b2-
    done | sort -u > $DIRLIST
}

listsymlinks(){
	for d in $DIRS ; do
		find $d -type l 2>/dev/null | cut -b2-
    done | sort -u > $SYMLINKLIST
}

exclude(){
	grep -v "^dev/" \
	| grep -v "^var/" \
	| grep -v "^install/" \
	| grep -v "^home/" \
	| grep -v "^root/" \
	| grep -v "^tmp/" \
	| grep -v "^proc/" \
	| grep -v "^sys/" \
	| grep -v "\./"
}

listpkgfiles(){
	for f in /var/log/packages/* ; do
	if [ -f $f ] ; then
	    sed -n "/FILE LIST:/,/^$/p" < $f | grep -v "FILE LIST:" | grep -v "/$" 
	fi
    done | exclude | sort -u > $PKGFILELIST
}

listpkgdirs(){
	for f in /var/log/packages/* ; do
	if [ -f $f ] ; then
	    sed -n "/FILE LIST:/,/^$/p" < $f | grep -v "FILE LIST:" | grep "/$"
	fi
    done | exclude | sed -e 's/\/$/''/' | sort -u > $PKGDIRLIST
}

listpkgsymlinks(){
	for f in /var/log/scripts/* ; do
	if [ -f $f ] ; then
		sed -n 's,^( *cd \([^ ;][^ ;]*\) *; *rm -rf \([^ )][^ )]*\) *) *$,\1/\2,p' < $f
	fi
	done | exclude | sort -u > $PKGSYMLINKLIST
}

makelists(){
	listfiles
	listdirs
	listsymlinks
	listpkgfiles
	listpkgdirs
	listpkgsymlinks
}

orphan_files(){
	echo "-------------"
	echo "File orphans:"
	echo "-------------"
	comm -23 $FILELIST $PKGFILELIST \
	| grep -v "^usr/share/mime/" \
	| while read f ; do
	case "$f" in
		*.so)
			grep -q "/incoming/$(basename $f)$" $PKGFILELIST && continue
		;;
		*.pyo)
			grep -q "$(dirname $f)/$(basename $f .pyo).py$" $PKGFILELIST && continue
		;;
		*.pyc)
			grep -q "$(dirname $f)/$(basename $f .pyc).py$" $PKGFILELIST && continue
		;;
		*)
			grep -q "$f\.new$" $PKGFILELIST && continue
			grep -q "/$(basename $f)$" $PKGFILELIST && continue
			grep -q "$f" /var/log/scripts/* && continue
		;;
	esac
	echo $f
	done | sort -u
}

orphan_dirs(){
	echo "------------------"
	echo "Directory orphans:"
	echo "------------------"
	comm -23 $DIRLIST $PKGDIRLIST \
	| grep -v "^usr/share/mime/" \
	| while read f ; do
	case "$f" in
		*)
			grep -q "/$(basename $f)$" $PKGDIRLIST && continue
			grep -q "$f" /var/log/scripts/* && continue
		;;
	esac
	echo $f
	done | sort -u
}

orphan_links(){
	echo "----------------"
	echo "Symlink orphans:"
	echo "----------------"
	comm -23 $SYMLINKLIST $PKGSYMLINKLIST \
	| grep -v "^usr/share/mime/" \
	| grep -v "^etc/ssl/certs/" \
	| while read f ; do
	case "$f" in
		*)
			grep -q "/$(basename $f)$" $PKGSYMLINKLIST && continue
			grep -q "$f" /var/log/scripts/* && continue
		;;
	esac
	echo $f
	done | sort -u
}

makelists
orphan_files
orphan_dirs
orphan_links

clean
I use tmpwatch to manage my /tmp with a cron job

Code:
#!/bin/sh

for d in /tmp /var/tmp /home/*/{tmp,.thumbnails} ; do
    if [ -d $d ] ; then
	/usr/bin/tmpwatch -afqs 7d $d
    fi
done

for d in /var/log/removed_{packages,scripts} ; do
    if [ -d $d ] ; then
	/usr/bin/tmpwatch -afqs 30d $d
    fi
done
For finding libs not used by any package I use tracepkg and a simple script
Code:
#!/bin/bash

slackpkg update
tracepkg --sync
grep -w /slackware/l /var/lib/slackpkg/pkglist | cut -f6 -d ' ' | \
while read p ; do
    [ -f /var/log/packages/$p ] || continue
    grep -q $p /var/log/dependencies/* || echo $p
done
 
1 members found this post helpful.
Old 03-08-2011, 03:49 AM   #12
dh2k
Member
 
Registered: Jan 2006
Distribution: Slackware 13.0 (KDE 3.5.10 from 12.2; Xfce 4.6; Fluxbox); Slackware 13.1 (KDE 4.5)
Posts: 211

Rep: Reputation: 52
Consider (building, then) installing 'filelight' for KDE desktop from http://slackbuilds.org/repository/13...tem/filelight/ - this maybe used to visually see what is taking up so much space.
 
1 members found this post helpful.
Old 03-08-2011, 05:04 AM   #13
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
Did you remember to clear out the original /tmp before setting up /tmp on tmpfs? if not then you could be using space that you can't see because you've over-mounted it. The mount bind option is useful for seeing what's underneath. (in the old days you would have to unmount stuff and that was a right pain)

Try this as root. mount -o bind / /mnt then have a look what is in /mnt/tmp. (du -Sh is how I like to keep an eye on space, but use whatever you're happy with)
If you find anything then you probably want to remove it.

Once done, umount /mnt will put it back to normal.


P.S. This is assuming that you didn't have a separate /tmp beforehand and /tmp was a part of the root filesystem.

Last edited by GazL; 03-08-2011 at 05:08 AM.
 
3 members found this post helpful.
Old 03-08-2011, 09:27 AM   #14
Robert.Thompson
Member
 
Registered: Nov 2009
Location: Montreal, Quebec, Canada
Distribution: LinuxMint 20 Cinnamon
Posts: 589

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by GazL View Post
Did you remember to clear out the original /tmp before setting up /tmp on tmpfs? if not then you could be using space that you can't see because you've over-mounted it. The mount bind option is useful for seeing what's underneath. (in the old days you would have to unmount stuff and that was a right pain)

Try this as root. mount -o bind / /mnt then have a look what is in /mnt/tmp. (du -Sh is how I like to keep an eye on space, but use whatever you're happy with)
If you find anything then you probably want to remove it.

Once done, umount /mnt will put it back to normal.


P.S. This is assuming that you didn't have a separate /tmp beforehand and /tmp was a part of the root filesystem.
Hi Gazl:

I think that you are correct. When I do as you suggested, I see tons of stuff that I don't normally see!

Edit: I think that I am wrong. The 'du -Sh' shows everything, not just the contents of the /tmp directory, right?

How do I get rid of everything? Do I put my fstab back to normal and then try to delete the stuff or is there a better way.

Thanks,

Last edited by Robert.Thompson; 03-08-2011 at 09:43 AM.
 
Old 03-08-2011, 10:51 AM   #15
Robert.Thompson
Member
 
Registered: Nov 2009
Location: Montreal, Quebec, Canada
Distribution: LinuxMint 20 Cinnamon
Posts: 589

Original Poster
Rep: Reputation: 49
Hello:

Note: I am an inexperienced Slackware user.

Doing the following reduced the file space used on /dev/sda1 (/root) from 10.51 GiB to 6.83 GiB.
The 3.68 GiB difference were files living in my /tmp directory that I could not see because I had altered my /etc/fstab by adding the following:
Code:
tmpfs            /tmp             tmpfs       defaults         0   0
Adding this will clean out your /tmp directory every time that you reboot. see: http://genek.net/LinuxAdventures/sys...ackconfig.html
However, I made the mistake of altering the /etc/fstab many days after I installed Slackware (Gene tells you to do this almost immediately after the initial install) and, as GazL brought to my attention, I should have cleaned out the /tmp directory, manually, before altering my /etc/fstab file. By not doing this, all the files living in /tmp previously remained in place but became, for lack of a better word, invisible.

So, here is what I did:
  1. Backed up my system
  2. Opened Konsole
  3. su & password
  4. Code:
    # nano /etc/fstab
  5. deleted the line:
    Code:
    tmpfs            /tmp             tmpfs       defaults         0   0
  6. Ctrl+X & saved the changes to fstab
  7. Code:
    # lilo
  8. Code:
    # reboot
  9. Opened Konsole
  10. su & password
  11. entered the following:
    Code:
    rm -R /tmp/*
  12. Code:
    # nano /etc/fstab
  13. added back the line I had removed:
    Code:
    tmpfs            /tmp             tmpfs       defaults         0   0
  14. Code:
    lilo
  15. Code:
    reboot
This corrected my mistake and gave me back 3.68 Gib of disk space in /dev/sda1 (/root) but remember:
I am only an inexperienced Slackware user.

Thanks to all you Slackers for your input!

Marking as SOLVED

Last edited by Robert.Thompson; 03-08-2011 at 12:12 PM. Reason: typo's
 
  


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
Changing /tmp from it's own partition back to root partition branisd SUSE / openSUSE 3 06-10-2010 02:20 AM
Root partition changed to /dev/root mdg Linux - Software 9 02-19-2010 12:03 AM
Accidently deleted the linux partition(root partition) how to recover it? sanues Linux - Newbie 7 11-30-2009 01:55 PM
GRUB won't load windows partition - root (hd0,0), Filesystem type unknown partition.. cillm527 Linux - Software 4 04-27-2008 06:44 AM
colinux access to ext3 partition (opensuse root partition) billtracy1957 Linux - General 0 05-03-2007 10:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:33 AM.

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