[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Ceci est une ancienne révision du document !


TRADUCTION en cours — Cedric M. 2015/09/10 15:32

Libérer de l'Espace

Parfois, vous pouvez vous retrouver dans une situation imprévue : un message vous indique qu'il n'y a pas plus de place sur votre système. Cependant, certaines choses sont possibles pour retrouver de l'espace libre.

Le Répertoire /tmp

Une des premières causes peut être que le répertoire /tmp n'est pas nettoyé automatiquement. Je crée mes propres fichiers temporaires dans mon répertoire home, je peux ainsi supprimer en toute sécurité le contenu de /tmp chaque fois que j'arrête mon système. Vous n'êtes pas obligé de le faire manuellement.

La commande suivante devrait être placée dans /etc/rc.d/rc.local_shutdown.

/etc/rc.d/rc.local_shutdown.append
/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -exec /bin/rm -rf {} +;

Cela va supprimer tous les fichiers du répertoire /tmp à chaque fois que le système est arrêté, faites donc attention à ce que vous mettez dedans!

Le fichier rc.local_shutdown peut également être utile dans d'autres cas. Si vous avez besoin d'effectuer d'autres tâches à l'arrêt du système, vous pouvez les mettre ici. Comme ce fichier n'existe pas par défaut sur l'installation de Slackware, vous aurez besoin de le créer d'abord et de le rendre exécutable:

root@darkstar# touch /etc/rc.d/rc.local_shutdown
root@darkstar# chmod +x /etc/rc.d/rc.local_shutdown
Rappelez-vous de tester vos commandes avant de les inclure dans le fichier d'arrêt.

Autrement, si vous avez suffisamment de RAM, vous pouvez monter /tmp dans tmpfs en ajoutant l'entrée suivante dans /etc/fstab.

/etc/fstab.append
tmpfs	/tmp		tmpfs	size=4G,nodev,nosuid	0	0

Vous pouvez restreindre la taille de /tmp (max. 4Go dans l'exemple ci-dessus) pour éviter de manquer de mémoire.

Il y a aussi une façon plus sûre pour nettoyer de votre répertoire tmp; cette méthode consiste à n'effacer les fichiers temporaires qu'au bout d'un certain temps. Le script suivant sélectionne les fichiers qui n'ont pas été utilisés pendant un certain temps et conserve les sockets pour X. On pourrait décider d'exécuter ce script de manière régulière en utilisant cron.

cleanstale.sh
#!/bin/sh
# Cleanup /tmp however, do not remove sockets for X
 
# No lost+found with reiserfs
find /tmp/lost+found -exec /bin/touch {} \;
find /tmp -type s -exec /bin/touch {} \;
find /tmp -type d -empty -mtime +37 -exec /bin/rmdir {} \;
find /tmp -type f -mtime +37 -exec rm -rf {} 
Encore une fois, n'oubliez pas de tester vos scripts avant de les déployer sur votre système. Comme toujours: votre kilométrage peut varier.

sbopkg

root@darkstar# sbopkg -o
[ Checking for obsolete sources ]
This may take a few moments. Press <ESC> to abort.
100%[====================================================]
It appears there are no obsolete sources in /var/cache/sbopkg.

If you do not need the sources of packages installed via sbopkg, you may also want to clean the whole sbopkg cache. You can do it in sbopkg’s utility menu.

Finding files/directories taking up most space

It’s also good practice to find directories/files that take up most space. The following command will display 20 largest files/directories in a specified place (in this example Fred's home directory):

find_largest.sh
du -a /home/fred/ | sort -n -r | head -n 20

You can go through the list and decide whether you want to delete any of them.

A quicker approach might be to use ncdu, du's ncurses frontend. Not only does it display directories in your chosen order (ascending/descending, by size/name), but also lets you interactively browse (and be careful: delete) them.

To make sure you don’t delete something by accident, you can run the program in the read-only mode calling it with the -r flag.

Apart from ordering the files/directories by size or name, there are also a number of interesting display options like showing percentage or graph, showing/hiding hidden or excluded files and directories (you can exclude certain directories or files if you want.)

Although it is not part of the stock Slackware, it can be easily installed from SlackBuilds.org (it does not have any additional dependencies.)

Remove unnecessary programs

Another way of freeing some space is by uninstalling the apps that you no longer need. If you don’t know what you are doing, it is NOT recommended to uninstall anything from the Slackware’s default installation. You might break some parts of the system . A safer approach would be to uninstall some 3rd party applications. Long time ago you may have installed some applications from SlackBuilds that you no longer use. You can remove 3rd party programs using the following command:

root@darkstar# slackpkg clean-system

This will list all 3rd party packages and let you select the ones you want to remove. In order for an application to be included in slackpkg list it must have been built and installed the Slackware way, ie. by using a SlackBuild. Otherwise, it will not be part of the Slackware package management system.

If there's no SlackBuild for a program you want to install, try to create one or use the excellent src2pkg tool.

Disk Cleanup Utilities

Here are a list of disk cleanup utilities you might find useful to remove unnecessary or temporary files from your system.

  • Sweeper - A KDE disk cleanup application.
  • BleachBit - BleachBit quickly frees disk space and tirelessly guards your privacy. Free cache, delete cookies, clear Internet history, shred temporary files, delete logs, and discard junk you didn't know was there. A Slackbuild is available at SlackBuilds.org.

Sources

  • Initialement écrit par sycamorex
  • Basé sur cet article du blog de sycamorex
  • Compléments d'information par Harishankar (Disk Cleanup Utilities section)
  • Contributions de cpt (cleanup script), original script has been copied from a mail-list, cpt does explicitly not claim to be the original author of this script.

 fr:howtos:general_admin:free_your_space ()
Cette traduction est plus ancienne que la page originale et est peut-être dépassée. Voir ce qui a changé.