Partitioning [SOLVED]: www-data User cannot access mounted partition

Partitioning [SOLVED]: www-data User cannot access mounted partition

Home Forums Partitioning Partitioning [SOLVED]: www-data User cannot access mounted partition

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #36571



    On my local dev machine my nginx server runs as user www-data. I have a separate 3TB HDD which stores my local websites. The HDD is mounted automatically on Ubuntu 16.04 startup. I can access my files properly with my own user, but when I su www-data and try to access the files that way I get a permissions error when accessing anything mounted in the /media/ folder.

    How can I allow www-data to access this hard drive?

    Details: BLKID (last HDD)

    sudo blkid
    /dev/sda1: UUID="BB84-E577" TYPE="vfat" PARTUUID="d62d7f99-f050-4411-8e57-0030bbd73635"
    /dev/sda2: UUID="aba7016b-3277-416b-9243-fc10f1752b12" TYPE="ext2" PARTUUID="d567afcf-1f63-4f53-a8a9-d61c619f9493"
    /dev/sda3: UUID="r3Gnc3-zpe7-m81D-dBde-ShtM-6z0j-FZhaIG" TYPE="LVM2_member" PARTUUID="d4ffe4c2-0c4e-45bd-83fe-3d12d5b4a74b"
    /dev/sdb1: PARTLABEL="Microsoft reserved partition" PARTUUID="ff6c7bf2-9ffa-4d27-aebd-8f4f9569b985"
    /dev/mapper/ubuntu--vg-root: UUID="fd4ff318-8e5c-489e-a17c-08a6c02f7919" TYPE="ext4"
    /dev/mapper/ubuntu--vg-swap_1: UUID="86e3d28e-3c13-4e5d-a8c1-ad56778355e7" TYPE="swap"
    /dev/sdb2: LABEL="data" UUID="53c5e897-b414-4faf-892c-ffd415f4d451" TYPE="ext4" PARTLABEL="Basic data partition" PARTUUID="30eff523-5ebc-46f5-9051-2e6604cb772d"

    Details: FSTAB

    /dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro 0       1
    # /boot was on /dev/sda2 during installation
    UUID=aba7016b-3277-416b-9243-fc10f1752b12 /boot           ext2    defaults        0       2
    # /boot/efi was on /dev/sda1 during installation
    UUID=BB84-E577  /boot/efi       vfat    umask=0077      0       1
    /dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0
    /dev/disk/by-uuid/53c5e897-b414-4faf-892c-ffd415f4d451 /media/steven/data auto nosuid,nodev,nofail 0 0



    Accepted AnswerAnswer

    Two things I would suggest:

    1. Find which group owns that device:

      ls -ald /dev/sdX
      • where X is the letter representing the external drive usually /dev/sdb, or /dev/sdc
    2. Add www-data user to that group:

      sudo usermod -a -G disk www-data

    And now user www-data should be able to access that external HDD.

    Author: George Udosen
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.