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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-17-2016, 10:52 PM
|
#1
|
LQ Newbie
Registered: Jun 2016
Posts: 2
Rep:
|
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!
|
|
|
10-18-2016, 12:10 PM
|
#2
|
LQ Guru
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,370
|
Quote:
Originally Posted by gustep12
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.
|
|
|
10-18-2016, 01:04 PM
|
#3
|
Moderator
Registered: Aug 2002
Posts: 26,453
|
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.
|
|
|
10-18-2016, 01:08 PM
|
#4
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,803
|
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.
|
All times are GMT -5. The time now is 02:29 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|