Shared Drive

Setting up a Shared Hard Drive

In my home system, I have a second Hard Drive on each of my computers for common storage of projects and files.

I’d like to have this second drive accessible from all the other computers, with all permissions. It’s just a private home network, so I’m not worried about controlling who does what. I want it to be wide open.

Here’s what I do to set it up:

  1. Check the device name for the drive:
    sudo fdisk -l

    We’ll assume for the rest of the examples that the drive is /dev/sda2

  2. Create a permanent folder in /media to mount the drive into:
    sudo mkdir /media/storage
  3. Set the drive to mount at boottime in fstab:
    sudo gedit /etc/fstab
  4. For an EXT4 formatted drive:

    /dev/sda2   /media/storage   ext4   rw,user,exec,noatime   0   0

    For an NTFS formatted drive:

    /dev/sda2   /media/storage   ntfs    users,defaults   0   0

    These next three instructions only apply to EXT formatted drives. If your drive is NTFS format, you can skip them.

  5. Make root of drive writeable:
    sudo chmod +w /media/storage
  6. Give permissions to all users in the root of the drive:
    sudo chmod 777 /media/storage
  7. Set all file/folder permissions (for those already created):
    sudo chmod -R 777 /media/storage/*
    sudo chgrp -R users /media/storage
  8. This last step is a brute-force technique since I still sometimes have problems between Windows and Linux using Samba. This line forces any network access to the drive to be done with the standard Linux user and group.
    sudo gedit /etc/samba/smb.conf

    Put in the following lines (substitute your user/group name, and your path):

    [storage]
    path = /media/storage
    writeable = yes
    browseable = yes
    force user = frank
    force group = frank
    read only = no
    guest ok = yes
    create mask = 0777
    directory mask = 0777
By practic on April 30, 2014 | | A comment?