LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-17-2016, 10:52 PM   #1
gustep12
LQ Newbie
 
Registered: Jun 2016
Posts: 2

Rep: Reputation: Disabled
Root directory 100% full - but disk utilization doesn't add up. Maybe solved?


I ran into a common problem that took me more than an hour to solve. Here is what happened - maybe someone can explain this better?

My root directory / is sda2 (~40GB capacity, normally 25% full)
My home directory /home is sda3 (~400GB capacity, normally 20% full)

I also have several network shares (Samba, SMB) that reside on a separate NAS, which I mount at boot through fstab like this, for convenient local access:

//192.168.1.245/Public/Shared_folder ==> mounted locally as /mnt/Shared_Folder (~1TB capacity, normally 10% full)

df / shows root as 100% used
du / shows a lot of data since /mnt/Shared_Folder is included

du -x /(to exclude remote folders under /mnt) shows ~10GB of data, about

The problem was that I also had an rsync script that was supposed to copy lots of data to /mnt/Shared_Folder. However, apparently the NAS went down, and somehow Linux then created an actual folder under /mnt/Shared_Folder on the local root (sda2). Later on, the NAS was back online.

The fundamental problem is that it was very difficult for me to tell apart which directories in /mnt are actually residing locally on sda2, and which ones are remote SMB shares.

Eventually, I edited my fstab and rebooted without the network shares. And see there, now I found a large sub-folder inside /mnt/Shared_Folder, which means it must have been local, even though it shouldn't have been. I deleted that, restored my fstab, rebooted again.

Now df shows root directory back at ~25% usage. All is well again.

If the same problem happens again, how can I use ls, df, du, or something else, to see which directories (or files) in /mnt are local (by accident), when they all should have been remote on the NAS? And how do I check the size of local files in /mnt but not any remote files that are mapped to /mnt ?

Thank you!
 
Old 10-18-2016, 12:10 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,370

Rep: Reputation: 563Reputation: 563Reputation: 563Reputation: 563Reputation: 563Reputation: 563
Quote:
Originally Posted by gustep12 View Post
The problem was that I also had an rsync script that was supposed to copy lots of data to /mnt/Shared_Folder. However, apparently the NAS went down, and somehow Linux then created an actual folder under /mnt/Shared_Folder on the local root (sda2). Later on, the NAS was back online.

If the same problem happens again, how can I use ls, df, du, or something else, to see which directories (or files) in /mnt are local (by accident), when they all should have been remote on the NAS?
I suggest that you place an if statement in your rsync script to check if /mnt/Shared_Folder is mounted. If /mnt/Shared_Folder is not mounted you can either mount it or issue an error message and exit the script. Here is an example where I check to see if a USB drive is mounted before I run a rsync backup to it:

# Mount the USB hard drive
if ! (mount -t ext4 -L dog /media/usb.hard.drive);
then
echo "mount failed for USB hard drive on dog partition"
exit
fi

---------------------
Steve Stites

Last edited by jailbait; 10-18-2016 at 12:14 PM.
 
Old 10-18-2016, 01:04 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,453

Rep: Reputation: 6215Reputation: 6215Reputation: 6215Reputation: 6215Reputation: 6215Reputation: 6215Reputation: 6215Reputation: 6215Reputation: 6215Reputation: 6215Reputation: 6215
There are many ways to find out mount points. You can look at the output of mount, df, /proc/mounts, /etc/mtab, via mountpoint etc.

To check that the share is mounted via the mountpoint command.

Code:
res=$( mountpoint -q "/mnt/Shared_Folder" )
if (( $res != 0 )); then
    exit
fi

# Your rsync code goes here

Last edited by michaelk; 10-18-2016 at 05:06 PM.
 
Old 10-18-2016, 01:08 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,803

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
You can use a bind-mount to see what might be hiding under an active mount point. Example for the root filesystem:
Code:
mkdir /tmp/tmpmnt
mount --bind / /tmp/tmpmnt
You can now look in /tmp/tmpmnt and see the root filesystem as it would appear without anything mounted. You can move or delete files that you find in places they shouldn't be.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disk utilization 100% usao Linux - Server 1 01-01-2016 10:49 AM
100% disk utilization on /boot partition!! locus84 Linux - Newbie 3 08-26-2011 04:10 AM
disk space is full ( / is 100% in use) samengr Linux - General 3 01-26-2008 10:38 AM
Disk 100% full eggoz Linux - Software 7 12-22-2004 11:01 PM
Root file system shows 100% percent utilization simplyrahul Linux - Software 1 11-26-2004 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration