• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Other The mount command in FreeBSD

vince66

Well-Known Member

Thanks: 10
Messages: 287

#1
Hello guys,

to mount an external device (HD, USB stick) in read only mode are different setting options, depending on the filesystem type.

Reading the mount(8) manual pages I've seen that in the FreeBSD are not implemented the following options:

- nodev
- loop
- norecovery
- nointegrity
- nolog
- umask
- shortname
- quiet

I think that, probably, the above options are developed for Linux OSes and are not necessary in FreeBSD.
What do you think about ?

Tips are welcome.

Thanks in advance.

Please, tips are welcome.
 

ShelLuser

Son of Beastie

Thanks: 1,193
Messages: 2,560

#2
Several of those options heavily depend on the filesystem being in use. For example; if you mount FAT32 (msdosfs) then this filesystem obviously doesn't support umasks nor devices.

As to the loop option... That's not really an option, I assume you're now referring to loop devices (as they're called on Linux)? FreeBSD uses mdconfig(8) for that. So first you create a device (memory disk) which points to the file you want to access, then you'd use mount to actually access the filesystem on it.
 

scottro

Daemon

Thanks: 385
Messages: 1,137

#3
Code:
mdconfig -a -t vnode -f my.iso
You should then see something like mdo, assuming it's the first one you created.
Then
Code:
mount_cd9660 /dev/md0 mount
or similar. I haven't actually done this in a long time, but at least it shouldn't break anything. (or mount -t cd9660 would also work). As i said, I haven't done this in awhile, it may not be necessary to specify the type anymore, don't have a CD around to test. :)
 

vince66

Well-Known Member

Thanks: 10
Messages: 287

#4
Hello guys !

Thanks very much !

ShelLuser says:
"Several of those options heavily depend on the filesystem being in use. For example; if you mount FAT32 (msdosfs) then this filesystem obviously doesn't support umasks nor devices."

I'm agree that several of those options depend on the filesystem, but my question was another: those options are not implemented in FreeBSD mount command. Why ?

The loop option is clear: the FreeBSD doesn't take into account block devices but only the character devices, so for block devices it's necessary a preliminary mdconfig(8) operation (moreover, I personally think that this is one of the best development choise of the FreeBSD O.S. that do it different and better than other OSes !!! ).

And for the other options ?

Again:
I've tryed to mount a usb_stick using this command:

mount -t msdosfs -o ro,noauto,noexc,noatime /dev/da4 /usbstick

Running the ls -lag I've seen the following permissions:

drwxr-xr-x

My question now is:

how can I mount a device to have the following permission set:

dr--r--r-- ?

Where my mistakes are ?

Thanks very much in advance for your time.

I hope to hear you soon.

Have you a nice day !!!!!!
 

ShelLuser

Son of Beastie

Thanks: 1,193
Messages: 2,560

#5
Again:
I've tryed to mount a usb_stick using this command:

mount -t msdosfs -o ro,noauto,noexc,noatime /dev/da4 /usbstick
<snip>
how can I mount a device to have the following permission set:

dr--r--r-- ?
Well, that's what I was hinting at but re-reading I agree that I could have been a bit more precise.

The easiest way to get this information is to check mount_msdosfs(8). I believe the manual page for mount also mentions as much but I'm not sure from mind. Alas... You're looking for the -M option, this can set a mask which applies to the directories on the filesystem. Though you might want -m instead considering that a directory with only the read flag set wouldn't be very useful.

For example: # mount_msdosfs -m 444 -M 555 /dev/da0s1 /mnt.
 

vince66

Well-Known Member

Thanks: 10
Messages: 287

#6
Hello ShelLuser,

let me pose this question:

I've used the command you wrote, changed in this way:

# mount_msdosfs -m 000 -M 000 /dev/da0s1 /mnt,

so, typing ls -lag, any file permission appears:

----------

and any directory permission appears:

d---------

After that I've tryed to delete a file from the /mnt directory, running the command:

rm /mnt/filename.

The strange event has been that the file has been deleted !!!! This is not possible ! What happens ?

Moreover, I copied a file to /mnt, running:

cp filename /mnt

and in this case, also, the file has been copied !!!!!

Is there a reply to this strange behaviour ?

Any file can be entered as root and wheel. Maybe is this the problem ?
 

ShelLuser

Son of Beastie

Thanks: 1,193
Messages: 2,560

#7
After that I've tryed to delete a file from the /mnt directory, running the command:

rm /mnt/filename.

The strange event has been that the file has been deleted !!!! This is not possible ! What happens ?
I assume you were root? It's for a good reason why it's advised not to use that account for general purposes. Those file system permissions have no meaning for the root user.

If you want the whole thing to be readonly then mount it as such, see the -o option for that.
 

vince66

Well-Known Member

Thanks: 10
Messages: 287

#8
If I've well understood what you assert, the best choice is to login the computer as non-root user, then mount the device.
Are you agree ?

Thanks in advance for your usefull tips !!
 
Top