- Freeing Disc Space
- See partitions and discs usage
- Full partitions
- See which directories are using the most disc space
- See which packages are using the most disc space
- Command line
- Remove some cruft
- Graphical Interface
- Find things to erase
- Categorically Expendable Directories
- Temporary
- Logs
- Cache
- Spool
- Command line tools to see seldom used files
- /usr/bin/find
- Duplicate Handling
- Finders
- Files you do not want
- Packages you do not want
- Tools to alter files to reduce them
- Convert spaces to tabs
- Reduce data creation
- File Systems
- Application Level / User Space
- In Linux
- No high confidence of high reliability
- Turn Off Reserved Blocks on ExtFS
- Off Line Storage
- File Compression
- Wish list
- See Also
- Useful GUI Tools to Free Up Space on Ubuntu and Linux Mint
- 1. Stacer
- 2. Ubuntu Cleaner
- 3. BleachBit
- 4. Sweeper
- 5. rmLint
Freeing Disc Space
This page talks about ways to find out how much of the system storage space is used and to free up some of it.
For a description on how to reduce the footprint of a Debian installation see ReduceDebian.
- Freeing Disc Space
- See partitions and discs usage
- Full partitions
- Command line
- Remove some cruft
- Graphical Interface
- Categorically Expendable Directories
- Command line tools to see seldom used files
- Duplicate Handling
- Files you do not want
- Packages you do not want
- Convert spaces to tabs
- Application Level / User Space
- In Linux
See partitions and discs usage
First of all, to see the existing partitions, use:
Then to check which partitions are getting full use:
$ df --local --human-readable -T Filesystem Type Size Used Avail Use% Mounted on /dev/sda1 ext4 100M 77M 33M 77% / .
Full partitions
If a partition becomes full the system might not work properly.
When your Home directory becomes full, you will not be able to save any file, and some applications might refuse to start correctly.
When your temporary directory (/tmp) becomes full, many applications will fail with error messages such as:
cannot create temp file for document: No space left on device
See which directories are using the most disc space
There are several tools to see which directories are using the most disc space on a Debian system, like baobab (GUI) or the command line program du in the package coreutils that can be used like this:
/usr/bin/du --total --summarize --human-readable --one-file-system
Ncdu is a ncurses-based du viewer. It provides a fast and easy to use interface and allows to browse through directories, to show percentages of disk usage and to delete unwanted files.
See which packages are using the most disc space
Command line
To list packages that take up most of the disc space with aptitude into visual mode, select Views → New Flat Package List (this menu entry is available only after etch version), press l and enter ~i, press S and enter ~installsize, then it will give you nice list to work with. Doing this after upgrading aptitude should give you access to this new feature.
In lenny, aptitude has «why» and «why-not».
shows why package1 may have been installed.
aptitude why package1 package2
tries to work out why installing package1 would drag in package2.
«why-not» looks at conflicts.
These commands only provide one possible explanation. Check /var/log/aptitude for definitive information.
Using aptitude to list uninstalled recommended or suggested packages:
aptitude search '~RBsuggests:~i!~i'
To list upgradeable packages:
To list manually installed packages:
To install without recommends but not uninstalling other recommends:
aptitude install -R -o Aptitude::Keep-Recommends=true
To list packages in increasing order of size:
aptitude -F '%I %p' search '~i'|egrep '^6+[\.,]?4* [MG]B'|sort -n
Remove some cruft
Purge obsolete configuration files:
Sort installed packages by size:
dpkg-query -W --showformat='$ $\n' | sort -n
Graphical Interface
synaptic, go to installed packages and click on the size column.
Find things to erase
Categorically Expendable Directories
Temporary
Contents of these directories are only intended to be used in the short term or while a program is running and are generally expendable.
Logs
Cache
- packages in /var/cache/apt/archives usually eats some space. As root or using sudo, you can get rid of them with:
Use apt-get autoclean if you want to remove old packages for which you also have the last package.
Spool
are intended to be processed but may be expendable.
Command line tools to see seldom used files
/usr/bin/find
- -mtime
- -atime (if your system has atime enabled, which is not default in Linux)
- -size
Duplicate Handling
When you find duplicates, you can hard link them, if they are on the same file system, or remove duplicates to make them unique.
Finders
- duff Can compare full file contents, but not default.
- fdupes Can remove. Does compare full file contents.
- fslint also does other maintenance and size reduction tasks.
- hardlink Can convert from duplicates to hard links.
- rdfind Can hard link or remove. Does not compare full file contents. Warning: uses MD5 by default to compare. May produce false matches. Can specify SHA1 instead.
Files you do not want
Packages you do not want
- debfoster
- deborphan The textual user interface is provided by the program orphaner.
- gtkorphan GUI for deborphan
- popularity-contest Requires file system option strictatime, local e-mail server. run popularity-contest | sort > popcon
Tools to alter files to reduce them
Do not compress bash or your scripts will crash. Compressed executables may require more memory when run.
Convert spaces to tabs
Can reduce the file size of text files, though the difference is usually slight. For this example you need the commands find of findutils; unexpand of coreutils; and rewrite, which is at http://oss.ezic.com but not packaged.
find -type f -writable -name '*.txt' -exec rewrite '<>' 'unexpand --all' \;
Reduce data creation
Output to what would be files can be caused to go to /dev/null in some cases where a symlink does not work as in this example redirecting output from .xsession-errors: mknod .xsession-errors c 1 3
On systems that have been running for some time you might consider removing or compressing old log files. logrotate can assist
File Systems
ReiserFS can pack multiple small files and the ends of larger files into shared blocks, which saves space.
For file systems have blocks and which do not put parts of more than 1 file in a block, such as Ext4FS: using a different block size for the file system may save space depending on the size of the files stored on the file system. A block size of 1KB reduces space useage compared to 4KB for a Debian installation.
The following file systems provide compression.
Application Level / User Space
- GVFS Zip format archives can be mounted by GVFS.
- fuse-utils There are many file systems which offer compression and operate through FUSE.
In Linux
No high confidence of high reliability
Turn Off Reserved Blocks on ExtFS
By default, ExtFS reserves 5% of the file system for the user ‘root’ as a safety measure. To turn this off:
This can be done on a mounted filesystem.
Off Line Storage
You may move data to off line storage, such as removable optical discs or discs on an external data bus (such as Firewire or USB).
If you have a read-only source like a write once optical disc, an overlaid unifying file system like aufs or Linux’s «union mount» can save changes in a writeable filesystem, saving the user the space of the unchanged portions. The same could be accomplished with a snapshotted filesystem as with Linux Volume Manager (lvm2).
File Compression
Wish list
See Also
Useful GUI Tools to Free Up Space on Ubuntu and Linux Mint
As time moves along, you might notice your disk space gradually getting depleted. The explanation for this is that over time, junk files rapidly fill up your hard drive.
This happens particularly during the installation of software packages. During installation, these files are typically cached in the /var/cache/ directory before installation just in case you need to install them again.
Unfortunately, Ubuntu does not have an automated way of removing these files which are no longer required by the system. As such, they accumulate with each consecutive package installation and gobble up huge chunks of space on your drive.
Removing these files from your system on the terminal is a straightforward process.
This command gets rid of packages that were automatically installed to satisfy dependencies for other packages and are no longer needed as dependencies.
Another command you can consider running is:
The command clears the residual packages left in the /var/cache/ directory.
Now let us shift focus on how you can free up the disk space using a few GUI applications in Ubuntu and Linux Mint distribution.
1. Stacer
Written in C++, Stacer is a free and open-source GUI application that monitors and optimizes your disk space. It provides an intuitive and appealing user interface that gives you a glance at usage statistics of your resources such as RAM, CPU, and disk utilization. In addition, it gives you information about your system information and bandwidth utilization.
Stacer provides a couple of useful features to manage processes, startup applications, system services, and uninstall applications. Worth noting is the system cleaner which gets rid of package caches that occupy huge amounts of disk space. In addition, it also empties the trash and clears crash reports, application caches, and logs, thus freeing up the disk space.
To install Stacer on your system, run the command:
$ sudo apt update $ sudo apt install stacer
2. Ubuntu Cleaner
Developed in Python, Ubuntu Cleaner is yet another GUI option that does a decent job in freeing up disk space on Ubuntu / Mint. The graphical tool cleans up the system by removing the following files:
- Old Linux kernels
- Browser cache
- Thumbnail cache
- Apps Cache
- APT cache
- Any unneeded packages
Ubuntu Cleaner is open-source and absolutely free to use.
To install Ubuntu cleaner, clone the git repository.
$ git clone https://github.com/gerardpuig/ubuntu-cleaner.git
Then update your package index and install the Ubuntu cleaner package as follows:
$ cd ubuntu-cleaner $ ./ubuntu-cleaner
3. BleachBit
Designed for both Windows and Linux systems, BleachBit is a free and open-source disk cleaner that quickly frees up your disk as your PC fills up with junk files.
With BleachBit, you can shred temporary files, delete cookies, clear internet history, and discard application log files and unneeded files in the system.
In addition, BleachBit acts as a cleaner for web browsers such as Firefox and Chrome to mention a few.BleachBit is available in Ubuntu repositories and you can install it using the APT package manager as follows:
$ sudo apt update $ sudo apt install bleachbit
4. Sweeper
Native to the KDE desktop environment, Sweeper is a system cleaner application that clears your hard drive of junk files such as thumbnail cache, web browser junk such as cookies, web history, the temporary cache of visited websites, and also gets rids of files in your trash.
There are two ways of installing a Sweeper. You can install it from the official Ubuntu repository as follows:
$ sudo apt update $ sudo apt install sweeper
Additionally, you can install using snap as shown. First, ensure, snap is enabled on your system.
$ sudo apt update $ sudo apt install snapd
$ sudo snap install sweeper --edge
5. rmLint
Last on the list is the rmLint tool. The tool traverses multiple directories and helps in identifying duplicate files and directories, broken symbolic links, and non-stripped binaries.
It doesn’t delete these files per se, but it generates executable output, such as JSON or shell scripts that you can use to delete the files. It scans files and directories and intelligently determines the duplicates. When duplicates are found, you can then proceed and delete them using auto-generated scripts.
To install rmLint, simply run the command:
To launch the graphical interface, run the command:
That was a roundup of some of the most popular GUI tools that you can use to free up disk space in your Linux system.