This guide will help users who are having issues with a lack of free disk space. The user may have received an error message such as "There is not enough room on the disk to save ..." or perhaps a message about "insufficient disk space". This page presents ways to discover what is using large portions of your disk space and how to regain some free space.

The primary focus is on restoring space on the system partition ( / ) but the procedures can easily be modified for other partitions as well.

Common Reasons for "Lost" Free Space

  • Backup files were mistakenly saved to the wrong location.
  • Deleted files in the trash bin are still on the system taking up disk space.
  • The user unknowingly created a large file in the wrong location.
  • Downloads have accumulated in /var/cache/apt/archives.

  • Various log files have increased in size and/or number.
  • A cloned partition doesn't show the new partition's correct size.
  • An NTFS partition shows the incorrect size.
  • The contents of a lost+found folder has grown.

  • An advertised 500 GB drive doesn't format to 500 GB.
  • Nothing has changed, the user just needs a bit more space.
  • Finally, a partition, such as / or /boot, is simply too small.

Tips Before You Start

  • Mounting. Many of the commands and applications used in this guide present information only on mounted partitions. If possible, mount only those partitions you wish to investigate. At best additional mounted devices provide extra results - at worst a mounted device might hide what is actually on the system partition.

    • To view only the system folders, first close all open applications and then run the following command. It will attempt to unmount all partitions listed in /etc/mtab. You will get messages stating "device is busy" for any system partition or partition currently being used by the system. These messages are normal and can be ignored.

      sudo umount -a
    • To investigate other devices/partitions, you can mount all those listed in /etc/fstab with the following command. Once you have done that, you can manually mount any other devices which are not listed therein.

      sudo mount -a
  • Permissions. Users of Ubuntu are allowed access to files as set by permissions. These file permissions may prevent a user from seeing files created or stored in system folders and those owned by other users. If using a graphical file browser don't forget to enable hidden file viewing (usually CTRL+H). Run the commands/applications as 'root'. For command line operations, precede the command with sudo. For graphical applications such as nautilus and baobab/Disk Usage Analyzer start the command to launch the application with gksudo.

  • Deletions. When deleting folders/files from within a file browser such as nautilus remember that the deleted folders/files are moved to the Trash bin. Until you empty the trash, these files will continue to use disk space. Use one or more of these methods to permanently remove these files:

    • In a file browser, use SHIFT-DELETE to bypass the Trash bin.
    • In terminal, use the rm command.

    • Empty the Trash bins - the user's and root's. Starting with Ubuntu 8.04 (Hardy) these are located at ~/.local/share/Trash and /root/.local/share/Trash, respectively. The user's Trash can also be emptied by right clicking on the Trash icon and selecting Empty Trash.

      Warning: SHIFT-DELETE and rm cannot be easily reversed. Make sure you are deleting the correct item(s) when using these methods.

  • Formatting. A new drive rarely will format to the advertised size. Manufacturers normally promote unformatted capacities. Expect to lose approximately 5-7% of the advertised capacity. Additionally, by default Ubuntu reserves 5% for system use. This can be altered with the tune2fs command and is discussed later.

Checking Your Partitions Graphically (GUI)

System Monitor

  • Open with: System > Administration > System Monitor: File Systems tab. (In terminal: gksudo gnome-system-monitor &)

  • The information presented includes only currently mounted devices. Trash is considered used space.
  • The System tab lists the available disk space on the system ( / ) partition.


Disk Usage Analyzer

  • Open with: Applications > Accessories > Disk Usage Analyzer. (In terminal: gksudo baobab &). Also known as: baobab

  • Disk Usage Analyzer reports information only on mounted devices.


  • DUA provides valuable information but often brings up questions about its use. Here are some things to keep in mind:
    • Once a scan is complete, the top entry, whether it is the system or a single folder, will always show 100%. The sub-folder percentages add up to 100%. 100% does not necessarily mean there is no space left on the partition.
    • Total file system capacity includes the space on all mounted devices. If you have an external drive mounted, it's contents are included in the totals.

    • Scan Home scans the user's home folder, or root's if baobab is opened with gksudo. "Scan FileSystem" scans the system whether or not gksudo is used. If DUA is opened without gksudo baobab & not all folders/files will be visible/reported.

    • In the top section below the menus, DUA will list the Total file system capacity. This total is the sum of all reported devices. If DUA sees a / partition of 15 GB, a data partition of 30 GB, and an external drive mounted on /media/backup of 30 GB, it will report a total of 75 GB. The available space reported is the total space available, even if one partition is completely full. This value is the total of partitions selected in Preferences. You can select or deselect a partition/device by deselecting it in the Edit > Preferences section.

    • The Size column entries reflect actual disk space usage (allocated space), not the apparent folder size. You can change this option via the View menu.

    • If the disk usage is approximately double the size you expected, baobab may be including the .gvfs (a virtual file system). You may be able to deselect it via the Edit > Preferences menu.

    • Running DUA as root may show different results in the folders section. The reason is that opening DUA as a normal user through the main menu will not allow you to view certain folders, such as root's deleted Trash. For the most accurate results start this application with gksudo baobab &.

    • To narrow the search, you can expand a folder to see what amount of disk space each of the sub-folders is using.


  • Open with: Places > Home Folder. (In terminal: gksudo nautilus &)

  • The familiar file browser is good for reviewing folder contents and deleting specific folders/files.
  • Nautilus will show mount points (although not the contents of unmounted devices) even when a device is not mounted on the mount point.
  • Unless nautilus is opened with administrative privileges (gksudo nautilus &) certain folders/files such a root's Trash will not be visible. The folder may show no contents even though sub-folders or files exist.

  • Right click a folder and select Properties to display the size (for files) and free space remaining on the parent partition.



  • Open with: System > Administration > Partition Editor. (In terminal: gksudo gparted &)

    • gparted is a simple way of seeing how much of a partition the system thinks is used.

    • Partition > Information provides information on usage and free space percentage.


Checking Your Partitions via Command Line

Access the terminal via Applications > Accessories > Terminal or use CTRL-ALT-T, or use ALT-F2 and then enter the command in the top input area.

A brief note on df and du: It is beyond the scope of this guide to go into detail about how df and du report disk usage. They look at disk space differently and the results will not be the same. Generally the results of df will show more disk usage than those of du since it considers block size rather than just the specific file size. Additionally, df's results will include information about open files - those which are not currently written to disk but do exist in memory.

Terminal command results may include /proc/ entries. These are virtual file entries, are not the cause of lost disk space, and should be disregarded.

df (Disk Find)

Report file system disk space usage - check /dev/sd''XX''.

Since the df command provides details on mounted partitions you should run the df command after you have decided which devices you wish to investigate and have run the appropriate mount/umount command. By closing all applications and running sudo umount -a first, df commands are more likely to report only system partition information.

  • Deleted files in Trash are included in used space until completely removed from the system.
    • df -Th
      # Optionally: df -Th | grep -v "fs" | sort
  • Sample result:
    • /dev/sda1     ext3     15G  7.7G  6.3G  55% /
      /dev/sda2     ext3     15G  2.1G   12G  15% /media/data
      /dev/sdb2     ext3     48G   35G   11G  76% /media/backup
      Filesystem    Type    Size  Used Avail Use% Mounted on
  • Mounted NTFS partitions will be displayed as type: fuseblk.

du (Disk Usage)

Estimate file space usage - check your folders.

This command will show you how much space is being used by the mounted file systems on a given folder. If a device is mounted to a folder which already contains data, the underlying data size will not be included in the results. This means that if /media/data contains 40 GB of data, but a 20 GB partition is then mounted to /media/data, the results will show only the 20 GB of the last-mounted device (because the 40 GB are now inaccessible).

  • The --max-depth switch allows you to set how many sub-levels you wish to view. Once you have run the command starting at the top level ( / ) you can then investigate specific folders by replacing / with another starting point (for example, /var/log). This command reads the the disk contents when executed and thus will take a while to complete if the entire disk is to be searched. Using grep can help display only folders meeting specific criteria. Use sudo to gain access to system folders.

    • sudo du -h --max-depth=1 /

      # Optionally: sudo du -h --si --max-depth=1 / | grep '[0-9]G\>'

      The grep command reduces returns to folders 1 GB or larger (if du is run without the --si option, grep would then reduce returns to folders 1 GiB or larger).

  • Folder usage is recursive - that means that the command will report the total usage of the folder and its sub-folders. Used with the right switches and run as root, it is a good tool to quickly locate files/folders which use large amounts of disk space. Once the large folders are located, investigating them with other commands or a file browser probably will provide the best results for a new user. Remember that the du command reports information on mounted partitions.

  • Here is a sample of the sudo du / -h --si --max-depth=1 | grep '[0-9]G\>' command, which searches for folder/subfolders which use at least 1 GB of space:

    • du: cannot access `/proc/6793/fdinfo/3': No such file or directory
      1.8G    /media
      2.8G    /usr
      3.1G    /home
      8.9G    /

    Note: --max-depth limits the results to one level but includes the total disk usage of the folder and all subfolders. Once you identify a specific folder to investigate, you can substitute its address for / (e.g. /usr ) and/or increase the --max-depth=1 to a larger number.

find (Find)

Find a file or folder

  • The find command, used with the appropriate options, is an excellent tool to locate large files.
    • sudo find / -name '*' -size +1G
      # ''Optionally'': sudo find / -name '*' -size +500M
  • An initial Ubuntu installation will not normally have files larger than 500 MB on the system partition.
  • Starting with / will help ensure a thorough search of your entire system. You can specify a different starting point to speed up the search if you know which folder you want to search. Example: sudo find /var/log -name '*' -size +1G

  • The -name '*' option is included to show the format should the user wish to replace the universal search with a specific file name.

  • The difference between this command and the du command discussed previously is that this command will search only for individual files and not for folders. This would be a good choice to search for a backup file you think may have ended up in the wrong place.

Problems & Solutions

Partition Is Too Small

How to Find It:

  • If you plan on going throught the list from start to finish a logical starting point is the actual size of your partition. A quick review of the Ubuntu System Requirements shows that for a standard Ubuntu 14.04.2 LTS desktop installation the bare minimum is 4.5 GB. A recommended minimum would be about 8 GB. Of course, you can get by with less or need much more, depending on how many apps you install. Note: If you have a separate /boot partition, the minimum size depends on how many kernels you have installed, but users who created a separate /boot partition of 50 MB often run out of room!

Backup any important files before performing any partitioning operations. If the operations involve NTFS partitions, defragment them at least once as well.

How to Fix It:

  • Take Space from Another Partition. If you drive has another partition with extra space, reduce the size of one or more of them and expand the partition short of space. The partition must not be mounted. For system partitions unmount / and /swap. Repartitioning in Ubuntu is often accomplished using gparted, Ubuntu's default partition editor (System > Administration > Partition Editor). Since the system folder must be unmounted during resizing, gparted should be run from the LiveCD or a third party CD such as the GParted LiveCD or a SystemRescueCD.

  • Move /home. Move parts of your system, such as /home, to another location. Here is a link on how to move your `/home` folder, as well as another on how to move partitions in general.

  • Move data. Data files, music collections, video files, etc. can take up a lot of space. Creating a separate data partition on the same or another drive can provide more space for critical system files.

  • Try Xubuntu. If you just have a small hard drive or don't have the space to dedicate to a normal Ubuntu installation try Xubuntu. It is an official Ubuntu derivative which uses less resources. The minimum space required is only 2 GB; the recommended minimum is 20 GB.

Kernel installation failure

Some users created very small /boot partitions. If older kernels are not removed the partition may become full and this or a similar message may result: gzip: stdout: No space left on device update-initramfs: failed for /boot/initrd.img If the user has a separate /boot partition and/or received the previous warning, check the available space and the kernel in use:

  • df -Th | grep 'boot'  # Only if separate /boot partition exists.
    uname -r
  • To regain space in the /boot partition one of the easiest options is to remove older kernels with the Synaptic Package Manager. Open Synaptic and search for linux-image. Synaptic will display all installed kernels. Unused kernels can be safely removed; many experienced users keep at least one older kernel which they have previously used. The same kernel's linux-headers-... may also be uninstalled. Note that Ubuntu will not allow you to remove the current kernel while it is in use.

Back Ups Gone Wrong

On of the most common causes of disappearing disk space is a back up saved to the wrong location. Improperly designating the back up location is a frequent cause. It can also be the result of a file saved to a mount point on which no device, such as a back up drive, is mounted.

  • Example: A script calls for Simple Backup (sbackup) to back up a partition and automatically save the result to an external drive mounted on /media/backup. At the given time, the device is neither turned on nor mounted. Since the mount point exists, the file is created and saved in /media/backup, using up space on the system partition instead of on the planned external drive.

How to Find It:

For problems with your system partition, unmount all but your system folders using the sudo umount -a command discussed earlier.

  • Run the following command to search for files larger than 1 GiB (find has no option for power-of-ten sizes). Disregard findings which include /proc/.

    • sudo find / -name '*' -size +1G
  • Any file found larger than 1 GiB is a likely suspect for further investigation, especially any file found on one of the user's mount points. Mount points will normally be empty unless a device is mounted to it.
  • If the backup contains many smaller folders, such as a music collection, rather than look for one large file the user may wish to look at the combined folder size. In this case, run the following command. It will look for folders using more than 1 GB of space if the grep option is included.

    • sudo du -h --si --max-depth=1 / | grep '[0-9]G\>'
  • Once large folders are located, you can refine the search by identifying a specific folder as the starting point and/or increase the maxdepth level. The folders /usr, /root, and /home will normally be included in the results. If all your mount points are in the /media folder, your search might be: sudo du -h --max-depth=2 /media.

How to Fix It:

  • Move the file to another partition or delete it. If you delete it, you must use SHIFT-DEL in a file browser, the rm command via terminal, or empty your Trash (or root's for root-owned Trash) before the space is actually recovered and made available for use. Simply highlighting the item and hitting the DELETE key will move it to Trash, where it will continue to take up space. Warning: These delete methods cannot be reversed! Make sure you are deleting the correct item.

  • Amend the script. If the problem was the result of an automatic back up, amend the script or take steps to ensure the back up device is mounted prior to executing the script.

    • Tip: To help prevent this when using sbackup, the user can select the "Abort backup if destination directory does not exist" in the "Destination" tab during setup.

Trash Folders Not Empty

When a file or folder is deleted via a file browser in most cases it is not removed from the system. Instead it is placed in Trash. Until Trash is emptied, these files are recoverable and continue to take up space on the partition. There are several places on the system that deleted files are stored. It varies by which version of Ubuntu is running, the origin of the deleted folders/files, and who deleted them.

Example: A user downloads a collection of large .iso files or installation packages. Deciding not to use the files, the user deletes them using administrative privileges (as root). The user's Trash shows empty, the user can't find the files with his/her browser, but the free space isn't restored. In a different scenario, another user on the same machine deletes files but never empties Trash.

How to Find It:

  • Run the following command to locate all Trash folders in the system. This will find the Trash folders of all users as well as root. The second part of the command will display the size of the located folders.
    • sudo find / -type d -name '*Trash*' | sudo xargs du -h | sort

How to Fix It:

  • Empty the Trash completely. Items in Trash must be deleted in a special manner - otherwise they will be moved to the ...Trash!

    • Open a file browser with administrative privileges (gksudo nautilus &). Navigate to the Trash folder, highlight it and press SHIFT-DELETE. Using this key combination ensures the Trash folder is permanently deleted, The Trash folder contains two sub-folders, info and files. Deleting the parent Trash folder will delete both these folders. All three will be restored the next time something is deleted. Warning: These delete methods cannot be reversed! Make sure you are deleting the correct item.

Unexpectedly Large File

A single 'rogue' file may be consuming large amounts of space. Use the following command to locate abnormally large files.

How to Find It:

As mentioned earlier the user can use the find command to search for large files.

  • sudo find / -size +1G

How to Fix It:

Decide what the files are, if they are in the proper location, and whether or not you wish to retain them. If you delete a large file, either bypass the Trash bin with the rm command, SHIFT-DEL in nautilus, or empty the appropriate Trash bin after deleting it.

Too Many Collected Packages

Packages (.deb files) downloaded for installation by a user via the system (apt, synaptic, dpkg) are stored in /var/cache/apt/archives. Over time, this folder can become quite large. Under normal circumstances it is not necessary to keep packages locally; they can be retrieved from a server if re-installation is desired.

How to Find It: To check the amount of space being used for package storage, run:

  • du -h /var/cache/apt/

How to Fix It:

There are several system commands you can use to reduce or eliminate the number of locally stored packages.

  • Remove all the packages from /var/cache/apt/archives and /var/cache/apt/archives/partial folders:

  • sudo apt-get clean
  • Remove all expired packages from /var/cache/apt/archives and /var/cache/apt/archives/partial that are no longer available for download:

  • sudo apt-get autoclean

    "Not available for download" does not mean the user should save them - normally these files have been replaced or are no longer needed.

  • Remove unneeded dependencies which are no longer needed:

    • sudo apt-get autoremove
    • An application called APTonCD can save these packages to a CD/DVD if you want to preserve your .deb files prior to removing them.

Check Your Logs

Log files are usually stored in /var/log and its subfolders. An excessive number of small log files or large individual logs can eat up disk space.

How to Find It:

You can run the following to see the size of each /var/log/ subfolder:

  • sudo du -h /var/log

How to Fix It:

  • Change the manner log files are generated and stored.

  • Move or delete unnecessary log files, especially older files with more current entries. Archived *.gz log files are safe to delete.

  • Remove the contents of a particularly large log file if the user doesn't want to delete it. Remove the file's contents while keeping the file structure intact with the following command. Change the filename to the name of the actual file:

    • sudo cp /dev/null /var/log/log_filename.log

Cloned Partitions

When partitions are cloned to a partition of a different size (such as restoring a Partimage file to a larger partition), the partition table may need to be updated. How to Find It:

The size of a partition after cloning may reflect the original cloned partition size rather than the size of the partition into which it was restored. This is discussed in the Partimage user's manual. gparted may show the entire partition as used even when you know it isn't. How to Fix It:

Note: The following procedure is for ext2 and ext3 formatted partitions only. Change sd'''XX''' to the correct device designation (example: sd'''b3''')

  • # Unmount the new partition  Example: sudo umount /dev/sdb3
    sudo umount /dev/sdXX
    # Optionally, perform a check of the partition
    sudo e2fsck /dev/sdXX
    # Redraw the partition table to reflect the correct partition size
    sudo resize2fs -p /dev/sdXX
    # Check the results
    df -h

NTFS Partition Is Not Correctly Sized

No matter what the cause, it is possible an NTFS partition table fails to indicate the correct size of the partition.

How to Find It:

The size of a partition isn't what it should be. You can check the disk size by running df -Th -BGB /dev/sdXX. The command will indicate the file type (NTFS), size in GB (in GiB if -BGB is omitted or if -BG is used), used/remaining space and percentage free.

  • How to Fix It:

Note: You will be warned in the final stages of the operation to backup data and ensure a reliable power source. The warning may appear a bit intimidating but merely reflects precautions which should be taken any time a partition table is altered.

  • Replace /dev/sdXX with the correct partition designation. Example: Replace /dev/sdXX with /dev/sda1 if the device is /dev/sda1 When you remount the NTFS partition after resizing make sure the mount point exists. Example: /mnt/windows
  • sudo apt-get update
    sudo apt-get install ntfsprogs  # ntfsprogs is included in the 'main' repository.
    sudo umount /dev/sdXX
    sudo ntfsresize /dev/sdXX
    sudo mount /dev/sd/XX /path/mount_ point # Or 'sudo mount -a' if listed in fstab.
    df -Th    # Check the results

`lost+found` Folders

Each ext2/3/4 partition will contain a lost+found folder. This folder contains corrupted files discovered by the system during an fsck check.

How to Find It:

You can run the following to locate each lost+found folder and, optionally, see the size of each folder:

  • sudo find / -name `lost+found` | sudo xargs du -h

How to Fix It:

  • Delete them. Open a file browser with administrative powers (gksudo nautilus &) and inspect the contents of any large lost+found folder. If there is nothing recoverable, you may delete the folder. This folder will be recreated after the next fsck check.

If you delete it, you must use SHIFT-DEL in a file browser, the rm command via terminal, or empty your Trash (or root's for root-owned folders) before the space is actually recovered and made available for use. Simply highlighting the item and hitting the DELETE key will move it to Trash, where it will continue to take up space. Warning: These delete methods cannot be reversed! Make sure you are deleting the correct item.

Gain Just a Bit of Space

You can gain a bit of space by following these steps. Don't expect large free space gains.

How to Fix It:

  • Computer Janitor. Recent versions of Ubuntu come with an app which can locate unnecessary libraries and other files. Access it via System > Administration > Computer Janitor. There is another app located in Synaptic called cruft that can also locate and remove unnecessary files.

  • tune2fs. Reduce the space reserved for system use. By default, Ubuntu reserves 5% of linux partitions for use by the operating system. Some commands and applications do not accurately reflect reserved system space (gparted/baobab). Nautilus and the df command accurately display available usable space by accounting for reserved system space.

    • The amount of partition space reserved for this can be altered with tune2fs. Replace X with the percentage of disk space you wish to reserve and XX with the device designation.

      sudo tune2fs -m X /dev/sdXX
      Example: sudo tune2fs -m 4 /dev/sda1 Note: There is a reason Ubuntu reserves this space. Carefully consider if you want to change this setting before doing so.
  • deborphan / gtkorphan. Install deborphan, a command-line application, and gtkorphan, a gui-based application. These programs help find and eliminate orphaned libraries which are no longer needed.

    • sudo apt-get install deborphan gtkorphan
    • deborphan. This app can identify orphaned packages. To run it:

      • sudo deborphan
    • gtkorphan. System > Administration > Remove orphaned packages. This application will allow the user to identify and delete selected orphan libraries.

  • localepurge. A number of language packages may be installed on the system. localepurge can be installed and run to remove and prevent future installation of extra language packages that the user does not use. Read the man page for warnings about its use.

Install Apps When the Disk is Full

Well, almost full. Use this technique when you don't have the space to download apps and then install them from cache.

  • Download the packages without installing them.
    • sudo apt-get upgrade -d
  • Move the downloaded packages to an external source or another partition.
  • Remove any remaining cached packages.
    • sudo apt-get clean
  • Install the packages from the external source.
    • sudo dpkg -i /media/disk/*.deb
      # Replace /media/disk with the path to the stored packages.






RecoverLostDiskSpace (last edited 2017-09-03 16:13:59 by ckimes)