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.

After a nasty episode (my second, you'd think I'd learn) caused by unsupervised automated podcast downloads filling my entire partition, I've finally moved just ~/Music to its own partition. The partition I'm using was already formatted NTFS (this is the genius part: when I got this computer three years ago, I actually set it up with a 20G music partition precisely because I'd had this problem before, but I never actually organized myself to store music on it. So that's my backstory. Here's what I need now:

I have two partitions that I want to start mounting on startup:

/dev/sda3   /mnt/devel  ext4    defaults    0   2
/dev/sda2   /mnt/excess ntfs    defaults    0   2

The ext4 partion mounts fine (owned by me, writeable only by me), but the ntfs mounts owned by root with read and write permission for all. I'm not sure how to fix this. Is there something quirky about ntfs or did I do something elsewhere that's causing this problem?

drwxr-xr-x  7 amanda amanda 4096 2012-03-14 19:07 devel
drwxrwxrwx  1 root   root   4096 2012-03-14 22:38 excess
share|improve this question
    
The options "noatime" or "relatime" is available and recommended for permanent ntfs mounting (see man mount.ntfs). I had some hdd busy-ness problems with ext3/4 and ntfs too! –  user259044 Mar 17 at 4:13

4 Answers 4

up vote 22 down vote accepted

Permissions for ntfs and vfat file systems must be set with the dmask, fmask and umask options. dmask controls permissions for directories, fmask controls permissions for files, and umask controls both. Since these options set masks, they should be the compliment of the permissions you want. For example, rwx for the owner and rw for others is 022 rather than 755.

To set the owner, use the uid and gid options for user and group, respectively. You can find your UID with the command echo $UID. To find your GID, use cat /etc/group. These values are both usually 1000.

A common set of mount options for ntfs is uid=1000,gid=1000,dmask=027,fmask=137. This sets you as the owner of the drive, and sets the permissions to drwxr-x---.

share|improve this answer
    
help.ubuntu.com/community/Fstab#ntfs –  Amanda Mar 17 '12 at 14:52
    
That is indeed the source of much of the above. I also included some more detailed explanations of how the *mask options work. –  bessman Mar 17 '12 at 14:56
    
Thanks. The "mask" part of masking threw me for a loop. 111 gets you -rw-rw-rw- not ---x--x--x –  Amanda Mar 17 '12 at 20:07
    
You can also use the id command to find your UID and GID. –  Sandeep Datta Nov 3 '13 at 16:48
1  
Could you possibly provide a more complete example showing those options used in a line from /etc/fstab –  puk Nov 15 '13 at 3:34

If you mount the ntfs partition with the permissions option, then chmod / chown will work

/dev/sda2   /mnt/excess ntfs-3g    permissions,locale=en_US.utf8    0   2

You can then

sudo chown your_user:your_user /mnt/excess

Easier then uid,dmask,fmask.

share|improve this answer

Might not be a good solution , but you can always map user id to your own one , or the group id:

Just an example here , my user id was 1000

/dev/sda5 /mnt/excess ntfs defaults,uid=1000,rw 0 0

In that case , all files mounted owned by user ided 1000

share|improve this answer
1  
That works, but with or with out the "rw" option, it still mounts with permissions drwxrwxrwx –  Amanda Mar 17 '12 at 14:10

I had some trouble with this because when I reboot the disk name changes... (sda0 to sdb2)

I fixed the problem by mounting them by UUID in the fstab, you can view the UUID for your harddrives by entering: sudo blkid

Make a back-up of your fstab file:

sudo cp /etc/fstab /etc/fstab.orig

Make sure you tripple check the >>, if you place one > you overwrite your fstab!

sudo blkid >> /etc/fstab

If you still screwed up you can replace your fstab with the original:

sudo cp /etc/fstab.orig /etc/fstab

Next make a folder:

sudo mkdir /media/mydrivename

Configure the fstab:

sudo vim /etc/fstab

Don't forget to comment the output from the blkid with a '#' on the beginning of the lines!

Add this to the fstab file, you can find the UUID in the block on the bottom you inserted with the command above. media/mydrivename is where the partition should be mounted.

UUID=xxxxxxxxxxxxxxxxx   /media/mydrivename ntfs    permissions,locale=en_US.utf8    0   2

This is my fstab file:

# /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/sda2 during installation
UUID=5d4940cf-5cf5-443a-be11-1f7e551962d1 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda1 during installation
UUID=84b7e5e9-08c3-4641-b28b-99e0255e604d none            swap    sw              0       0

# 500 GB Webserver harddisk from lr-serv-01
UUID=BA9A48D39A488E37 /media/hdd1 ntfs permissions,locale=en_US.utf8 0 2

# 2 TB Movie share harddisk from lr-serv-01
UUID=7EB09666B09624A5 /media/hdd2 ntfs permissions,locale-en_US.utf8 0 2

#/dev/sda1: UUID="10EC004DEC003010" TYPE="ntfs" 
#/dev/sda2: LABEL="system" UUID="88A4FE47A4FE3772" TYPE="ntfs" 
#/dev/sda3: LABEL="storage_01" UUID="BA9A48D39A488E37" TYPE="ntfs" 
#/dev/sdb1: LABEL="storage_02" UUID="7EB09666B09624A5" TYPE="ntfs" 
#/dev/sdc1: UUID="84b7e5e9-08c3-4641-b28b-99e0255e604d" TYPE="swap" 
#/dev/sdc2: UUID="5d4940cf-5cf5-443a-be11-1f7e551962d1" TYPE="ext4" 
#/dev/sdd1: LABEL="storage_spotnet" UUID="EC6E8F416E8F0394" TYPE="ntfs" 
#/dev/sdd2: LABEL="storage_backup_pcs" UUID="6C2699D026999BA0" TYPE="ntfs" 
#/dev/sdd5: LABEL="storage_series" UUID="7670ABF770ABBC6D" TYPE="ntfs" 
#/dev/sdd6: LABEL="storage_winmx" UUID="564AB81B4AB7F5B9" TYPE="ntfs" 

Reboot the system by typing:

sudo reboot

To check if the partition is mounted you can type df -k.

Give ownership to yourself:

sudo chown -R USERNAME:USERNAME /media/mydrivename

Did this on Ubuntu Server 14.04.01!

Hope this answer helps someone ;-)

share|improve this answer
    
While this sounds like generally solid advice, I would find it more elegant to simply copy the UUID from the output of sudo blkid instead of dumping the whole thing to /etc/fstab and transiently corrupt it. Another way would be to get the UUID from the properties dialogue of the partition in GParted. –  David Foerster Oct 19 at 12:09
    
Well as I am doing this on my server I don't really see a way to copy it... All I have is a keyboard and bash. –  Lars Rotgers Oct 19 at 13:46
    
Most terminal emulators allow you to copy things (assuming you're using remote access or a terminal emulator like screen or tmux instead of a raw virtual terminal). –  David Foerster Oct 19 at 13:55
    
Bad assumption haha, I was not using a terminal emulator. However, I added some stuff to my answer for making a copy of the fstab file in case someone screws up. :) –  Lars Rotgers Oct 19 at 13:59

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.