Differences between revisions 29 and 82 (spanning 53 versions)
Revision 29 as of 2009-06-15 20:32:06
Size: 4666
Editor: FranklinPiat
Comment: Use new DebianPkg interwiki link
Revision 82 as of 2020-03-16 13:23:41
Size: 9948
Comment: merged here DiskFull, removed category redundandt (IMO ReduceDebian deals with reducing the footprint of a new installation mostly, rather than space issues in a ongoing system)
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
''Translation'' [[https://wiki.debian.org/de/FreeSpace|Deutsch]]
= Freeing Disk Space =
If you think you are running near the end of your disk space, this information may help you.

Firstly confirm what devices you have, whether they are mounted or not. Run (as root or sudo) {{{
fdisk -l
}}} Then see which of those are mounted and what space is available on them by typing in a console {{{
df -hT
}}} or in X Windows, run the program {{{kdf}}}.

If you feel that you need to free up some space, here are a few tips and tricks.
== Command line tools to see seldom used files ==
 * DebianPkg:agedu : will not function if file system option noatime is used.
== Command line tools to see which package are using the most disk space: ==
## page was renamed from FreeSpace
#language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: [[de/FreeSpace|Deutsch]] - English - [[it/FreeSpace|Italiano]]-~
----
= 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]].

<<TableOfContents(2)>>

= See partitions and discs usage =

First of all, to see the existing partitions, use:

{{{
sfdisk -l
}}}

Then to check which partitions are getting full use:

{{{
$ df -lhT
}}}
 or
{{{
$ 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}}} in package DebianPkg:gnome-utils or the command line program {{{du}}} in the package DebianPkg:coreutils that can be used like this:

{{{
/usr/bin/du --total --summarize --human-readable --one-file-system
}}}

See also DebianPkg:ncdu.

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 ==
 * kernel packages are large; older versions are not removed automatically for your safety.

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.
Line 21: Line 71:
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' 
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'
Line 32: Line 82:
aptitude -F '%I %p' search '~i'|egrep '^[0-9]+[\.,]?[0-9]*[MG]B'|sort -n
}}}
aptitude -F '%I %p' search '~i'|egrep '^[0-9]+[\.,]?[0-9]* [MG]B'|sort -n
}}}

== Remove some cruft ==

Purge obsolete configuration files:{{{
aptitude purge ~c
}}}
##Purge obsolete packages:{{{
##aptitude purge ~o
##}}}

Take a look at the Debian Cleanup Tips at http://raphaelhertzog.com/mastering-debian/.
Line 41: Line 102:
== Tools to erase ==
=== files you do not want ===
Sort installed packages by size:
{{{
dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -n
}}}

== Graphical Interface ==
{{{synaptic}}}, go to installed packages and click on the size
column.

= Find things to erase =
== Categorically Expendable Directories ==
=== Temporary ===
{{{
/tmp
/var/tmp
}}}
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 ===
{{{
/var/log
}}}

=== Cache ===
 * packages in {{{/var/cache/apt/archives}}} usually eats some space. As root or using sudo, you can get rid of them with:

{{{
apt-get clean
}}}
or
{{{
aptitude clean
}}}

Use {{{apt-get autoclean}}} if you want to remove old packages for which you also have the last package.

=== Spool ===
Things in
{{{
/var/spool
}}}
are intended to be processed but may be expendable.

== Command line tools to see seldom used files ==

These function only if file systems are usually mounted with option {{{strictatime}}}.

 * DebianPkg:agedu
 * DebianPkg:findutils : {{{/usr/bin/find}}}

=== /usr/bin/find ===
The following options are of special interest

 * {{{-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 ===
 * DebianPkg:duff Can compare full file contents, but not default.
 * DebianPkg:fdupes Can remove. Does compare full file contents.
 * DebianPkg:fslint also does other maintenance and size reduction tasks.
 * DebianPkg:hardlink Can convert from duplicates to hard links.
 * DebianPkg: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 ==
Line 45: Line 172:

=== packages you do not want ===
=== Packages you do not want ==
Line 49: Line 175:

== Tools to alter files to reduce them ==
 * DebianPkg:gtkorphan GUI for deborphan
 * DebianPkg:popularity-contest Requires file system option strictatime, local e-mail server. run {{{ popularity-contest | sort > popcon }}}

= Tools to alter files to reduce them =
Line 52: Line 180:
  * eg. {{{strip --strip-unneeded foo}}}  * eg. {{{strip --strip-unneeded foo}}}
Line 57: Line 185:
== Reduce data creation ==
== 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 DebianPkg:findutils; {{{unexpand}}} of DebianPkg: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 =
Line 62: Line 196:
On systems that have been running for some time you might consider stripping out old log files.

Note that localepurge is a package that will strip unwanted language versions from everything you install. If you want a new language in the future you will have to add the locale and then re-install the package.

You might consider running {{{ dpkg -l }}} periodically and manually going through it to see if there are packages which you never use. Alternately you can install the package popularity-contest and run {{{ popularity-contest | sort > popcon }}} This will list the packages in least-used order in a text file called ~/popcon. Then to actually remove some unwanted/unused package you can do {{{ aptitude purge -s <unwanted package> }}} to simulate the process and see what else is affected. You can answer yes to seemingly drastic removals because the {{{ -s }}} makes it simulate and report, not actually execute. Once you are happy with the consequences do {{{ aptitude purge <unused package> }}} and aptitude will still tell you what it's doing and what dependencies are affected, but when you say Yes, it will actually execute the removal.

Using a compressed filesystem can save a lot of space. Typically squashfs reduces space used by about 50%, but it is read-only.

If you have a read-only source like a DVD, an overlaid unifying file system like [[http://aufs.sourceforge.net/|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).

__Wish list: __
 * ''media compressions.''
 * ''free space disk control like df''
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. DebianPkg: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.
 * DebianPkg:fuse-utils There are many file systems which offer compression and operate through FUSE.

== In Linux ==
 * squashfs read-only

=== No high confidence of high reliability ===
These file systems might not be reliable enough to store critical data.
 * Reiser4FS
 * BTrFS

=== 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:
{{{
tune2fs -r 0 /dev/sda2
}}}
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 [[http://aufs.sourceforge.net/|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 =
The following packages provide programs which losslessly compress data and can operate by a pipe or on files.
 * BZip2 format
 * DebianPkg:bzip2
 * DebianPkg:lbzip2
 * DebianPkg:pbzip2
 * GZip format
 * DebianPkg:gzip
 * DebianPkg:pigz
 * DebianPkg:plzip
 * DebianPkg:lzop
 * DebianPkg:xz-utils
[[http://www.iasylum.net/writings/parallel-compression.html|External article on parallel compressors]]

= Wish list =
 * ''lossy compressions.''
Line 76: Line 251:

= See Also =
 * [[Partition]]
 * DiskPartitioning
 * ReduceDebian - Reducing the size of the Debian Installation Footprint

----

CategorySystemAdministration | CategoryStorage

Translation(s): Deutsch - English - Italiano


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.

See partitions and discs usage

First of all, to see the existing partitions, use:

sfdisk -l

Then to check which partitions are getting full use:

$ df -lhT
  • or

$ 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 in package gnome-utils 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

See also ncdu.

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

  • kernel packages are large; older versions are not removed automatically for your safety.

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

 aptitude why package1 

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:

aptitude search '~U'

To list manually installed packages:

aptitude search '~i!~M'

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 '^[0-9]+[\.,]?[0-9]* [MG]B'|sort -n

Remove some cruft

Purge obsolete configuration files:

aptitude purge ~c

Take a look at the Debian Cleanup Tips at http://raphaelhertzog.com/mastering-debian/.

Using dpigs (debian-goodies):

dpigs -n50

Using wajig :

wajig size

Sort installed packages by size:

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -n

Graphical Interface

synaptic, go to installed packages and click on the size column.

Find things to erase

Categorically Expendable Directories

Temporary

/tmp
/var/tmp

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

/var/log

Cache

  • packages in /var/cache/apt/archives usually eats some space. As root or using sudo, you can get rid of them with:

apt-get clean

or

aptitude clean

Use apt-get autoclean if you want to remove old packages for which you also have the last package.

Spool

Things in

/var/spool

are intended to be processed but may be expendable.

Command line tools to see seldom used files

These function only if file systems are usually mounted with option strictatime.

/usr/bin/find

The following options are of special interest

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

Stripping dbus-daemon exposes a bug in BFD. Executing in find /usr/bin -not -name strip -and -not -name dbus-daemon -execdir strip --strip-unneeded '{}' \;  reduced the size of contents of the directory in a Squeeze installation from 140MB to 120MB.

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

Use the following line as your /etc/rsyslog.conf configuration file in order to not save logs but output them on virtual terminal 12:

  • *.* -/dev/tty12

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

  • squashfs read-only

No high confidence of high reliability

These file systems might not be reliable enough to store critical data.

  • Reiser4FS
  • BTrFS

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:

tune2fs -r 0 /dev/sda2

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

The following packages provide programs which losslessly compress data and can operate by a pipe or on files.

External article on parallel compressors

Wish list

  • lossy compressions.

  • using Quota as usrquota groupquota waringquota in quota

See Also


CategorySystemAdministration | CategoryStorage