[SOLVED] How can I tell if I have 'garbage' in my root partition?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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...
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.
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 /
...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.
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.
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.
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.
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
#!/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
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.
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.
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:
Backed up my system
Opened Konsole
su & password
Code:
# nano /etc/fstab
deleted the line:
Code:
tmpfs /tmp tmpfs defaults 0 0
Ctrl+X & saved the changes to fstab
Code:
# lilo
Code:
# reboot
Opened Konsole
su & password
entered the following:
Code:
rm -R /tmp/*
Code:
# nano /etc/fstab
added back the line I had removed:
Code:
tmpfs /tmp tmpfs defaults 0 0
Code:
lilo
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.