I'm a Class A Muppet. I have had /var/spool/ mounted as tmpfs for over a year and that means crontab has never been able to remember what it's doing and postfix has been broken.

I'm not asking to restore lost data. That data is long gone.

I would like to restore the default content of /var/spool/ though. crontab seems to manage to write its own but to get postfix back online I have to reconfigure (or reinstall) it. These are just two systems that I know of. There could be dozens more.

Is there any way to tick through all the installed packages and work out which should have something in /var/spool/? And by extension, is there any simple way to restore that data?


After you've unmounted, and got rid of the configuration to mount /var/spool as tmpfs by removing it from /etc/fstab, you can run the following commands to reinstall all the packages which own files in /var/spool:

dpkg -S /var/spool | sed 's/\:.*$//;s/,//g' | xargs sudo apt-get install --reinstall

The dpkg -S command lists all of the packages which own /var/spool or something under it. The pipe to sed strips off the end and then removes the commas from the comma-and-space-separated list of package names. And finally the xargs is to pass the list of packages on to sudo apt-get install --reinstall as the list of arguments, rather than the normal STDIN that a pipe sends to.

  • 1
    Might even be cleaner as sudo apt-get install --reinstall $(dpkg -S /var/spool | sed 's/,//g;s/\:.*$//') but I'm going to stop messing around with it for now! – Oli May 30 '13 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.