Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Mount permissions HDD

New to Debian (Or Linux in general)? Ask your questions here!
Message
Author
Lamios
Posts: 37
Joined: 2017-12-09 23:26

[Solved] Mount permissions HDD

#1 Post by Lamios »

Hello,

currently I installed mpd on my Debian 9. Mpd works fine, except that it cannot play music from my HDD I share with Windows. The HDD is ntfs formatted and owned by root. To solve the resulting permission problem for mpd, I thought to automatically mount the HDD with user permissions. In the moment I have created the respective folder for the mounting in /media
I wanted to extend fstab by the following line:
UUID=MediaUUID /media/Volume ntfs-3g defaults, auto, uid=Myuid, gid=????, umask=??? 0 0
Now I have the problem that I don't know which ID I have to use for the group. Which group should one normally use as group owner for mounted HDDs? I have all my data on this HDD, not only music. Thus, audio is maybe not the right group.
And finally, which permissions should I assign? Here I thought about 023, but I am not sure if this is appropriate.

Thanks for your help!
Last edited by Lamios on 2018-01-26 20:18, edited 1 time in total.

User avatar
dotlj
Posts: 646
Joined: 2009-12-25 17:21

Re: Mount permissions HDD

#2 Post by dotlj »

If you share a HDD with Windows, why set the owner to root, and not to your user ID?
why not simply
chown -R lambios:lambios /media/Volume

Then you won't have permission problems.
Your user is probably a member of the groups needed, as you say Mpd works fine.


p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Mount permissions HDD

#4 Post by p.H »

dotlj wrote:why not simply
chown -R lambios:lambios /media/Volume
Because that does not work with NTFS. The NTFS format ignores Unix permissions so they have to be set at mount time with mount options as in the OP's post.

Lamios
Posts: 37
Joined: 2017-12-09 23:26

Re: Mount permissions HDD

#5 Post by Lamios »

Thank you for your answers.
I had been able to find the the group for my user.
Now the only question is, which permissions should I set to maintain privacy?

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: Mount permissions HDD

#6 Post by bw123 »

I don't understand why you're having trouble, when I mount an ntfs partition I am able to access everything on it with a simple mount command:

Code: Select all

# mount /dev/sdb1 /mnt
# mount | grep mnt
/dev/sdb1 on /mnt type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
I can read and write files as a regular user just fine. I do have pkg ntfs-3g installed.
which permissions should I set to maintain privacy?
What privacy? They are music files. Who do you want privacy from?
UUID=MediaUUID /media/Volume ntfs-3g defaults, auto, uid=Myuid, gid=????, umask=??? 0 0
Be sure no spaces in your string of options, but I would think just defaults should work for fstab entry. Just get it working first and worry about fine-tuning later. Don't make it complicated unless you have to.
resigned by AI ChatGPT

Lamios
Posts: 37
Joined: 2017-12-09 23:26

Re: Mount permissions HDD

#7 Post by Lamios »

Thanks.
I mounted the HDD. The mounting worked fine. However, mpd is not able to read music from the HDD (but is able to read some from /home). In the moment umask=023, but I also changed it to 000 once, which did not change anything.
The first time I accidentally copied the line with the spaces and than mpd had been playing music from the HDD, but I got some problems during unmounting. Thanks for the hint with the spaces, I wouldn't have seen that. Did I make a mistake in the string of options?

Code: Select all

UUID=MyUUID /media/Volume ntfs-3g defaults,auto,uid=Myuid,gid=Mygid,umask=023 0 0

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: Mount permissions HDD

#8 Post by bw123 »

You're just making it too hard, and it's really not that complicated. I think you should study more about linux with ntfs before you really wreck something. Please don't type in any commands you find on the internet.
UUID=MyUUID /media/Volume ntfs-3g defaults,auto,uid=Myuid,gid=Mygid,umask=023 0 0
Is this some kind of code because you don't want to copy and paste, or you think people on here will hack your UUID, UID, and GID or what? What's the umask=23 supposed to do?

have you tried with just the default mount options? Who told you that you needed all this complicated stuff?
resigned by AI ChatGPT

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Mount permissions HDD

#9 Post by debiman »

can you access the ntfs partition normally? through filemanager, terminal?
did you look at the search results i provided?

Lamios
Posts: 37
Joined: 2017-12-09 23:26

Re: Mount permissions HDD

#10 Post by Lamios »

I did read your search results. Most of them I had read during my research before my post.

The ntfs is accessible and I am able to write on it or play music with another player.

Permissions and ownership for the test music library I created in /home are identical to the ones from my music folder on the HDD.
ls -al on the HDD gives the following (I am not sure if it is helpful):

Code: Select all

:/media/Volume# ls -al                                                                                                                                                                                                                                        
total 784                                                                                                                                                                                                                                                                      
drwxr-xr-- 1 user user   8192 Jan 23 12:20 .                                                                                                                                                                                                                 
drwxr-xr-x 5 root          root            4096 Jan 21 16:19 ..                                                                                                                                                                                                                
drwxr-xr-- 1 user user   4096 Jan 21 18:41 Pictures                                                                                                                                                                                                                                                                                                                                                                                                           
drwxr-xr-- 1 user user  32768 Jan 16 14:18 Documents                                                                                                                                                                                                                                                                                                                                                                                                      
drwxr-xr-- 1 user user  65536 Jan 13 23:08 Music  
Could it be caused by the second line, which ends with .. and has root as owner?

I also tried to run mpd as user. I than only got the following error after reboot: Connection to "Default" (localhost:6600) failed
But I think that does not reflect the problem that mpd cannot play music from HDD when set to user mpd?

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: Mount permissions HDD

#11 Post by bw123 »

Lamios wrote:
drwxr-xr-- 1 user user 65536 Jan 13 23:08 Music
<snip>
Could it be caused by the second line, which ends with .. and has root as owner?
<snip>
...the problem that mpd cannot play music from HDD when set to user mpd?
No, it's not because of the second line.
resigned by AI ChatGPT

Lamios
Posts: 37
Joined: 2017-12-09 23:26

Re: Mount permissions HDD

#12 Post by Lamios »

0k. Is there anything I could post that might help to find the cause for the problem?

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: Mount permissions HDD

#13 Post by bw123 »

Lamios wrote:0k. Is there anything I could post that might help to find the cause for the problem?
It's because you have removed the search bit for the directories. I didn't even know you could do this on ntfs, how you managed it? You don't need to change permissions and ownership without understanding what it does. I really don't know how to fix it on ntfs. I never used chmod or chown on ntfs before. I always mount ntfs with default options and owner is root:root with 777 permissions and that works fine for me. I have never seen an ntfs part mounted on linux that had two different owners on the files/dirs.

If that really is an ntfs partition, then you are probably doing something odd to mount it? Maybe you installed some kind of add-on that you forgot to mention?

Code: Select all

$ mkdir foodir
$ ls -al
total 12
drwxr-xr-x  3 me me 4096 Jan 23 18:13 .
drwxr-xr-x 20 me me 4096 Jan 23 18:13 ..
drwxr-xr-x  2 me me 4096 Jan 23 18:13 foodir
$ su
Password: 
# chown vnstat:vnstat foodir
# chmod 754 foodir
# exit
exit
$ ls -al
total 12
drwxr-xr-x  3 me    me    4096 Jan 23 18:13 .
drwxr-xr-x 20 me    me    4096 Jan 23 18:13 ..
drwxr-xr--  2 vnstat vnstat 4096 Jan 23 18:13 foodir
$ ls -al foodir
ls: cannot access 'foodir/.': Permission denied
ls: cannot access 'foodir/..': Permission denied
total 0
d????????? ? ? ? ?            ? .
d????????? ? ? ? ?            ? ..
resigned by AI ChatGPT

Lamios
Posts: 37
Joined: 2017-12-09 23:26

Re: Mount permissions HDD

#14 Post by Lamios »

In don't know. All I did (as far as I know) is adding this line to /etc/fstab

Code: Select all

UUID=0BE7094A0BE7094A /media/Volume ntfs-3g defaults,auto,uid=Myuid,gid=Mygid,umask=023 0 0
and creating the folder Volume in /media.

What does it mean to
have removed the search bit for the directories
and how do you see it?

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: Mount permissions HDD

#15 Post by bw123 »

Code: Select all

defaults,auto,uid=Myuid,gid=Mygid,umask=023 0 0
    ^     ^    ^         ^         ^
good|     |    |         |         |
    why? -|    |         |         |
         why? -|         |         |
                   why? -|         |
                             wtf? -| 


drwxrwxrwx
   ^  ^  ^
   |  |  |
   |________ dir srch bits

resigned by AI ChatGPT

Lamios
Posts: 37
Joined: 2017-12-09 23:26

Re: Mount permissions HDD

#16 Post by Lamios »

0k, thanks. I used the guide on https://ubuntuforums.org/showthread.php?t=1604251 Maybe it had not been the best way to do it.

User avatar
Thorny
Posts: 542
Joined: 2011-02-27 13:40

Re: Mount permissions HDD

#17 Post by Thorny »

Lamios wrote:0k, thanks. I used the guide on https://ubuntuforums.org/showthread.php?t=1604251 Maybe it had not been the best way to do it.
To say the least, following advice from 2010 of a different distro than Debian isn't likely to be the best way to proceed.

Tell bw123 what you have entered for uid and gid, there is no reason for you to keep that information secret, especially if you want help fixing the problem. bw123 is trying to help you and the rest of us watching would warn you if you didn't get good advice.

At the same time, open a terminal and enter

Code: Select all

id
then copy and paste that information into a code box in your reply. If you are the user that installed Debian then it is likely to be 1000 anyway, just like mine.

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: Mount permissions HDD

#18 Post by sunrat »

I'll show you mine. ;) I have an external drive where I back up and sync between 2 computers and use ntfs as it needs to be accessible in Windows too.

Code: Select all

LABEL=green-media    /mnt/green-media    auto   noauto,user,uid=roger,gid=roger,rw,noatime   0   0
uid and gid is needed to keep consistency with sync. You can use name or numerical id, curiously mine is

Code: Select all

$ id roger
uid=1000(roger) gid=1004(roger)
so I just put name. You don't need umask and don't need rw or noatime or noauto (or auto) if you just use defaults.
Try

Code: Select all

UUID=0BE7094A0BE7094A /media/Volume ntfs-3g defaults,uid=<whatever>,gid=<whatever> 0 0
"Removing the search bits" is what the umask does. It's called "execute" bit and you can't enter a directory without it.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

Lamios
Posts: 37
Joined: 2017-12-09 23:26

Re: Mount permissions HDD

#19 Post by Lamios »

Yes, it had not been the best idea to follow and outdated tutorial from another distro :oops:
Sorry for not having shared this content in before. I thought it is better not to make things public, when I am not sure if one should make it public :)

Here is the line I wrote at the end of /etc/fstab

Code: Select all

UUID=0BE7094A0BE7094A /media/Volume ntfs-3g defaults,auto,uid=1000,gid=1000,umask=023 0 0
and this is the output from id

Code: Select all

uid=1000(Lamios) gid=1000(Lamios) groups=1000(Lamios),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),108(netdev),114(bluetooth),115(lpadmin),119(scanner)
So I basically just have to delete umask? And follow the code from sunrat.

Thanks for your help!

Lamios
Posts: 37
Joined: 2017-12-09 23:26

Re: Mount permissions HDD

#20 Post by Lamios »

I deleted the umask part and now everything works again :)
Can I let auto where it is? I think it is for automatic mount during booting?

Post Reply