13

A friend of mine partitioned his ubuntu system with /usr on a separate partition. That partition is now full. He can't use apt to install new software. Is there anything in /usr that he can safely delete (i.e. delete with rm, not apt-get remove)?

Since he can't install new software he can't install something like dpigs (the tool for checking which packages is taking up space)

6 Answers 6

10

Have you tried "sudo apt-get clean", "apt-get autoclean", and "apt-get autoremove"? If you use "man apt-get" that will describe what each does and may free some space.

5
  • 5
    clean only deletes stuff in /var.
    – womble
    Nov 23, 2009 at 14:39
  • 1
    As @womble said, clean only deletes things in /var. However autoremove will delete things in /usr, so it might save something Nov 23, 2009 at 15:30
  • 1
    Whoops...didn't hurt to try it though :-) Looks like autoremove may give wanted results. It may have given some direction in which to look though. Nov 24, 2009 at 12:06
  • On a similar quest, I found sudo apt-get clean to be most effective. apt-get autoclean and apt-get autoremove actually decreased available space. clean released it again. I checked disk space with df -h.
    – RolfBly
    Oct 21, 2014 at 15:25
  • Running apt-get autoremove will remove lingering (older versions) linux-modules in the /usr directory (resulting in freeing up space). May 25, 2023 at 11:34
18

I had a similar problem. First step was to find the top ten space hogs:

# cd /usr/share
# du -sm * | sort -rn | head -10

/usr/share/doc was 759MB on my system. Space that could be useful for other purposes. With *nix you can move things around without breaking things. In my case I had plenty of free space on /home which was on a different partition:

# mkdir -p /home/share/doc
# mv /usr/share/doc/* /home/share/doc
# rmdir /usr/share/doc
# ln -s /home/share/doc /usr/share/doc 

If you are really desparate, you can always mount an external hard drive and perform a similar relocation process. The thing to watch for in that case is that you don't move anything critical to the system startup to the external drive. /usr/src is another candidate, but I wouldn't move /usr/lib, too risky.

9
/usr/share/doc
/usr/src
3
  • /usr/share/doc is the best place to purge. /usr/src can contain locally-built stuff that can't be easily replaced.
    – womble
    Nov 23, 2009 at 14:40
  • 1
    yes, but sometimes it conain vanilla kernel and standard sources what easily can be restored from internet
    – vlad
    Nov 24, 2009 at 11:03
  • 1
    /usr/share/doc is a good one to clean up, however, using apt-get to delete the files would be a better way. Is there some easy way to remove those files using apt? Dec 21, 2009 at 10:28
1

Another option not explored is to resize the partitions with the gparted livecd. Backup your critical data first though and be prepared to loose the lot just in case. I have done a resize a few times before and not had an issue so it's quite a robust procedure.

Another extension to this is that he could move everything from /usr to another larger partition linking it with a symbolic link to the new location. Then using gparted you can remove the old /usr partition and merge /usr into the other partition.

Personally, I don't see the need to separate partitions for /usr /home etc like the old days. It often results in more issues than it solves (i.e. running out of space). Still, that's just my opinion.

0

An ugly hack would be to try uninstalling GNOME and get something lightweight instead. Presumably this shall save some space.

0

I like the solution by CyberFonic best, however when creating the symlink I had to give it the option for 'no dereference' since it's a directory. Otherwise i would get errors when installing anything that tried to add a doc file, since /usr/share/doc wasn't being seen as a directory. I couldn't cd to /usr/share/doc until I did the symlink like so:

sudo ln -sfn /home/usr/share/doc /usr/share/doc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .