DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 22nd July 2008
ivanatora ivanatora is offline
Real Name: Ivan
Fdisk Soldier
 
Join Date: Jul 2008
Location: Bulgaria
Posts: 51
Default Mount filesystem with a regular user

Hello,
I have a desktop installation of FreeBSD 7, and that's why I need my regular user to have write access to some mounted filesystems. How can I mount these filesystems? I can't see an option to mount giving user ownership rights.
I tried with
sysctl -w vfs.usermount=1
then change ownership of /mnt directory:
chown ivanatora:ivanatora /mnt/*
and then issue mount /mnt/storage/ with user ivanatora, and I got:
chown: storage: Invalid argument
Wtf? What does 'Invalid argument' means? Never seen that for chown.
Anyway I tried chowning a different directory with success, and I can mount it with my user.
The question is how would it be mounted after a reboot? I don't want to remount these everytime the system starts. There must be a fstab option to set the uid of that mount, maybe?
Reply With Quote
  #2   (View Single Post)  
Old 22nd July 2008
Weaseal's Avatar
Weaseal Weaseal is offline
Package Pilot
 
Join Date: May 2008
Location: East Coast, US
Posts: 177
Default

You must specify the filesystem type, here's an example:
Code:
mount -t ntfs /dev/ad2s1 /mnt/storage
/dev/ad2s1 is patition 1 on disk 2, and /mnt/storage is where it will appear in your filesystem.
__________________
FreeBSD addict since 4.2-RELEASE.
My FreeBSD wiki.
Reply With Quote
  #3   (View Single Post)  
Old 22nd July 2008
18Googol2's Avatar
18Googol2 18Googol2 is offline
Real Name: whoami
Spam Deminer
 
Join Date: Apr 2008
Location: pwd
Posts: 283
Default

Quote:
Originally Posted by ivanatora View Post
The question is how would it be mounted after a reboot? I don't want to remount these everytime the system starts. There must be a fstab option to set the uid of that mount, maybe?
For mounting upon startup, there are a couple of sample entries in stock fstab file. Create your own one based on these, and you shouldnt have any problem
Reply With Quote
  #4   (View Single Post)  
Old 22nd July 2008
ivanatora ivanatora is offline
Real Name: Ivan
Fdisk Soldier
 
Join Date: Jul 2008
Location: Bulgaria
Posts: 51
Default

Just getting it mounted is not the problem. I can mount everything as root, and here is my current fstab:
Code:
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ad4s1b             none            swap    sw              0       0
/dev/ad4s1a             /               ufs     rw              1       1
/dev/acd0               /cdrom          cd9660  ro,noauto       0       0
/dev/ad0s7              /mnt/storage    msdosfs rw              0       0
/dev/ad0s5              /mnt/ntfs       ntfs    rw              0       0
/dev/ad0s1              /mnt/xp         ntfs    rw              0       0
/dev/ad0s8              /mnt/linux      ext2fs  rw              0       0
/dev/ad0s6              /mnt/extra      reiserfs        ro      0       0
/dev/da1s1              /mnt/mmc        msdosfs,noauto  rw              0       0
After a reboot they are mounted with root privilegies - i.e. no other user than root can write on them. I can write there with a regular user only after remounting these with that user.
And a one more point on ext2/3 partitions - they are mounted with preserved modes of ownership. I.e. if /mnt/linux/home/user1 is owned by user1 on the Linux filesystem (uid 1500 for example), after mount in FreeBSD the file owner is uuid 1500, which I doesn't have on my system. Can I just ignore these ownerships and make one single user owner of the whole mounted filesystem? And how to keep that after a reboot? Man page of mount didn't have a clue about setting uuid of the mount point.
Reply With Quote
  #5   (View Single Post)  
Old 22nd July 2008
18Googol2's Avatar
18Googol2 18Googol2 is offline
Real Name: whoami
Spam Deminer
 
Join Date: Apr 2008
Location: pwd
Posts: 283
Default

Assume the user you mount as on your server is also ivanatora and this user has write privilege.

Now unmount the directories, then

#chown -R ivanatora:ivanatora /mnt

You may need root priviledge to execute the above command

Next time when file systems are mounted, all files and dir under /mnt should be owned by ivanatora:ivanatora
Reply With Quote
  #6   (View Single Post)  
Old 22nd July 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Default

there are two different ways to control ownership of ntfs and msdosfs filesystems. The hard way is to specify the user and group when mounting the filesystem - use the -u and -g options: check man mount_msdosfs(8)
The easy way, and better, is to set the user, group and permissions of the mount point. Unmount the filesystem, set the mount point's owner and permissions, and remount the filesystem. All files in the filesystem will now have the same permissions as the mount point. (executable permissions excetped: -x on directories will be carried over, but will be cleared on regular files)
I do not know of any way to remap these uids when mounting filesystems. It is an option you can specify when exporting a filesystem over NFS. (which, of course, is no help whatsoever!) Man pages did not help me either, there.
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote
  #7   (View Single Post)  
Old 23rd July 2008
ivanatora ivanatora is offline
Real Name: Ivan
Fdisk Soldier
 
Join Date: Jul 2008
Location: Bulgaria
Posts: 51
Default

OK, something is wrong.
I've changed ownership of /mnt with chown -R:
Code:
# ls -l /mnt/
total 1
drwxr-xr-x  2 ivanatora  ivanatora  512 Jul  1 15:31 extra
drwxr-xr-x  2 ivanatora  ivanatora  512 Jul  1 15:31 linux
drwxr-xr-x  2 ivanatora  ivanatora  512 Jul 21 19:31 mmc
drwxr-xr-x  2 ivanatora  ivanatora  512 Jul  1 13:39 ntfs
drwxr-xr-x  2 ivanatora  ivanatora  512 Jul  1 13:13 storage
drwxr-xr-x  2 ivanatora  ivanatora  512 Jul  1 15:25 xp
I've enable usermount in sysctl:
Code:
> sysctl -a | grep usermo
vfs.usermount: 1
And I'm still getting strange errors like:
Code:
> mount /mnt/extra/
mount: /dev/ad0s6 : Operation not permitted
> mount -t reiserfs /dev/ad0s6 /mnt/extra/
mount: /dev/ad0s6 : Read-only file system
# But /mnt/extra is not succesfully mounted!
> mount -t msdosfs /dev/ad0s7 /mnt/storage/
mount_msdosfs: /dev/ad0s7: : Operation not permitted
EDIT:
I changed these permissions:
Code:
# chmod a+rw /dev/ad*
And now I'm able to mount these devices...

Last edited by ivanatora; 23rd July 2008 at 08:31 AM.
Reply With Quote
  #8   (View Single Post)  
Old 23rd July 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

> I changed these permissions: # chmod a+rw /dev/ad*

the permissions will revert to their defaults on the next boot.
you will need to tell devfs to apply the permission automatically on booting: http://bsdforums.com/forums/showthre...t=47864&page=2
Reply With Quote
  #9   (View Single Post)  
Old 23rd July 2008
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 696
Default

Have a look at the output of # dmesg to see extra error messages and information.

Note also that FreeBSD only has read-only support for most of the Linux filesystems (XFS, ReiserFS, JFS, etc). There's only read-write support for ext2. The "read-only filesystem" error is mount telling you that you really should add -r to the mount command for these filesystems. It added this for you, output the error, then mounted the fs read-only.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
Old 23rd July 2008
ivanatora ivanatora is offline
Real Name: Ivan
Fdisk Soldier
 
Join Date: Jul 2008
Location: Bulgaria
Posts: 51
Default

Yep, everything is OK now.
Reply With Quote
Old 23rd July 2008
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 696
Default

Could you post what you did to make it all work? Then others with similar issues will find the solution.

Thanks.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
Old 24th July 2008
ivanatora ivanatora is offline
Real Name: Ivan
Fdisk Soldier
 
Join Date: Jul 2008
Location: Bulgaria
Posts: 51
Default

I've already posted it, but here it is again -
1) Setting vfs.usermount = 1
2) Unmounting all filesystems
2) Chowning the /mnt tree - chown -R ivanatora:ivanatora /mnt
3) Set permissions for these devices - chmod a+rw /dev/ad*
and then added into /etc/defvs.rules:
Code:
[myrules=10]
add path 'ad*' mode 0666
and into rc.conf:
Code:
devfs_system_ruleset="myrules"
NOTE: This is sorta *not so secure* permission set. It would be better to use 660 permissions and add your group to the group owner of the /dev/ad*
4) Added these filesystems to /etc/fstab so they will be automatically mounted after next reboot:
Code:
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ad4s1b             none            swap    sw              0       0
/dev/ad4s1a             /               ufs     rw              1       1
/dev/acd0               /cdrom          cd9660  ro,noauto       0       0
/dev/ad0s7              /mnt/storage    msdosfs rw              0       0
/dev/ad0s5              /mnt/ntfs       ntfs    rw              0       0
/dev/ad0s1              /mnt/xp         ntfs    rw              0       0
/dev/ad0s8              /mnt/linux      ext2fs  rw              0       0
/dev/ad0s6              /mnt/extra      reiserfs        ro      0       0
/dev/da1s1              /mnt/mmc        msdosfs,noauto  rw              0       0
Reply With Quote
Old 27th July 2008
Errinok Errinok is offline
Port Guard
 
Join Date: Jun 2008
Posts: 14
Default

how are you able to write with the ntfs filesystem? i was under the impression that the freebsd mount_ntfs program has no write support and to write to an ntfs filesystem u needed to use the ntfs-3g program provided by the fuse-ntfs package/
Reply With Quote
Old 27th July 2008
ninjatux's Avatar
ninjatux ninjatux is offline
Real Name: Baqir Majlisi
Spam Deminer
 
Join Date: May 2008
Location: Antarctica
Posts: 293
Default

You could always use dbus + HAL if you wanted to.
__________________
"UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity."
MacBook Pro (Darwin 9), iMac (Darwin 9), iPod Touch (Darwin 9), Dell Optiplex GX620 (FreeBSD 7.1-STABLE)
Reply With Quote
Old 27th July 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Default

Quote:
Originally Posted by Errinok View Post
how are you able to write with the ntfs filesystem? i was under the impression that the freebsd mount_ntfs program has no write support and to write to an ntfs filesystem u needed to use the ntfs-3g program provided by the fuse-ntfs package/
You _can_ tell freebsd to mount ntfs read-write: but that is like saying that you can bungee jump using dental floss as a rope.

It will cause strange behavior and filesystem corruption.

You are correct - and it is a pity that someone (me included) didn't tweak to that one sooner - he should be using fuse-ntfs.
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote
Old 30th July 2008
ivanatora ivanatora is offline
Real Name: Ivan
Fdisk Soldier
 
Join Date: Jul 2008
Location: Bulgaria
Posts: 51
Default

Yes, now I'm using the ntfs-3g driver.
Here is how I did it (as long as I remember):
1) Install package fusefs-ntfs
2) Add to rc.conf:
Code:
fusefs_enable="YES"
AND/OR do it on the fly:
Code:
/usr/local/etc/rc.d/fusefs start
3) Using ntfs-3g you can mount filesystems only with the mount_ntfs-3g command, which appears to not be working with fstab. That's why a little patch must be applied to the mount program. Here is the patch.
4) Change NTFS entries in /etc/fstab from ntfs to ntfs-3g, like that:
Code:
/dev/ad0s5              /mnt/ntfs       ntfs rw              0       0
becomes:
Code:
/dev/ad0s5              /mnt/ntfs       ntfs-3g rw              0       0
Voila.
Reply With Quote
Reply

Tags
mount

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expressions: renaming files with 'sed' J65nko Guides 26 15th October 2010 08:03 PM
PHP regular expression help cajunman4life Programming 2 16th August 2008 05:17 PM
are you an former bsdforum regular? ephemera Off-Topic 18 28th July 2008 12:57 PM
dvd filesystem type chill FreeBSD General 6 17th June 2008 08:22 AM
Best Filesystem thavinci FreeBSD General 25 29th May 2008 03:32 PM


All times are GMT. The time now is 07:23 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick