User Tools

Site Tools


computing:disk_space_low

This is an old revision of the document!


Dealing with Low Disk Space

Linux

du -sh /*

rm -rf /tmp/*
rm -rf /var/tmp/*

Remove Old Kernels

:!: Uses aptitude package manager.

Paste this ant the CLI then run rmkernel to remove all kernels except your running kernel.

rmkernel () {
        local cur_kernel=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
        local kernel_pkg="linux-(image|headers|ubuntu-modules|restricted-modules)"
        local meta_pkg="${kernel_pkg}-(generic|i386|server|common|rt|xen|ec2)"
        sudo aptitude purge $(dpkg -l | egrep $kernel_pkg | egrep -v "${cur_kernel}|${meta_pkg}" | awk '{print $2}')
}

Windows

Empty Recycle Bin for All Users

For Windows 7 or Server 2008 enter this command:

rd /s c:\$Recycle.Bin

For Windows XP, Vista, or Server 2003 enter this command:

rd /s c:\recycler

Disable Hibernation

Delete hiberfil.sys:

powercfg.exe -h off

Tools

TreeSize Free is a very useful tool for finding the problem:

http://www.jam-software.com/treesize_free/

This is a short script that is probably best used as an emergency 'free space now' tool:

@echo off
rem Script to clean up disk space on SBS 2008 servers
rem Downloaded from SBSfaq.com
rem V1.0 - March 28th, 2010
rem Certificate Services Logs
net stop "Active Directory Certificate Services"
del c:\windows\system32\certlog\*.log
del c:\windows\system32\certlog\*.chk
del c:\windows\system32\certlof\*.jrs
net start "Active Directory Certificate Services"
rem IIS Log Files
Del C:\inetpub\logs\LogFiles\*.log /f /s

CleanUp may be useful to clean up Windows Profiles:

https://bitbucket.org/dev247/cleanup/overview

On New Systems

If you are building new systems:

http://support.microsoft.com/kb/949977

Windows 2008 and R2

https://support.appliedi.net/index.php?/Knowledgebase/Article/View/992/0/how-to-enable-the-disk-cleanup-tool-on-windows-server-2008-r2

On 2008 R2, at an administrative command prompt:

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe %systemroot%\System32

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui %systemroot%\System32\en-US

Cleanmgr.exe
computing/disk_space_low.1434389538.txt.gz · Last modified: 2015/06/15 11:32 by gcooper