Sharing a mounted drive with samba on CentOS7












0















CentOS 7, samba issue: 0 Files/Folders when trying to share USB drive with EXT4 file system.



Samba Configuration file:



[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = 271-filesharing
security = user
map to guest = bad user
dns proxy = no

#============================ Share Definitions ==============================
[Administrator]
path = /mnt/ELEMENTERY-1TB/
browsable =yes
writable = yes
public = no
valid users = RVS


I have user called RVS on samba. I can access samba share using my macbook pro when I use path to user's home directory.



I've done sudo chown RVS:RVS -R /mnt/ELEMENTERY-1TB. Here are the permissions of the drive:



[RVS@271 mnt]$ ls -al
total 4
drwxr-xr-x. 3 RVS RVS 28 Sep 12 00:26 .
dr-xr-xr-x. 17 root root 224 Sep 9 11:27 ..
drwxrwxrwx. 4 RVS RVS 4096 Sep 12 00:26 ELEMENTERY-1TB


I also mounted this drive as RVS user with sudo mount /deb/sdb /mnt/ELEMENTERY-1TB.



Is there something I have skipped in configuration/permissions?










share|improve this question





























    0















    CentOS 7, samba issue: 0 Files/Folders when trying to share USB drive with EXT4 file system.



    Samba Configuration file:



    [global]
    workgroup = WORKGROUP
    server string = Samba Server %v
    netbios name = 271-filesharing
    security = user
    map to guest = bad user
    dns proxy = no

    #============================ Share Definitions ==============================
    [Administrator]
    path = /mnt/ELEMENTERY-1TB/
    browsable =yes
    writable = yes
    public = no
    valid users = RVS


    I have user called RVS on samba. I can access samba share using my macbook pro when I use path to user's home directory.



    I've done sudo chown RVS:RVS -R /mnt/ELEMENTERY-1TB. Here are the permissions of the drive:



    [RVS@271 mnt]$ ls -al
    total 4
    drwxr-xr-x. 3 RVS RVS 28 Sep 12 00:26 .
    dr-xr-xr-x. 17 root root 224 Sep 9 11:27 ..
    drwxrwxrwx. 4 RVS RVS 4096 Sep 12 00:26 ELEMENTERY-1TB


    I also mounted this drive as RVS user with sudo mount /deb/sdb /mnt/ELEMENTERY-1TB.



    Is there something I have skipped in configuration/permissions?










    share|improve this question



























      0












      0








      0


      0






      CentOS 7, samba issue: 0 Files/Folders when trying to share USB drive with EXT4 file system.



      Samba Configuration file:



      [global]
      workgroup = WORKGROUP
      server string = Samba Server %v
      netbios name = 271-filesharing
      security = user
      map to guest = bad user
      dns proxy = no

      #============================ Share Definitions ==============================
      [Administrator]
      path = /mnt/ELEMENTERY-1TB/
      browsable =yes
      writable = yes
      public = no
      valid users = RVS


      I have user called RVS on samba. I can access samba share using my macbook pro when I use path to user's home directory.



      I've done sudo chown RVS:RVS -R /mnt/ELEMENTERY-1TB. Here are the permissions of the drive:



      [RVS@271 mnt]$ ls -al
      total 4
      drwxr-xr-x. 3 RVS RVS 28 Sep 12 00:26 .
      dr-xr-xr-x. 17 root root 224 Sep 9 11:27 ..
      drwxrwxrwx. 4 RVS RVS 4096 Sep 12 00:26 ELEMENTERY-1TB


      I also mounted this drive as RVS user with sudo mount /deb/sdb /mnt/ELEMENTERY-1TB.



      Is there something I have skipped in configuration/permissions?










      share|improve this question
















      CentOS 7, samba issue: 0 Files/Folders when trying to share USB drive with EXT4 file system.



      Samba Configuration file:



      [global]
      workgroup = WORKGROUP
      server string = Samba Server %v
      netbios name = 271-filesharing
      security = user
      map to guest = bad user
      dns proxy = no

      #============================ Share Definitions ==============================
      [Administrator]
      path = /mnt/ELEMENTERY-1TB/
      browsable =yes
      writable = yes
      public = no
      valid users = RVS


      I have user called RVS on samba. I can access samba share using my macbook pro when I use path to user's home directory.



      I've done sudo chown RVS:RVS -R /mnt/ELEMENTERY-1TB. Here are the permissions of the drive:



      [RVS@271 mnt]$ ls -al
      total 4
      drwxr-xr-x. 3 RVS RVS 28 Sep 12 00:26 .
      dr-xr-xr-x. 17 root root 224 Sep 9 11:27 ..
      drwxrwxrwx. 4 RVS RVS 4096 Sep 12 00:26 ELEMENTERY-1TB


      I also mounted this drive as RVS user with sudo mount /deb/sdb /mnt/ELEMENTERY-1TB.



      Is there something I have skipped in configuration/permissions?







      centos samba selinux






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 12 '17 at 12:36









      sebasth

      8,28632046




      8,28632046










      asked Sep 11 '17 at 19:23









      Rahul SharmaRahul Sharma

      1033




      1033






















          1 Answer
          1






          active

          oldest

          votes


















          1














          CentOS enables SELinux by default, which adds additional security restrictions on the system. Default policy mostly covers the typical/default configurations for confined software. When access is denied, usually a log entry is generated in audit logs in /var/log/audit/audit.log.



          With a removable media you should consider mounting the device with SELinux context option. This way you avoid modifying your system's SELinux policy and the need for filesystem relabeling on the removable device. You can use samba_share_t if you only intend to make the mount point to be used with samba. If you use/label user_home_t type, the files will be treated as if they were in user home directory.



          mount -t ext4 /dev/sdb /mnt/ELEMENTERY-1TB 
          -o context="system_u:object_r:samba_share_t:s0"


          Or in /etc/fstab



          UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1


          If you still have issues with SELinux,
          you can use audit2why to find out why access was denied, and possibly if a SELinux boolean exists to allow access. In case you need to alter SELinux policy, you can use audit2allow to generate a policy module to allow access.



          There are also two booleans samba_export_all_ro and samba_export_all_rw when enabled allow samba to access (and share) any files. In this case this allows samba significantly more access than required and therefore should not be used in this situation as mount options can be configured easily.






          share|improve this answer


























          • Dude, Dude Dude, Thankyou !!!

            – Rahul Sharma
            Sep 12 '17 at 5:25











          • Can i use this statement in fstab ? UUID=a6339f33-1c61-4c2c-a490-04c83ccfb4d6 /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro 0 1 -o context="system_u:object_r:samba_share_t:s0"

            – Rahul Sharma
            Sep 12 '17 at 5:53













          • add the context option with the other options: UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1

            – sebasth
            Sep 12 '17 at 6:03













          • That works !! Please append this in the answer for auto-mount, People will love this.

            – Rahul Sharma
            Sep 12 '17 at 6:11











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f391673%2fsharing-a-mounted-drive-with-samba-on-centos7%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          CentOS enables SELinux by default, which adds additional security restrictions on the system. Default policy mostly covers the typical/default configurations for confined software. When access is denied, usually a log entry is generated in audit logs in /var/log/audit/audit.log.



          With a removable media you should consider mounting the device with SELinux context option. This way you avoid modifying your system's SELinux policy and the need for filesystem relabeling on the removable device. You can use samba_share_t if you only intend to make the mount point to be used with samba. If you use/label user_home_t type, the files will be treated as if they were in user home directory.



          mount -t ext4 /dev/sdb /mnt/ELEMENTERY-1TB 
          -o context="system_u:object_r:samba_share_t:s0"


          Or in /etc/fstab



          UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1


          If you still have issues with SELinux,
          you can use audit2why to find out why access was denied, and possibly if a SELinux boolean exists to allow access. In case you need to alter SELinux policy, you can use audit2allow to generate a policy module to allow access.



          There are also two booleans samba_export_all_ro and samba_export_all_rw when enabled allow samba to access (and share) any files. In this case this allows samba significantly more access than required and therefore should not be used in this situation as mount options can be configured easily.






          share|improve this answer


























          • Dude, Dude Dude, Thankyou !!!

            – Rahul Sharma
            Sep 12 '17 at 5:25











          • Can i use this statement in fstab ? UUID=a6339f33-1c61-4c2c-a490-04c83ccfb4d6 /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro 0 1 -o context="system_u:object_r:samba_share_t:s0"

            – Rahul Sharma
            Sep 12 '17 at 5:53













          • add the context option with the other options: UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1

            – sebasth
            Sep 12 '17 at 6:03













          • That works !! Please append this in the answer for auto-mount, People will love this.

            – Rahul Sharma
            Sep 12 '17 at 6:11
















          1














          CentOS enables SELinux by default, which adds additional security restrictions on the system. Default policy mostly covers the typical/default configurations for confined software. When access is denied, usually a log entry is generated in audit logs in /var/log/audit/audit.log.



          With a removable media you should consider mounting the device with SELinux context option. This way you avoid modifying your system's SELinux policy and the need for filesystem relabeling on the removable device. You can use samba_share_t if you only intend to make the mount point to be used with samba. If you use/label user_home_t type, the files will be treated as if they were in user home directory.



          mount -t ext4 /dev/sdb /mnt/ELEMENTERY-1TB 
          -o context="system_u:object_r:samba_share_t:s0"


          Or in /etc/fstab



          UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1


          If you still have issues with SELinux,
          you can use audit2why to find out why access was denied, and possibly if a SELinux boolean exists to allow access. In case you need to alter SELinux policy, you can use audit2allow to generate a policy module to allow access.



          There are also two booleans samba_export_all_ro and samba_export_all_rw when enabled allow samba to access (and share) any files. In this case this allows samba significantly more access than required and therefore should not be used in this situation as mount options can be configured easily.






          share|improve this answer


























          • Dude, Dude Dude, Thankyou !!!

            – Rahul Sharma
            Sep 12 '17 at 5:25











          • Can i use this statement in fstab ? UUID=a6339f33-1c61-4c2c-a490-04c83ccfb4d6 /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro 0 1 -o context="system_u:object_r:samba_share_t:s0"

            – Rahul Sharma
            Sep 12 '17 at 5:53













          • add the context option with the other options: UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1

            – sebasth
            Sep 12 '17 at 6:03













          • That works !! Please append this in the answer for auto-mount, People will love this.

            – Rahul Sharma
            Sep 12 '17 at 6:11














          1












          1








          1







          CentOS enables SELinux by default, which adds additional security restrictions on the system. Default policy mostly covers the typical/default configurations for confined software. When access is denied, usually a log entry is generated in audit logs in /var/log/audit/audit.log.



          With a removable media you should consider mounting the device with SELinux context option. This way you avoid modifying your system's SELinux policy and the need for filesystem relabeling on the removable device. You can use samba_share_t if you only intend to make the mount point to be used with samba. If you use/label user_home_t type, the files will be treated as if they were in user home directory.



          mount -t ext4 /dev/sdb /mnt/ELEMENTERY-1TB 
          -o context="system_u:object_r:samba_share_t:s0"


          Or in /etc/fstab



          UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1


          If you still have issues with SELinux,
          you can use audit2why to find out why access was denied, and possibly if a SELinux boolean exists to allow access. In case you need to alter SELinux policy, you can use audit2allow to generate a policy module to allow access.



          There are also two booleans samba_export_all_ro and samba_export_all_rw when enabled allow samba to access (and share) any files. In this case this allows samba significantly more access than required and therefore should not be used in this situation as mount options can be configured easily.






          share|improve this answer















          CentOS enables SELinux by default, which adds additional security restrictions on the system. Default policy mostly covers the typical/default configurations for confined software. When access is denied, usually a log entry is generated in audit logs in /var/log/audit/audit.log.



          With a removable media you should consider mounting the device with SELinux context option. This way you avoid modifying your system's SELinux policy and the need for filesystem relabeling on the removable device. You can use samba_share_t if you only intend to make the mount point to be used with samba. If you use/label user_home_t type, the files will be treated as if they were in user home directory.



          mount -t ext4 /dev/sdb /mnt/ELEMENTERY-1TB 
          -o context="system_u:object_r:samba_share_t:s0"


          Or in /etc/fstab



          UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1


          If you still have issues with SELinux,
          you can use audit2why to find out why access was denied, and possibly if a SELinux boolean exists to allow access. In case you need to alter SELinux policy, you can use audit2allow to generate a policy module to allow access.



          There are also two booleans samba_export_all_ro and samba_export_all_rw when enabled allow samba to access (and share) any files. In this case this allows samba significantly more access than required and therefore should not be used in this situation as mount options can be configured easily.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 4 mins ago

























          answered Sep 11 '17 at 19:49









          sebasthsebasth

          8,28632046




          8,28632046













          • Dude, Dude Dude, Thankyou !!!

            – Rahul Sharma
            Sep 12 '17 at 5:25











          • Can i use this statement in fstab ? UUID=a6339f33-1c61-4c2c-a490-04c83ccfb4d6 /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro 0 1 -o context="system_u:object_r:samba_share_t:s0"

            – Rahul Sharma
            Sep 12 '17 at 5:53













          • add the context option with the other options: UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1

            – sebasth
            Sep 12 '17 at 6:03













          • That works !! Please append this in the answer for auto-mount, People will love this.

            – Rahul Sharma
            Sep 12 '17 at 6:11



















          • Dude, Dude Dude, Thankyou !!!

            – Rahul Sharma
            Sep 12 '17 at 5:25











          • Can i use this statement in fstab ? UUID=a6339f33-1c61-4c2c-a490-04c83ccfb4d6 /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro 0 1 -o context="system_u:object_r:samba_share_t:s0"

            – Rahul Sharma
            Sep 12 '17 at 5:53













          • add the context option with the other options: UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1

            – sebasth
            Sep 12 '17 at 6:03













          • That works !! Please append this in the answer for auto-mount, People will love this.

            – Rahul Sharma
            Sep 12 '17 at 6:11

















          Dude, Dude Dude, Thankyou !!!

          – Rahul Sharma
          Sep 12 '17 at 5:25





          Dude, Dude Dude, Thankyou !!!

          – Rahul Sharma
          Sep 12 '17 at 5:25













          Can i use this statement in fstab ? UUID=a6339f33-1c61-4c2c-a490-04c83ccfb4d6 /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro 0 1 -o context="system_u:object_r:samba_share_t:s0"

          – Rahul Sharma
          Sep 12 '17 at 5:53







          Can i use this statement in fstab ? UUID=a6339f33-1c61-4c2c-a490-04c83ccfb4d6 /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro 0 1 -o context="system_u:object_r:samba_share_t:s0"

          – Rahul Sharma
          Sep 12 '17 at 5:53















          add the context option with the other options: UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1

          – sebasth
          Sep 12 '17 at 6:03







          add the context option with the other options: UUID=<...> /mnt/ELEMENTERY-1TB/ ext4 defaults,errors=remount-ro,context="system_u:object_r:samba_share_t:s0" 0 1

          – sebasth
          Sep 12 '17 at 6:03















          That works !! Please append this in the answer for auto-mount, People will love this.

          – Rahul Sharma
          Sep 12 '17 at 6:11





          That works !! Please append this in the answer for auto-mount, People will love this.

          – Rahul Sharma
          Sep 12 '17 at 6:11


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f391673%2fsharing-a-mounted-drive-with-samba-on-centos7%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Accessing regular linux commands in Huawei's Dopra Linux

          Can't connect RFCOMM socket: Host is down

          Kernel panic - not syncing: Fatal Exception in Interrupt