Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: HOWTO: Recover Lost Disk Space

  1. #1
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Lightbulb HOWTO: Recover Lost Disk Space

    Disk Space Problems & Solutions

    This guide was created to help users who are having issues with disk space, or lack thereof. It presents various reasons why free space may have unexpectedly disappeared or changed, and how to locate and remove the files which now may be occupying this space.

    The primary focus is on restoring space on the system partition ( / ) but the commands can easily be modified for other partitions as well. Although Linux 'thinks' of everything as a file, I will often refer to folders, partitions, and devices to keep things simpler for users transitioning from other operating systems.

    This guide is an outgrowth of a tutorial covering residual Trash files. If you know your issue is related to Trash, please refer to Disk Full? - Check Your Trash Bin(s) for a more comprehensive treatment of that subject.

    In a Rush? ... Go Directly to # 6 for possible solutions or to # 8 for a step-by-step summary.

    A Note to Wubi Users: While the same things that steal disk space from a normal Ubuntu installation can occur in Wubi, and the methods below will work, it is also possible that you did not allocate enough space within Windows for the Wubi file. If you find you need to increase the size of the Wubi folder, please visit this site: HOWTO: Resize the WUBI virtual disk

    1. Error Messages - Why You Are Here?
    "There is not enough room on the disk to save ..." or perhaps you received an error message about "insufficient disk space". Perhaps you looked at your system with a file browser or Disk Usage Analyzer and realized that you were running out of disk space. Maybe your system is reporting a partition full when you know it isn't. This thread presents ways to discover what is using large portions of your disk space and how to regain some free space.

    2. Where Did My Free Space Go? - Common Causes
    • A partition, such as / or /boot, is too small. (See # 6a).
    • Backup files were mistakenly saved to the wrong location. (See # 6b)
    • Deleted files in the trash bin are still on your system taking up disk space. (See # 6c)
    • You unknowingly created a large file. (See # 6d)
    • Downloads have accumulated in /var/cache/apt/archives. (See # 6e)
    • Various log files have increased in size and/or number. (See # 6f)
    • Your cloned partition doesn't show the new partition's correct size. (See 6g)
    • Your NTFS partition shows the incorrect size. (See 6h)
    • The contents of your "lost+found" folders have grown. (See #6i)
    • You just need a bit more space. (See # 6j)
      • This includes not being able to install a new kernel.


    3. An Important Note About Mounting Options, Permissions, and Deletions
    • Mounting. Many of the commands and applications mentioned in this post present information only on mounted partitions. If you execute the command without first running one of the mount/unmount commands below, you will see information on only the devices that are currently mounted.

      For troubleshooting, one of the first things you have to determine is what devices (partitions, drives, etc) you want to look at. If you are having a problem with system space, you would normally want to look only at system folders and not additional devices. At best the additional mounted devices just provide extra results - at worst a mounted device might hide a problem with underlying data on the same mount point (see du).

      To view only the system folders, first close all open applications and then run the following. 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.
      Code:
      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.
      Code:
      sudo mount -a
    • Permissions. Remember that when running commands or applications as a user you will see only files you have permission to see. This may prevent you from seeing files created or stored in system folders that may be taking up the space you have lost. To ensure you can view all the files on your computer if you have 'root' privileges 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. To free up space, you can:
      • 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 Hardy, these are located at ~/.local/share/Trash and /root/.local/share/Trash, respectively.

      Warning: SHIFT-DELETE and "rm" cannot be reversed. Make sure you are deleting the correct item(s).


    4. Checking Your Partitions via Terminal (CLI)

    To open a terminal, either use the Main Menu (Applications, Accessories, Terminal) or use ALT-F2, enter the command(s) in the top input area, and tick/enable "Run in terminal" to open a terminal window, .

    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 left alone.

    • df - Report file system disk space usage (Check your /dev/sdXX's)

      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. If you first run the "sudo umount -a" command the "df" results will usually report only your system partition information if all other applications are closed. Review Section 3 for mounting/unmounting options.

      Note that deleted files in Trash are included in used space until completely removed from the system.

      Code:
      df -Th
      Optionally: df -h or df -Th | sort or df -Th | grep -v "fs" | sort

      Here is a sample of the "df -Th | grep -v "fs" | sort" command:
      Code:
      /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
      Note: "sort" will order the partition results. The "T" switch shows the file type - you can omit it if desired. The "h" switch lists file sizes in "human" terms. Mounted NTFS partitions will be displayed as type: "fuseblk".

    • du - 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. One disadvantage of du is that it reports information only on mounted files. Additionally, 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 40GB of data, but a 20GB partition is then mounted to /media/data, the results will show only the 20GB of the last-mounted device.

      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. For best results, umount any non-system partitions first.

      Code:
      sudo du -h --max-depth=1 /
      sudo find . -maxdepth 1 -type d ! -name . -exec du -sh '{}' \; | sort -h  # Subfolders in current folder, sorted by size
      
      Optionally: sudo du -h --max-depth=1 / | grep '[0-9]G\>' (This combination reduces returns to folders 1GB 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. Refer to Section 3 for mounting/unmounting options.

      Here is a sample of the sudo du / -h --max-depth=1 | grep '[0-9]G\>' command, which searches for folder/subfolders which use at least 1GB of space:
      Code:
      du: cannot access `/proc/6793/fdinfo/3': No such file or directory
      1.8G	/media
      2.8G	/usr
      3.1G	/home
      8.9G	/
      Notes: "--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 a file or folder)
      The find command, used with the appropriate options, is an excellent tool to locate large files.
      Code:
      sudo find / -name '*' -size +1G
      or
      sudo find / -name '*' -size +500M
      In the above examples, +1G searches for files larger than 1GB. +500M looks for files larger than 500MB. You can adjust the sizes to suit your needs. An initial Ubuntu installation will not normally have files larger than 500MB 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

      Strictly speaking, you don't even need to include the "-name '*'" option. It is included to show the format should you wish to replace the universal search with a specific file name ( example: -name 'sbackup.tar.gz' )

      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 if you were searching for a backup file you think may have ended up in the wrong place.


    5. Checking Your Partitions Graphically (GUI)
    • Gnome-Device-Manager
      System > Administration > System Monitor: File Systems tab. (In terminal: gnome-system-manager or preferably gksudo gnome-system-manager)

      As with the "df" command, the information presented includes only currently mounted devices. Review Section 3 for more information on mounting/unmounting options. Trash is considered used space.

      This is the information displayed in the File Systems tab. System Monitor will, of course, present it graphically.
      Code:
      Device      Dir     Type   Total     Free      Available   Used     %
      /dev/sda2   /home   ext3   33.1GiB   31.1GiB   29.4GiB     2.0GiB   6%
      The "System" tab lists the available disk space on the system ( / ) partition.

    • Disk Usage Analyzer / baobab
      Applications > Accessories > Disk Usage Analyzer. (In terminal: baobab or preferably gksudo baobab )

      Disk Usage Analyzer reports information only on mounted devices. Refer to Section 3 for more information on mounting/unmounting options
      .
      While DUA provides valuable information, it 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.
      • 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 15GB, a data partition of 30GB, and an external drive mounted on /media/backup of 30GB, it will report a total of 75GB. 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 unticking 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, baobad may be including the .gvfs (a virtual file system). You may be able to de-select 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, opening DUA with "gksudo baobab will provide the most accurate assessment of disk usage.
      • To narrow the search, you can expand a folder to see what amount of disk space each of the sub-folders is using.


    • Nautilus
      Places > Home Folder. (In terminal: nautilus or preferably 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 "Empty" even though sub-folders or files exist. For viewing the contents of your system, I recommend running nautilus with root privileges ("gksudo nautilus").
      • Right click a folder and select "Properties" to display the size (for files) and free space remaining on the parent partition.


    • Gparted
      System > Administration > Partition Editor. (In terminal: gksudo gparted)

      For checking total disk usage on a given partition, gparted is a simple way of seeing how much of a partition the system thinks is used.


    6. PROBLEMS & SOLUTIONS
    • a. 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 desktop installation the bare minimum is 4GB and the recommended minimum is 8GB. These are recommended minimums. 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 50MB 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 your / partition (or another running out of space). To resize any system partition, the / partition (and perhaps /swap) must not be in use/mounted). Repartitioning in Ubuntu is normally accomplished with an application called "gparted". (System > Administration > Partition Editor). You can run gparted from the LiveCD. You can also use other CD/DVD/USBs which contain gparted, such as the GParted Live CD or a SystemRescueCD.
        It is beyond the scope of this guide to present details of how to use gparted, however this guide and this one can help.

      • Move /home. Move parts of your system, such as /home, to another location. Here is a link on how to move your /home folder:
        Create a separate home partition in Ubuntu

      • Move data files to another location. 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.

      • 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:
        Code:
        df -Th | grep 'boot'
        uname -r
        If you are out of space, the easiest option is to remove older kernels via synaptic. Open synaptic, search for "linux-image". Synaptic will display all kernels, current and former. You can safely remove one or more older kernels although many experienced users keep at least one older kernel. You can also remove the same kernel's "linux-headers-..." Ubuntu will not allow you to remove the current kernel while it is in use.

      • Try a lighter version of Ubuntu. If you just have a small hard drive or don't have the space to dedicate to a normal Ubuntu installation, you can try Xubuntu, an official Ubuntu derivative which uses less resources. The minimum space required is only 1.5GB, with the recommended minimum minimum is 6GB.


    • b. Backups Gone Wrong!
      On of the most common causes of disappearing disk space is a backup saved to the wrong location. Besides just improperly designating the backup location, this can also be the result of a file being saved to a mount point on which no device, such as an internal or external backup drive, is mounted.

      Example: A script calls for Simple Backup (sbackup) to backup 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 backup 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 in Section 3.
      • Run the following command detailed in Section 4. The option searches for files larger than 1GB. Disregard findings which include "/proc/".
        Code:
        sudo find / -name '*' -size +1G
      • Any file found larger than 1GB 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 detailed in Section 4. The command will look for folders using more than 1GB of space if the "grep" option is included.
        Code:
        sudo du -h --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 could might look like "sudo du -h --max-depth=2 /media".



      How to Fix It:

      • Once you have found the file, either move it to a location on a different 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.
      • If the problem was the result of an automatic backup, amend the script or take steps to ensure the backup device is mounted prior to executing the backup script.

        • luisjeronimo offered this 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.


    • c. 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.
        Code:
        sudo find / -type d -name '*Trash*' | sudo xargs du -h | sort

      How to Fix It:

      • 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.


      For a detailed tutorial on the Ubuntu Trash system, please go to: Disk Full? - Check Your Trash Bin(s)

    • d. 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 in Section 4, you can use the "find" command to search for large files. If you completed # 6a. you have already run this command.
      Code:
      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.

    • e. 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:
      Code:
      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.
      • To remove all the packages from /var/cache/apt/archives and /var/cache/apt/archives/partial folders:
        Code:
        sudo apt-get clean
      • To remove all expired packages from /var/cache/apt/archives and /var/cache/apt/archives/partial that are no longer available for download:
        Code:
        sudo apt-get autoclean
        "Not available for download" does not mean you should save them - normally you don't.
      • To remove packages that were installed to satisfy dependencies for other applications but which are no longer needed:

        Code:
        sudo apt-get autoremove
        There is an application called APTonCD that can save these packages to a cd/dvd if you want to preserve your .deb files prior to removing them.


    • f. 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:
      Code:
      sudo du -h /var/log
      How to Fix It:

      • Determine which process is generating the log files and try to change its behavior.
      • Move or delete unnecessary log files, especially older files with more current entries. Archived *.gz log files are safe to delete.
      • If you find a particularly large log file and you don't want to delete it, you can remove its contents while keeping the file structure intact with the following command. Change the filename to the name of the actual file:
        Code:
        sudo cp /dev/null /var/log/log_filename.log
      • If you find a large log file, inspect the contents to find out what is generating the messages. Correcting the underlying problem which generated the messages will prevent the log file issue from reoccurring.


    • g. Cloned Partitions Folders
      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 "sdXX" to the correct device designation (example: sdb3)
      Code:
      sudo umount /dev/sdXX        # unmount the new partition  Example: sudo umount /dev/sdb3
      sudo e2fsck /dev/sdXX        # Optionally, perform a check of the partition
      sudo resize2fs -p /dev/sdXX  # redraw the partition table to reflect the correct partition size
      df -h                        # Check the results

    • 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 /dev/sdXX". The command will indicate the file type (NTFS), size in GB, 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
      Code:
      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  (If listed in fstab, 'sudo mount -a' will mount it.)
      df -Th    # Check the results

    • i. lost+found Folders
      Each ext2/3 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:
      Code:
      sudo find / -name "lost+found" | sudo xargs du -h
      How to Fix It:

      • 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.


    • j. 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 accumulated 'cruft' - stuff that doesn't need to be on your system.
      • 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.
        Code:
        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.

      • 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.
        Code:
        sudo apt-get install deborphan gtkorphan
        • "deborphan" can identify orphaned packages.To run it:
          Code:
          sudo deborphan
        • To run "gtkorphan", System > Administration > "Remove orphaned packages". GtkOrphan 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 it's use.


    7. Other Issues
    When investigating this topic, run everything as root ( sudo / gksudo) to ensure as much consistency as possible.
    • New Hard Drives. New hard drives will not contain the space shown on the packaging. For example, a 1TB drive normally starts with about 931GB of space. Additionally, linux file systems by default reserve 5% of the space for system use.
    • Reporting Inconsistencies. Unfortunately disk usage is not uniformly reported throughout the range of applications. Total usable disk space is generally consistent. Space reserved for system use (and thus unavailable) is accounted for with the "df" command and in nautilus but is shown as available in GParted and baobab/Disk Usage Analyzer.



    8. The Five Minute Guide
    Let's just get on with it!
    • Determine what you need mounted.
    • Run everything with administrative powers (gksudo nautilus, etc).
    • When you discover the problem, refer to the appropriate section above for tips on how to fix it.
    • When you are done deleting items make sure all Trash is removed from the user's and root's Trash folders.
    • If you get stuck, read the guide! Good luck.
      For system partition ( / ) troubles:
      sudo umount -a # keep only / mounted, disregard "busy" messages (#3)

      To inspect all partitions:
      sudo mount -a # mount all devices in fstab, then manually mount the rest (#3)

      Confirm partition/disk usage (partition size, used, remaining):
      df -Th | grep -v "fs" | sort # confirm partition usage (#4)

      Search generally for large folders/files:
      sudo du -h --max-depth=1 / | grep '[0-9]G\>' # find large folders > 1GB (#4)
      sudo find / -name '*' -size +500M # find large files > 500MB (#4/6c)

      Target Specific Partitions/Folders:
      sudo find / -type d -name '*Trash*' | sudo xargs du -h | sort # check for Trash (#6b)
      sudo du -h /var/cache/apt/ # check for a large cache of .deb files (#6d)
      sudo du -h /var/log # check for large log folders

      Ensure your Trash bins aren't 'full':
      sudo find / -type d -name '*Trash*' | sudo xargs du -h | sort # check for Trash (#6b)

      Recheck your disk space:
      df -Th | grep -v "fs" | sort
    Last edited by drs305; November 11th, 2011 at 05:15 PM.
    Back to Xorg...

    Retired.

  2. #2
    Join Date
    Oct 2009
    Location
    Auckland New Zealand
    Beans
    17

    Smile Re: HOWTO: Recover Lost Disk Space

    Thanks for a good guide for clearing out some unused or un-needed files to free up some space. Good for us who are using old netbooks with solid state hard drives and have limited space.

    Ian

  3. #3
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: HOWTO: Recover Lost Disk Space

    Quote Originally Posted by zl1ogx View Post
    Thanks for a good guide for clearing out some unused or un-needed files to free up some space. Good for us who are using old netbooks with solid state hard drives and have limited space.

    Ian
    Your welcome.

    Now I'm going to have to figure out how every post from the original posting date from April 2009 until your's has disappeared.

    Now that's some kind of clean up!
    Back to Xorg...

    Retired.

  4. #4
    Join Date
    Nov 2009
    Beans
    Hidden!
    Distro
    Kubuntu 10.10 Maverick Meerkat

    Re: HOWTO: Recover Lost Disk Space

    Thanks for the great article drs.

    One point to note - There are some instances when cron fails to run or /var/log/syslog or some other log fills up. It is good for the user to open up these logfiles (system->admin->logfileviewer) to view these files and see what the errors are. Most times it is the same error message repeated over and over indicating a system problem. Example ufw log mode set to a medium on high logging. If cron fails to run, logrotate fails too causing massive logfile dumps. Moving/deleting these does create the space but does not solve the underlying problem.
    I would also recommend the use of bleachbit that does some cleaning automatically.

  5. #5
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: HOWTO: Recover Lost Disk Space

    @ john newbuntu,

    Good tip! I've included it in the log file section. Thanks.
    Back to Xorg...

    Retired.

  6. #6
    Join Date
    Oct 2010
    Beans
    1

    Re: HOWTO: Recover Lost Disk Space

    This is a very useful guide. Thank you for sharing. This will be very handy.

  7. #7
    Join Date
    Jun 2009
    Location
    South Coast UK
    Beans
    606
    Distro
    Ubuntu 19.10 Eoan Ermine

    Re: HOWTO: Recover Lost Disk Space

    I ve got discc space problems and I suspect its to do with my lost+found folders, but for some reason terminal will not let me do anything-yesterday it said I was typing the wrong password (I wasnt) today the cursor simply moves down the terminal after I enter the password or the password is displayed (usually it isnt) but nothing happens in the terminal.

    Anyone got any ideas why it wont let me sign in as root?

    Very strange terminal will run some commands but not others, some folders are locked and when I right click most options are greyed out, so I cant for instance delete log files in /va/log and there is apparently 46Gb worth of files in /var/log which seems like it might be the root of my problem. I also now dont get a "delete" option when I right click, I only get move to rubbish bin.
    Last edited by typos1; January 17th, 2011 at 02:50 PM.
    HP EliteBook 745 G2 AMD A10 Pro-7350B/Radon R6 Graphics/15Gb RAM - Desktop Conversion

  8. #8
    Join Date
    Jun 2009
    Location
    South Coast UK
    Beans
    606
    Distro
    Ubuntu 19.10 Eoan Ermine

    Re: HOWTO: Recover Lost Disk Space

    Anyone?
    HP EliteBook 745 G2 AMD A10 Pro-7350B/Radon R6 Graphics/15Gb RAM - Desktop Conversion

  9. #9
    Join Date
    Nov 2005
    Location
    Mountains of SW Virginia
    Beans
    99
    Distro
    Ubuntu

    Re: HOWTO: Recover Lost Disk Space

    I want to thank you as well for this extensive guide. Obviously it took you a long time to prepare, but, from the looks of it, time well spent. Thank you again. Your efforts are appreciated.

    Later...

  10. #10
    Join Date
    Oct 2010
    Beans
    23

    Re: HOWTO: Recover Lost Disk Space

    Thanks for preparing this guide. Here, I have a hard-disk space related problem --- I suddenly lost all of the disk free space---after some trial and error, I finally address it using the
    Code:
    sudo touch /forcefsck
    and then restart to do a disk checking...From this, can I say it is a case of false drive space report? This always happens after a large amount of i/o operations. (I am using Kubuntu 10.04,recently updated)

    I hope that this issue can bring attention to users having this problem, and that someone can inform the developers about this bug.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •