Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've attached a SSD disk though USB. Then:

 sudo su -
 mkdir /mnt/hx
 chown ondra /mnt/hx
 mount /dev/sdb1 /mnt/hx  # It's FAT32 now, but was the same with EXT4

The last command changes dir owner to root. Whenever I create a file in the root dir, I need to be root and root is the owner.

Can I set different user as owner of the mounted dir? Or, simply said, ensure that user XY can freely read/write on the drive.

share|improve this question
    
Why don't you just sudo mkdir -p /mnt/hx then sudo mount /dev/sdb1 /mnt/hx? –  Chris Wayne Sep 20 '12 at 20:24
    
Seems like it's the uid=1000,gid=1000 options –  Ondra Žižka Sep 20 '12 at 20:28
    
You gotta do a sudo chown -R username:groupname /folder. The -R makes the chown permissions be applied recursively. Also check the chmod, even that takes the -R parameter. –  nitstorm Sep 20 '12 at 20:32
add comment

1 Answer 1

up vote 1 down vote accepted

Gnome-based GUI environment

gvfs-mount -d /dev/sdb1

Easy as that.

Headless (no GUI) machine

Add an entry in /etc/fstab and specify options for it.

From the manpage of fstab:

   The fourth field (fs_mntops).
          This field describes the mount options associated with the filesystem.

          <snip>

          user   allow a user to mount
          owner  allow device owner to mount

Now you'll need to make sure the device is owned by the correct owner. Specify that in an udev rule. Put a file in /etc/udev/rules.d/50-myhdd-ownerchange.rules:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0ff9", MODE="0600", OWNER="username"

Replace the vendor and product ids with the USB device you want to get triggered by it. Find them using the command lsusb. Also change the MODE if you like.

Alternatively, use pmount. I don't like it, personally.

share|improve this answer
    
I have mounted it succesfully. But now I can't exec executable files, not even with exec amongst options. –  Ondra Žižka Sep 20 '12 at 21:34
    
@OndraŽižka Are you sure about the order of options you gave in the fourth field? The example in the manpage mentions user,exec. AFAIK if you would do exec,user, then user will override the exec option with its implication noexec. If it still does not work, please share the relevant line in /proc/mounts. –  gertvdijk Sep 20 '12 at 21:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.