How to mount PiDrive on your Raspberry pi?

So, you bought a PiDrive from WD Labs and you want to mount it to yours Raspberry Pi? So, this tutorial might help. Note: I'm using my Raspberry Pi 3 and ordered PiDrive from NextCloud Box. And I will be using entire PiDrive as a one giant partition instead of partitioning it into several partitions.

Follow these steps:
- Connect your PiDrive to Raspberry, boot your Raspberry. Then find where your Raspberry Pi is mounted:
$ sudo fdisk -l
<... Lots of input here ...>
Disk /dev/sda: 931.5 GiB, 1000170586112 bytes, 1953458176 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


So, our Raspberry lives on /dev/sda. Good.

- Format this partition by using ext4:
$ sudo mkfs.ext4 /dev/sda1 -L "PiDrive"

- Mount partition to your system to /mnt/data
$ sudo mkdir /mnt/data
$ sudo mount -t ext4 -o "noatime" /dev/sda /mnt/data

 
- You need to setup correct user permissions on your mounted drive. First of all, find your UID/GID:
$ id
uid=1000(pi) gid=1000(pi) groups=1000(pi),4(adm),20(dialout),24(cdrom),27(sudo),29(audio)

So, in my case, UID/GID are 1000/1000.

Set permissions on drive:
$ sudo chown -R 1000:1000 /mnt/data
$ sudo chmod -R 775 /mnt/data


And you're done!

But you might want to permanently mount our PiDrive. So, you need to edit /etc/fstab file to do this.

- Find UUID of your drive:
$ sudo blkid
/dev/mmcblk0: PTUUID="6f92008e" PTTYPE="dos"
/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="947B-B89A" TYPE="vfat" PARTUUID="6f92008e-01"
/dev/mmcblk0p2: UUID="eda95d8a-9cdd-4224-96d0-890b4791600c" TYPE="ext4" PARTUUID="6f92008e-02"
/dev/sda: LABEL="PiDrive" UUID="0562789e-5f04-44c6-b36e-c64bb4e340bf" TYPE="ext4"


So, in my case UUID is 0562789e-5f04-44c6-b36e-c64bb4e340bf.

- Edit /etc/fstab and add the following entry:
$ sudo nano /etc/fstab
/dev/disk/by-uuid/0562789e-5f04-44c6-b36e-c64bb4e340bf /mnt/data ext4 defaults,noatime,nofail 0 0


Now you're finally done :)

Komentuoti