LinuxQuestions.org
Visit Jeremy's Blog.
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 03-02-2017, 10:05 PM   #1
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Rep: Reputation: Disabled
mounting filesystem question


Hi all

I am trying to make sense of something:

I have done the following: create an empty file, format it and mount it like a regular filesystem. Actually I mounted it at two different places.

My fstab looks like this:

Code:
$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=56b92ca1-312c-45e6-8f57-8c80762f96b9 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=07d0cb84-79a6-47bd-a155-cbfd045cf6ca none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
/home/davy/swap.img swap swap sw 0 0
/home/davy/test.img /home/davy/mnt auto rw,user,auto,exec,async 0 0
/home/davy/test.img /home/davy/test auto rw,user,auto,exec,async 0 0
As you can see the same file is mounted on two different places. Now when I write stuff into one my test folder I don't see it in mnt and I don't understand why.


Code:
$ ls test
asdfkl  asdfksdfklsd  bla  lost+found  testfiles
$ rm test/asdfk*
$ ls test
bla  lost+found  testfiles

$ ls mnt
asdfkl  asdfksdfklsd  bla  lost+found  testfiles

$ cd mnt
$ cat asdfk
cat: asdfk: No such file or directory
since both mnt and test mount the same file, shouldn't whatever I change on one end be reflected on the other side especially since I included the async option? Now when I try to access the file it is definitely gone, how do I get to update itself?

The img file is created via dd and formated as ext4.


Thanks
 
Old 03-03-2017, 01:58 AM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 5,495
Blog Entries: 16

Rep: Reputation: 3259Reputation: 3259Reputation: 3259Reputation: 3259Reputation: 3259Reputation: 3259Reputation: 3259Reputation: 3259Reputation: 3259Reputation: 3259Reputation: 3259
When you did the second mount, did you use the --bind option? That's the proper way to do it. It's possible that if you omit --bind, funny things happen.
 
1 members found this post helpful.
Old 03-03-2017, 08:32 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,547

Rep: Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082
It could be considered a bug that the second mount was even allowed. If you tried to do that with an actual block device you would get an "already mounted" error. Since the two mounts were done using separate loop devices, the duplication wasn't detected and you got away with it. Well, sort of. If you created files via both of those mount points you would almost certainly end up with a massively corrupted filesystem. (And, you indeed do. I just tried that in a VM.)
 
Old 03-04-2017, 08:59 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 5,935

Rep: Reputation: 3916Reputation: 3916Reputation: 3916Reputation: 3916Reputation: 3916Reputation: 3916Reputation: 3916Reputation: 3916Reputation: 3916Reputation: 3916Reputation: 3916
Quote:
Originally Posted by rknichols View Post
It could be considered a bug that the second mount was even allowed. If you tried to do that with an actual block device you would get an "already mounted" error.
Actually it'll also let you mount the same lvm lv twice without complaint, so the device-mapper block devices don't have this check either. And like you I'm surprised the kernel even allows this. God only knows what will happen with concurrent updates.
 
Old 03-04-2017, 09:33 AM   #5
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora 33
Posts: 3,573

Rep: Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006
Putting an entry in fstab does not mount a filesystem. What is the output of the mount command?
 
Old 03-04-2017, 09:34 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,547

Rep: Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082
Quote:
Originally Posted by GazL View Post
God only knows what will happen with concurrent updates.
As I found by testing, the result with loop devices is massive filesystem corruption due to uncoordinated usage of inodes and data blocks. Somehow, LVM seems to handle the duplicate mounts correctly.

Last edited by rknichols; 03-04-2017 at 09:50 AM. Reason: LVM seems OK
 
  


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
Mounting Filesystem saidul Linux - Newbie 3 12-15-2007 12:25 PM
A question for the filesystem gurus about converting from ext2 to ext3 and mounting PingFloyd Linux - General 4 07-01-2006 01:28 PM
help:about mounting filesystem ms_sachem Fedora 1 06-13-2005 06:34 AM
Mounting a filesystem codebox.nl Linux - Software 7 10-21-2004 06:18 AM
Mounting HDD vs. Mounting Filesystem snailophone Linux - Hardware 4 08-12-2003 11:00 AM

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

All times are GMT -5. The time now is 04:55 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