Mounting an external drive using UUID and fstab | Linux admin junior

Create a mountpoint for the external drive for ncdata

sudo mkdir /media/ncp

Find UUID of external drive

ls -lh /dev/disk/by-uuid/

(Mine looks like this)
total 0
lrwxrwxrwx 1 root root 15 Aug 11 09:10 29075e46-f0d4-44e2-a9e7-55ac02d6e6cc -> …/…/mmcblk0p2
lrwxrwxrwx 1 root root 10 Aug 11 09:10 35e98a80-8895-41f4-93e7-39940a1fda70 -> …/…/sda1
lrwxrwxrwx 1 root root 15 Aug 11 09:10 9304-D9FD -> …/…/mmcblk0p1

To add a ligne to /etc/fstab

sudo nano /etc/fstab

add line for your drive (copy/paste your drive’s UUID):

UUID=YourDrive’sUUID /media/ncp ext4 rw,users 0 0
or if using btrfs
UUID=YourDrive’sUUID /media/ncp btrfs rw,users 0 0

mount the drive

sudo mount -a

Verify drive is mounted:

df -h

Create folder for ncdata

sudo mkdir /media/ncp/ncdata
sudo chown www-data:www-data /media/ncp/ncdata

Or when using btrfs

sudo btrfs subvolume create /media/ncp/ncdata
sudo chown www-data:www-data /media/ncp/ncdata

You can use nc-datadir to move ncdata to the new location.

Or use rsync and manually edit config.php.

2 Likes