m1gin 50

In Ubuntu, I wanted to create a virtual directory for Apache web server is actually located on NTFS partition. 
I do that. But when I tried to access the URL, I get acces denied error like:

"403 - Forbidden
You don't have permission to access ... on this server."

Then, I tried to change file/folder permissions but unsuccesful. Then, I noticed that succeed if the file/folder is in ext4 file system partition.
So I started to search for how can I change owner or file permissions on NTFS partition in Ubuntu. 

Solution 1

Firstly, I unmounted the NTFS partition by file manager.

Then, I looked which partition I want:

sudo fdisk -l

I see that dev/sda3 is my NTFS partition.

Temporarily Mounting

If you need to mount the partition temporarily, you can do this by Terminal.

sudo mkdir /media/mypart1
sudo mount /dev/sda3 /media/mypart1 -o permissions
 
That's it. Now you should see the files and folders by opening the path /media/mypart1

Permanently Mounting

If you want this partition mounted permanently, then you can edit the file /etc/fstab and add a line like:

/dev/sda3 /media/mypart1 ntfs-3g locale=tr_TR.UTF-8,permissions 0 0

(You should change some options for your state).

Then, if you don't have /media/mypart1 folder, create it.

sudo mkdir /media/mypart1

And now, unmount and re-mount the partition:

sudo umount /dev/sda3
sudo mount /media/mypart1

Now, we can see the files and folders on /media/mypart1

Changing File/Folder Owner and Permissions

After mounting the NTFS partition with permissions option, now we are ready to change file/folder owner and file permissions.

To manage the ownership of a directory we can use the command chown

sudo chown user:group -R /media/mypart1/afolder

To change permissions of a directory/file we can use the command chmod

sudo chmod -R ug+rw,o=r /media/mypart1/afolder

By this command the user and the group has read and write permissions, and the others set  to read only.

Here is some options meaning:

u: user
g: group
o: other
r: read
w: write
x: execute
-R: recursively for sub files/folders

For examle if we want to grant read, write, execute for owner user, and read only for group, and no access for other, we can use a command like:

sudo chmod -R u=rwx,g=r,o= /media/mypart1/afolder

By the way, we can also use a file manager (like Thunar, PcManFM) to change permissions or owner by GUI.

Solution 2

I recently realized that, we can also create a symbolic link for a folder located on NTFS partititon. It is very simple solution. For example:

sudo ln -s /media/mypart1/afolder /var/www/html/ntfsdir1

Of course, /var/www/html is root folder for localhost.

Then we can access the directory as: http://localhost/ntfsdir1

2015/10/23 Update:

After I already did above settings, I kept getting access error for an alias located on NTFS partition.
I found a solution by editing Apache VirtualHost configuration as follow:

<VirtualHost *:80>
     Alias /ntfs1 "/media/data/testntfs1"
     Alias /ntfs2 "/media/data/testntfs2"

    <Directory "/media/data">
       allow from all
       Options Indexes Includes FollowSymLinks MultiViews
       Require all granted
    </Directory>
</VirtualHost>

 

References:


#from blog.mbirgin.com, archive, ubuntu, ubuntu tips, change owner, file permissions, chown, chmod, virtual directory on ntfs partition, apache web server, linux, folder permissions

Add to: