[solved] Automount and "autoshare" partition on a USB drive

  • Hello,


    i would like to use an external usb drive with a NTFS partition on it as share (and samba share). That works like a charm while mounting the partition with the web ui and create the share via web ui.


    But i like to have it automounted and "autoshared" without accesing the shell or the webui and want it identified by UUID as device names can change. After searching the forum i consider to create a Udev-Rule, maybe like this (example i found):


    Code
    ACTION=="add", KERNEL=="sd[b-z][0-9]", ENV{ID_FS_UUID}=="a59332c2-07ba-4c52-afb5-20e361bdf71a",SYMLINK+="usb-%n", GROUP="storage", NAME="%k"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", ENV{ID_FS_UUID}=="a59332c2-07ba-4c52-afb5-20e361bdf71a",RUN+="/bin/mkdir -p /symbiosis/utopia"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", ENV{ID_FS_UUID}=="a59332c2-07ba-4c52-afb5-20e361bdf71a", RUN+="/bin/mount -t auto -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /symbiosis/utopia", OPTIONS="last_rule"
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", ENV{ID_FS_UUID}=="a59332c2-07ba-4c52-afb5-20e361bdf71a", RUN+="/bin/umount -l /symbiosis/utopia", OPTIONS="last_rule"


    My Question:
    How can i "autoshare" the partition on the usb drive? I read this [Solved] Adding Share Folder from USB Stick and understand, that it'll maybe impossible. Thats right? Maybe i can configure a samba share manually in the smb.conf to achieve the goal? Or is there another way?


    Thank you for reading.
    -aeronaut

    • Offizieller Beitrag

    The easiest way (didn't try tho) I can think of to do this would be to symlink the the usb mount point to an already existing smb share location. Then remove the symlink when removing. To create mntent entry, create a shared folder, create a smb mount point and then undo that would be a lot of work.

    omv 7.0.5-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.13 | compose 7.1.4 | k8s 7.1.0-3 | cputemp 7.0.1 | mergerfs 7.0.4


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • I cant figure out how to set permissions/ownership on the symlink to access the linked directory within samba.


    The samba share with symlink:

    Code
    lrwxrwxrwx 1 root users 11 Jun 15 13:23 automount -> /automount/
    drwxrwxrwx 21 500 users 4096 Aug 8 2014 Camcorder


    Target:

    Code
    ls -al /automount
    drwxrwxrwx 2 500 root 4096 Jun 15 13:20 .
    drwxr-xr-x 25 root root 4096 Jun 15 13:20 ..


    On a windows machine, it says 'no right' upon access the automount folder.


    I tried to get Samba to follow symlink as following (not changing anything):

    Code
    [global]
    unix extensions = no
    
    
    [share]
    follow symlinks = yes
    wide links = yes


    Any suggestions welcome-
    -aeronaut

  • As i cannot figure out how to get it autoshared with symlinks, i tried annother approach: Manually edit the smb.conf to share the mount point of the usb drive, which is mounted via automount.


    That works, but the smb.conf gets overwritten with webui-configuration on rebooting.


    Guess i need a possibility to have a "protected" part in smb.conf, maybe marked with annotation, that won't get overwritten.


    Or a complete else approach. Can't imagine i'm the only one with the autoshare removeable devices requirement.


    Thank you for any hints or advices.


    -aeronaut

    • Offizieller Beitrag

    Create a file like this:


    nano /usr/share/openmediavault/mkconf/samba.d/21autousb



    ctrl-o to save
    ctrl-x to exit


    chmod +x /usr/share/openmediavault/mkconf/samba.d/21autousb
    omv-mkconf samba to make new samba config.

    omv 7.0.5-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.13 | compose 7.1.4 | k8s 7.1.0-3 | cputemp 7.0.1 | mergerfs 7.0.4


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    Einmal editiert, zuletzt von ryecoaaron ()

  • That gives me the option to be consistent with manually declared shares - great!


    Thanks, ryecoaaron.


    For the sake of completeness:

    Code
    chmod +x /usr/share/openmediavault/mkconf/samba.d/21autousb


    regards
    -aeronaut

    • Offizieller Beitrag

    Edited my post. Glad it worked.

    omv 7.0.5-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.13 | compose 7.1.4 | k8s 7.1.0-3 | cputemp 7.0.1 | mergerfs 7.0.4


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!