I recently rebuilt my home server from Ubuntu to CentOS. 90% of the servers I use at work are RedHat based, so I wanted to cut down on OS fracture, as well as trying to get completely au fait with the CentOS/systemd way of doing things. Ubuntu and I have had some good times. It was the first Linux distro I used, and, in a very roundabout way, set me on my odd career path from Literature grad to IT spod. Ubuntu, I love you, but it's time to cut the cord. We'll always have 12.04.

Most of the stuff I use my home server for is housed on a 2nd internal HDD, mounted via fstab at /mnt/media. This disk is very much a vintage piece, having been pilfered many years ago from a Windows PC. It's therefore NTFS formatted, and I never changed this when originally setting it up as I had no idea about the implications for permissions. It's now got 800GB+ of stuff on it, and I don't have a convenient alternative location to sync the data to in order to reformat the disk as something more Linux friendly. So, I'll work with what I've got.

Before the rebuild, I had the disk mounting happily as read/write at boot time. After the rebuild, I (quickly) noticed that the disk was owned by root, and I couldn't change the permissions. For example:

$ ls -l /mnt/media
drwxrwx--- 1 root        root         0 Dec 30 15:50 dir1
drwxrwx--- 1 root        root         0 Dec 21 22:25 dir2
$ sudo chown -R myuser /mnt/media/dir1
$ ls -l /mnt/hdd
drwxrwx--- 1 root        root         0 Dec 30 15:50 dir1
drwxrwx--- 1 root        root         0 Dec 21 22:25 dir2

Great. Naturally, I didn't take a backup of /etc/fstab.

There's a million posts online about how to configure an NTFS mount to adopt Unix permissions by smarter people than me. I made use of these when setting up the mount for Ubuntu, but had no recollection of which solution actually worked for me. What follows is how I did it on CentOS 7. Corrections and/or improvements welcomed!

I could not get my NTFS mount permissions working without a full reboot. umount /mnt/media followed by mount -a did not seem to have the desired effect.

  1. My Setup
  2. Enable EPEL repository
  3. Install NTFS software
  4. Obtain UUID of your NTFS mount
  5. Configure fstab
  6. Check setup
My setup
  • CentOS 7.2.1511
  • 1TB Hitachi HDS721010KLA330 SATA
Enable EPEL repository
$ wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
$ rpm -ivh epel-release-7-5.noarch.rpm

Learn more about the EPEL repository here.

Install NTFS software
$ yum install ntfs-3g ntfsprogs fuse
Obtain UUID of your NTFS mount

My disk is recognised as /dev/sdb, with the data partition at /dev/sdb1. Substitute in your partition here. If you don't know it, the lsblk and fdisk -l commands will help.

$ blkid | grep /dev/sdb1
/dev/sdb1: LABEL="Data" UUID="12345678910" TYPE="ntfs"
Configure fstab
  • Open the file:
$ vim /etc/fstab
  • Add a line for your NTFS mount as follows:
UUID=662853BD28538AC7	/mnt/media	ntfs-3g	rw,auto,users,permissions	0 0
  • Save and quit, then reboot:
$ reboot
Check setup

Once rebooted, log back in, then check the setup as follows:

  • Check the mount:
$ mount | grep /dev/sdb1
/dev/sdb1 on /mnt/media type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
  • Test changing permissions:
$ sudo chown -R myuser /mnt/media/dir1
$ ls -l /mnt/media/
drwxrwx--- 1 myuser        root         0 Dec 30 15:50 dir1
drwxrwx--- 1 root        root         0 Dec 21 22:25 dir2

There's a number of umask, dmask and fmask options you can set in fstab to make the partition more secure, particularly for shared environments. As this is just a personal device (and I've had limited success with any of those options), I've left it as is.