特殊:Badtitle/NS100:EmptyDiskSpace
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/EmptyDiskSpace }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/af | • {{#if: UbuntuHelp:EmptyDiskSpace|Afrikaans| [[::EmptyDiskSpace/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/ar | • {{#if: UbuntuHelp:EmptyDiskSpace|العربية| [[::EmptyDiskSpace/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/az | • {{#if: UbuntuHelp:EmptyDiskSpace|azərbaycanca| [[::EmptyDiskSpace/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/bcc | • {{#if: UbuntuHelp:EmptyDiskSpace|جهلسری بلوچی| [[::EmptyDiskSpace/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/bg | • {{#if: UbuntuHelp:EmptyDiskSpace|български| [[::EmptyDiskSpace/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/br | • {{#if: UbuntuHelp:EmptyDiskSpace|brezhoneg| [[::EmptyDiskSpace/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/ca | • {{#if: UbuntuHelp:EmptyDiskSpace|català| [[::EmptyDiskSpace/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/cs | • {{#if: UbuntuHelp:EmptyDiskSpace|čeština| [[::EmptyDiskSpace/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/de | • {{#if: UbuntuHelp:EmptyDiskSpace|Deutsch| [[::EmptyDiskSpace/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/el | • {{#if: UbuntuHelp:EmptyDiskSpace|Ελληνικά| [[::EmptyDiskSpace/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/es | • {{#if: UbuntuHelp:EmptyDiskSpace|español| [[::EmptyDiskSpace/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/fa | • {{#if: UbuntuHelp:EmptyDiskSpace|فارسی| [[::EmptyDiskSpace/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/fi | • {{#if: UbuntuHelp:EmptyDiskSpace|suomi| [[::EmptyDiskSpace/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/fr | • {{#if: UbuntuHelp:EmptyDiskSpace|français| [[::EmptyDiskSpace/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/gu | • {{#if: UbuntuHelp:EmptyDiskSpace|ગુજરાતી| [[::EmptyDiskSpace/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/he | • {{#if: UbuntuHelp:EmptyDiskSpace|עברית| [[::EmptyDiskSpace/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/hu | • {{#if: UbuntuHelp:EmptyDiskSpace|magyar| [[::EmptyDiskSpace/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/id | • {{#if: UbuntuHelp:EmptyDiskSpace|Bahasa Indonesia| [[::EmptyDiskSpace/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/it | • {{#if: UbuntuHelp:EmptyDiskSpace|italiano| [[::EmptyDiskSpace/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/ja | • {{#if: UbuntuHelp:EmptyDiskSpace|日本語| [[::EmptyDiskSpace/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/ko | • {{#if: UbuntuHelp:EmptyDiskSpace|한국어| [[::EmptyDiskSpace/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/ksh | • {{#if: UbuntuHelp:EmptyDiskSpace|Ripoarisch| [[::EmptyDiskSpace/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/mr | • {{#if: UbuntuHelp:EmptyDiskSpace|मराठी| [[::EmptyDiskSpace/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/ms | • {{#if: UbuntuHelp:EmptyDiskSpace|Bahasa Melayu| [[::EmptyDiskSpace/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/nl | • {{#if: UbuntuHelp:EmptyDiskSpace|Nederlands| [[::EmptyDiskSpace/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/no | • {{#if: UbuntuHelp:EmptyDiskSpace|norsk| [[::EmptyDiskSpace/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/oc | • {{#if: UbuntuHelp:EmptyDiskSpace|occitan| [[::EmptyDiskSpace/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/pl | • {{#if: UbuntuHelp:EmptyDiskSpace|polski| [[::EmptyDiskSpace/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/pt | • {{#if: UbuntuHelp:EmptyDiskSpace|português| [[::EmptyDiskSpace/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/ro | • {{#if: UbuntuHelp:EmptyDiskSpace|română| [[::EmptyDiskSpace/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/ru | • {{#if: UbuntuHelp:EmptyDiskSpace|русский| [[::EmptyDiskSpace/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/si | • {{#if: UbuntuHelp:EmptyDiskSpace|සිංහල| [[::EmptyDiskSpace/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/sq | • {{#if: UbuntuHelp:EmptyDiskSpace|shqip| [[::EmptyDiskSpace/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/sr | • {{#if: UbuntuHelp:EmptyDiskSpace|српски / srpski| [[::EmptyDiskSpace/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/sv | • {{#if: UbuntuHelp:EmptyDiskSpace|svenska| [[::EmptyDiskSpace/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/th | • {{#if: UbuntuHelp:EmptyDiskSpace|ไทย| [[::EmptyDiskSpace/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/tr | • {{#if: UbuntuHelp:EmptyDiskSpace|Türkçe| [[::EmptyDiskSpace/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/vi | • {{#if: UbuntuHelp:EmptyDiskSpace|Tiếng Việt| [[::EmptyDiskSpace/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/yue | • {{#if: UbuntuHelp:EmptyDiskSpace|粵語| [[::EmptyDiskSpace/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/zh | • {{#if: UbuntuHelp:EmptyDiskSpace|中文| [[::EmptyDiskSpace/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/zh-hans | • {{#if: UbuntuHelp:EmptyDiskSpace|中文(简体)| [[::EmptyDiskSpace/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:EmptyDiskSpace | UbuntuHelp:EmptyDiskSpace | {{#if: | :}}EmptyDiskSpace}}/zh-hant | • {{#if: UbuntuHelp:EmptyDiskSpace|中文(繁體)| [[::EmptyDiskSpace/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:EmptyDiskSpace|:EmptyDiskSpace|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :EmptyDiskSpace/zh | | {{#ifexist: EmptyDiskSpace/zh | | {{#ifeq: {{#titleparts:EmptyDiskSpace|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:EmptyDiskSpace|1|-1|}} | zh | | }}
<<Include(Tag/StyleCleanup)>>
Introduction
Did you ever wasted time investgating software problems or application crashes only to find out that it was caused by a full hard disk? The following simpel script warns if your hard disk runs out of available disk space.
Installation
1. Open a text editor with sudo to create the file /usr/local/bin/monitordiskspace.
gksudo gedit /usr/local/bin/monitordiskspace
2. Copy the following script into the text editor:
#!/bin/sh # This script is an adapted from Hans Zoebelein's ([email protected]) # script found at http://www.faqs.org/docs/Linux-HOWTO/Tips-HOWTO.html#ss2.3 # # Shoot and forget: Put 'check_hdspace &' in rc.local. # Checks for available space on devices every $SLEEPTIME sec. # You even might check your floppies or tape drives. :) # If available space is below $MINFREE (kb), it will echo a warning # and send one mail for each triggering device to $MAIL_TO_ME. # If there is more available space than trigger limit again, # mail action is also armed again. # # TODO: # Detect partitions automatically at startup # Different $MINFREE for each device. # Free /*tmp dirs securely from old junk stuff if no more free space etc. # Check https://wiki.ubuntu.com/FullFilesystemSanityGutsy and # https://wiki.ubuntu.com/HardyFullDiskHandling for the whole picture. DEVICES='/dev/sda2' # device; your put disks here, separated by blanks MINFREE=20480 # kb; below this do warning SLEEPTIME=10 # sec; sleep between checks # ------- no changes needed below this line (hopefully :) ------- MINMB=0 ISFREE=0 MAILED="" MINMB=`expr $MINFREE / 1024` # yep, we are strict :) while [ 1 ]; do DF="`/bin/df`" for DEVICE in $DEVICES ; do ISFREE=`echo $DF | sed s#.\*$DEVICE" "\*[0-9]\*" "\*[0-9]\*" "\*## | sed s#" ".\*##` if [ $ISFREE -le $MINFREE ] ; then ISMB=`expr $ISFREE / 1024` if [ -z "`echo $MAILED | grep -w $DEVICE`" ] ; then MAILEDH="$MAILED $DEVICE" MAILED=$MAILEDH if $( zenity --question --text "WARNING: $DEVICE only $ISMB mb free. (Trigger is set to $MINMB mb) Do you want to empty trash and erase downloaded software archive files?" ) then rm -r ~/.local/share/Trash/info/* rm -r ~/.local/share/Trash/files/* gksudo apt-get clean # put further action here like cleaning # up */tmp dirs... fi fi elif [ -n "`echo $MAILED | grep -w $DEVICE`" ] ; then # Remove mailed marker if enough disk space # again. So we are ready for new mailing action. MAILEDH="`echo $MAILED | sed s#$DEVICE##`" MAILED=$MAILEDH fi done sleep $SLEEPTIME done
3. Adapt the variable "DEVICES" to include your relevant devices. It should include your root and your home partition (if differ). Use the command "mount" to get a list of your devices.
Optional: Adapt "MINFREE" to your requirements. 4. Save the file and close the text editor. 5. The script should be started automatically at each system start resp. login. Therefore we need to select System -> Preferences -> Sessions. Select "add" and write the name "monitor disk space" and the command "/usr/local/bin/monitordiskspace" while the comment can be left blank. Close the dialog with "OK".
Note: This needs to be configured for every user who should be informed in case of empty disk space. 6. Close the current session and login to Ubuntu again.
The script will be executed silently in the background. If the disk space runs full the current user is warned and prompted to empty her trash bin and erase downloded software packages.
See Also
For the big picture see the following links.
- https://wiki.ubuntu.com/FullFilesystemSanityGutsy
- https://wiki.ubuntu.com/HardyFullDiskHandling
- A similar script can be found here.
<- The categories section helps organise pages. A full list of page categories can be found at