Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Root partition full

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
Romane
Posts: 106
Joined: 2009-05-17 11:39
Location: Glenwood, Queensland, Australia

Root partition full

#1 Post by Romane »

Good morning

Have just had an issue where my / partition became 100% full. Not gradually, either. After searching around and finding no answer, "accidently" discovered reason, so posting here as may help someone else another day. Turned out to be very simple.

A little history first.

Debian wheezy system, KDE desktop (kde-full), never had Gnome installed. Quad core. 4Gb memory. 1Tb hard drive. two external USB drives (500Gb FreeAgent 320Gb Maxtor) mounted in /media. The Maxtor gets swapped between the desktop and laptop when taking laptop out walkies.

/ is 25Gb. Way bigger than needed, but on a 1Tb drive, don't matter :D Had 18.6Gb free on shutdown. On reboot next day, zero free. Check of filesytem, no problems. Check of hard-drivem, no problems. Manually count / size, should still have my 18.6Gb free. No hidden files as culprit, apt cache cleaned out, no temp files causing issue. df and du gave no hint or indication. None of the solutions found in my search (Google, here, etc) solved issue.

In a moment of desperation, formatted / and reinstalled sytem, but used kde-standard instead. All fine for one day. Then again, zero space free. Rebooted again with the 2 usb drives disconnected, still zero free. Had installed fslint, and in searching with it, noticed that the entries for the Maxtor were still in /media/maxtor, but no maxtor connected. Deleted all entries and presto, all my free space back again.

Cause of problem

The FreeAgent drive was mounted via fstab, the Maxtor when accessing the drive the first time through Dolphin. I have a script which runs hourly (cron) which backs up my data using rsync every hour. The script, not finding the Maxtor mounted in the subdirectory allocated for it simply wrote what it could into the free space in /media/maxtor. Presto - drive full. ( :oops: - makes sense ).

Now mounting Maxtor through fstab so no need to remember to mount manually.

With greetings

Romane

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5347
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 13 times
Been thanked: 66 times

Re: Root partition full

#2 Post by dilberts_left_nut »

:D

Pointing your backup to a subdir, which is 'not found' when drive is not mounted could also be a failsafe.
AdrianTM wrote:There's no hacker in my grandma...

debianbob
Posts: 1
Joined: 2012-06-29 21:05

Re: Root partition full

#3 Post by debianbob »

Great advice on that subdir and dir not found. Had the same problem with a unreliable network mount and solved it by first mounting a virtual fs on the mount folder and then the target partition on top of the virtual fs but this is much more elegant.

User avatar
Romane
Posts: 106
Joined: 2009-05-17 11:39
Location: Glenwood, Queensland, Australia

Re: Root partition full

#4 Post by Romane »

Good morning

Ok, revisiting the subject. Ran into the problem again more than once (forgetful :oops: ) so tried to find a better way. Obvious answer is with a bash script, so after a couple of iterations and write / rewite (not all that familar with bash scripting) came up with this, which I put into /usr/bin. Gets called as a cron job every hour, and then gets run manually in a terminal, before I log off.

It checks for drives mounted in /media, makes sure its not a CDRom (I tested both with and without a disc in the drive), assumes that if the space available at the mount-point is the same as the amount of free in / that the drive is not mounted, makes sure the space available is more than the size of the directory it is called from (I tested with a USB thumb drive), then rsyncs it across (I prefer this to compressed, as if I botch something in my work, can just copy it simply back over from the last backup - don't lose more than an hours work). It suits my purpose, and means that if a drive is not connected, it doesn't get written to.

It may need modification(s) to work for someone elses circumstance, but for what it is worth :

Code: Select all

#!/bin/bash
# A backup file to copy via rsync to /media mounted drives.
where="/media" #                         directory in which to find the backup drives
from="./*" #                             copy from the current directory (assumed ~) - no hidden schtuff !!
cd="cdrom*" #                            cdrom with wildcard (more than one CDROM drive ?)
As="./.kde/share/apps/akregator" #       akgegator source directory
Is="./.icedove/ikalev1i.default" #       icedove source directory
Id="icedove" #                           icedove destination directory
p="-asvH" #                              rsync parameters
declare -a Array #                       the array to hold the output of df
Array=($(df $where)); #                  first, get the df values for the /media
root=${Array[10]} #                      and assign the free-space values to a variable
Array=($(df ./)) #                       next, get the df values for the current directory
home=${Array[9]} #                       and assign the used-space value to a variable
for f in $( ls $where ); do #            get the names of the directories in $where
  Array=($(df $where/$f)) #              fill the array with the output from df for $where/$f
  size=${Array[8]} #                     get the size of the target directory drive $f
  if [[ ${Array[10]} != $root ]]; then # assume if directory sizes don't match that drive mounted
    if [[ $f != $cd ]]; then #           not a CD drive ?
      if [[ $home < $size ]]; then #     is the drive is big enough to take the backup
        rsync $p $Is $where/$f/$Id #     yes, so copy the icedove directories
        rsync $p $As $where/$f #         then copy the akregator directories
        rsync $p $from $where/$f #       and then the remaining directories and files
      fi
    fi
  fi
done # ----- end of the for loop
With greetings

Romane

Purplegra
Posts: 5
Joined: 2012-08-27 08:49

Re: Root partition full

#5 Post by Purplegra »

Now mounting Maxtor through fstab so no need to remember to mount manually.
Image

User avatar
Romane
Posts: 106
Joined: 2009-05-17 11:39
Location: Glenwood, Queensland, Australia

Re: Root partition full

#6 Post by Romane »

Purplegra wrote:Now mounting Maxtor through fstab so no need to remember to mount manually.
Yeah - unless it is unplugged when the backup script runs. Done that. Or when the drive failed to mount at boot - had to reformat it to fix it (it is dying, just discovered have lost about 100Gb of space). Then I forgot to update the UUID in fstab. In any of these circumstances, the script dosn't care and will merrily write to the space it finds, so left with zero space in the root directory again. So, needed something to protect myself from myself and from any of the usb connected drives if they fail. If it aint propwerly mounted, it don't get written to.

Also does the job in a few lines in one script, not the three l o o o o n g script files that called each other before, and if stick in a new or different drive then only need to update fstab, not the script.

With greetings

Romane

Post Reply