Search code examples
unixgitlabchmodgitlab-omnibus

Permission issues with external ntfs HDD, gitlab-ctl reconfigure changing permissions: "Operation not permitted"


I'm using gitlab on a rasberry pi model 3 B. Following some information about my setup (sudo gitlab-rake gitlab:env:info):

System information
System:         Raspbian 8.0
Current User:   git
Using RVM:      no
Ruby Version:   2.3.6p384
Gem Version:    2.6.13
Bundler Version:1.13.7
Rake Version:   12.3.0
Redis Version:  3.2.11
Git Version:    2.14.3
Sidekiq Version:5.0.5
Go Version:     go1.3.3 linux/arm

GitLab information
Version:        10.6.0-rc3
Revision:       52fa89e
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     postgresql
URL:            http://gitlab.example.com
HTTP Clone URL: http://gitlab.example.com/some-group/some-project.git
SSH Clone URL:  git@gitlab.example.com:some-group/some-project.git
Using LDAP:     no
Using Omniauth: no

GitLab Shell
Version:        6.0.3
Repository storage paths:
- default:      /mnt/SeagateExpansion/GitLab/repositories
Hooks:          /opt/gitlab/embedded/service/gitlab-shell/hooks
Git:            /opt/gitlab/embedded/bin/git

After the gitlab update to version 10.6.0 I need to change the url again but when I do the necessary changes in /etc/gitlab/gitlab.rb and run sudo nano gitlab-ctl reconfigure I get the following error messages:

  ========================================================================
  Error executing action `run` on resource 'ruby_block[directory resource: 
  /mnt/SeagateExpansion/GitLab]'
  ========================================================================

and

============================================================================
Error executing action `create` on resource 
'storage_directory[/mnt/SeagateExpansion/GitLab]'
============================================================================

The result message says:

There was an error running gitlab-ctl reconfigure:

storage_directory[/mnt/SeagateExpansion/GitLab] (gitlab::gitlab-rails line 42) had an error: Mixlib::ShellOut::ShellCommandFailed: ruby_block[directory resource: /mnt/SeagateExpansion/GitLab] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/storage_directory.rb line 33) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of chmod 00700 /mnt/SeagateExpansion/GitLab ----
STDOUT:
STDERR: chmod: changing permissions of ‘/mnt/SeagateExpansion/GitLab’: Operation not permitted
---- End output of chmod 00700 /mnt/SeagateExpansion/GitLab ----
Ran chmod 00700 /mnt/SeagateExpansion/GitLab returned 1

So the problem seems to be, that the execution of the run and create command on the resource storage (GitLab folder on the external HDD [HDD = SeagateExpansion]) expects the permissions to be 700, right?
According to this errors I tried to change the permission of the external HDD folder /mnt/SeagateExpansion/GitLab see the ls -l output:

drwxrwxrwx 1 root GitLabUser        0 Jan  4 17:55 GitLab

With the help of this post I tried to change the permission with the command:

sudo find /mnt/SeagateExpansion/GitLab -type d -exec chmod 700 {} \;

to the required permission 700. But the changes don't take affect. I also tried chmod -R 700 /mnt/SeagateExpansion/GitLab and executed the commands as root but the changes don't take effect. Even after restarting the raspberry pi. What am I doing wrong?

I also tried to change the options settings/flag of the HDD in /etc/fstab to user but this doesn't help ether.

I'm thankful for every hint and answer :).

Best regards,

Bredjo


Solution

  • I finally figured it out. The solution is to change the mount settings in the /etc/fstab. Because if you have the wrong options settings (see: https://en.wikipedia.org/wiki/Fstab) you are not able to change the permissions because its a ntfs filesystem.

    So my old fstab entry was this:

    UUID=FE820568820526AD   /mnt/SeagateExpansion   ntfs defaults,gid=GitLabUser   0       0
    

    And the new entry is this:

     UUID=FE820568820526AD   /mnt/SeagateExpansion   ntfs-3g permissions   0       0
    

    Note that you need to install ntfs-3g to use it in fstab. And the permissions options only comes with ntfs-3g. See: https://www.tuxera.com/community/ntfs-3g-advanced/ownership-and-permissions/

    After this change I executed again:

    sudo gitlab-ctl reconfigure
    

    Now the error disappeared and the permission 700 of the folder /mnt/SeagateExpansion/GitLab could be set. I also noticed that the owner of the GitLab folder was also changed to user git after the reconfiguration:

    drwx------ 1 git  root        0 Jan  4 17:55 GitLab
    

    That's because I don't need the option gid=GitLabUserany more.
    Now everything works again :).