[Solved] Mounted Network folders are filling up local diskspace?

Connection sharing, Firewall, Samba..etc
Forum rules
Before you post please read how to get help
Post Reply
Alyana
Level 1
Level 1
Posts: 17
Joined: Thu Nov 19, 2015 10:36 am

[Solved] Mounted Network folders are filling up local diskspace?

Post by Alyana » Thu Mar 15, 2018 10:46 am

Hi everyone,

I recently experienced a strange behaviour with my mounted network folders and I hope someone here can explain me what is happening and why.

I successfully set up fstab to automatically mount 4 folders that are located on my WD MycloudMirror NAS. So far so good. Aside from a few permission issues things seemed to work fine, and I used Freefilesync to synchronize these folders with my home folders, as there are two different PC storing data on the NAS, a Windows PC and a Notebook running Linux Mint 18.3.

After a few days I got a warning, 0 bytes free on my harddisk, and I could not even log in anymore. I started the system with a boot stick and found out, that in the folders that are supposed to be the mount locations for the network folders, almost all the data of my local home folders was stored as well, almost doubling the data on my harddrive, which of course led to my harddisk becoming full in no time.

After deleting the data there Mint 18.3 worked fine again.

My question now is, why is this happening? Why is data that is supposed to be stored in network folders, also being stored locally in these folders? There rather should be a warning that the network drives are not available if there is no connection to the NAS.

How do I have to mount network folders so that they are not using local disk space?

Thank you for any help :)
Alyana
Last edited by Alyana on Tue Mar 20, 2018 12:54 pm, edited 1 time in total.

User avatar
WharfRat
Level 20
Level 20
Posts: 11547
Joined: Thu Apr 07, 2011 8:15 pm

Re: Mounted Network folders are filling up local diskspace?

Post by WharfRat » Thu Mar 15, 2018 11:54 am

Alyana,

Evidently the partition did not mount and therefore the folder you're using as a mountpoint ended up as a normal folder in /.

You can check if the there is a partition mounted with mountpoint or ls which will show a lost+found/ folder :wink:
ImageImage

Alyana
Level 1
Level 1
Posts: 17
Joined: Thu Nov 19, 2015 10:36 am

Re: Mounted Network folders are filling up local diskspace?

Post by Alyana » Thu Mar 15, 2018 12:24 pm

Thank you WharfRat for this information!

That was indeed the case, because I had no connection for a few days and the data was stored in these folders nevertheless, but like you said, obviously as normal folders.

Could you or someone else please explain to me in short, how I could prevent mountpoints from being used as normal folders then, in case there is no connection?

I mean, I have to create those directories with mkdir before being able to mount at all, but then these folders remain after disconnecting. But when starting my notebook next time without network connection, these folders are still present and might be used as normal folders again? I would rather want it to behave like disconnected windows network shares that are visible but with a red sign and refusing the connection when clicking on them.

Thank you and sorry for the maybe a bit newbie question but that is something I haven't figured out yet.

User avatar
WharfRat
Level 20
Level 20
Posts: 11547
Joined: Thu Apr 07, 2011 8:15 pm

Re: Mounted Network folders are filling up local diskspace?

Post by WharfRat » Thu Mar 15, 2018 12:37 pm

An easy solution is to use a simple script like this to check the status of your mountpoint before syncing your files:

Code: Select all

#!/bin/bash
# 
# check_mnt script to ensure a partition is mounted to /media/shared

mountpoint /media/shared >/dev/null 2>&1

if ! [ $? -eq 0 ];then 
	echo "Nothing is mounted to /media/shared !"
	exit $?
fi
#
# continue your stuff here

exit 0
Naturally you would change /media/shared to your mountpoint :wink:
ImageImage

Alyana
Level 1
Level 1
Posts: 17
Joined: Thu Nov 19, 2015 10:36 am

Re: Mounted Network folders are filling up local diskspace?

Post by Alyana » Thu Mar 15, 2018 3:01 pm

Great thank you so much!

Is this a common behaviour in Linux that mountpoints that are not connected are being used as local folders instead while the NAS folders are offline? And if files are being copied into such a folder, what happens when the connection is back up? I mean, some of the files might be double then, some might be missing or some files might be changed compared to the versions on the NAS.

How can it be determined then, which of the files that I see in that folder then, are the offline ones and the online ones?

User avatar
WharfRat
Level 20
Level 20
Posts: 11547
Joined: Thu Apr 07, 2011 8:15 pm

Re: Mounted Network folders are filling up local diskspace?

Post by WharfRat » Thu Mar 15, 2018 4:30 pm

Alyana wrote:
Thu Mar 15, 2018 3:01 pm
Is this a common behaviour in Linux that mountpoints that are not connected are being used as local folders instead while the NAS folders are offline?
Yes, because a mountpoint is nothing more than a local folder.
And if files are being copied into such a folder, what happens when the connection is back up?
Then the files on that filesystem will be accessed.
How can it be determined then, which of the files that I see in that folder then, are the offline ones and the online ones?
You can use mountpoint or mount or df to check if a filesystem is mounted to that folder, as an example:

Code: Select all

[bill@XPS] ~ $ df|grep -w shared
/dev/sda9      ext4      2.7T  1.8T  710G  72% /media/shared

[bill@XPS] ~ $ mount|grep -w shared
/dev/sda9 on /media/shared type ext4 (rw,nosuid,nodev,noexec,noatime,errors=remount-ro,data=ordered,user)

[bill@XPS] ~ $ mountpoint /media/shared
/media/shared is a mountpoint

[bill@XPS] ~ $ sudo umount /media/shared

[bill@XPS] ~ $ df|grep -w shared
[bill@XPS] ~ $ mount|grep -w shared
[bill@XPS] ~ $ mountpoint /media/shared
/media/shared is not a mountpoint
[bill@XPS] ~ $ 
The bottom line is a folder is a mountpoint when a filesystem is mounted to it :wink:

Not to confuse you, but your root file system is a mountpoint - you can see it with mountpoint /
ImageImage

Alyana
Level 1
Level 1
Posts: 17
Joined: Thu Nov 19, 2015 10:36 am

Re: Mounted Network folders are filling up local diskspace?

Post by Alyana » Fri Mar 16, 2018 4:10 am

Thank you so very much, WharfRat. Now a lot of things are a lot more transparent to me :)

To make sure that I understood it right:
And if files are being copied into such a folder, what happens when the connection is back up?

Then the files on that filesystem will be accessed.
Does that mean, that if there are some local files in such a mounted network folder, that they are displayed when the connection to the network resource is offline, and are not visible and therefore not usable when the connection is back up, and then the network folder is shown instead?

User avatar
WharfRat
Level 20
Level 20
Posts: 11547
Joined: Thu Apr 07, 2011 8:15 pm

Re: Mounted Network folders are filling up local diskspace?

Post by WharfRat » Fri Mar 16, 2018 8:40 am

Alyana wrote:
Fri Mar 16, 2018 4:10 am
Does that mean, that if there are some local files in such a mounted network folder, that they are displayed when the connection to the network resource is offline, and are not visible and therefore not usable when the connection is back up, and then the network folder is shown instead?
You almost got it :D

It's not the network folder being shown when a partition's filesystem is mounted to it, it's the filesystem's contents.

When a folder isn't mounted then it's the native filesystem's content.

Normally you would not store any files to a folder intended to be used as a mountpoint as they would not be accessible when a filesystem is mounted to it,

The concept of mounting filesystems is to provide for a seamless way to integrate external media of different filesystem types like usb drives, flash drives etc. into the linux filesystem hierarchy.

File system types can be seen with ls /lib/modules/$(uname -r)/kernel/fs

Also check out man hier for an explanation of the linux file tree :wink:
ImageImage

Alyana
Level 1
Level 1
Posts: 17
Joined: Thu Nov 19, 2015 10:36 am

Re: Mounted Network folders are filling up local diskspace?

Post by Alyana » Tue Mar 20, 2018 12:53 pm

Thank you very very much WharfRat!

This has really shed some light on this for me :D

Post Reply

Return to “Other networking topics”