Connect WD PiDrive with Raspberry Pi 3

Hi,

I’ve bought the WD PiDrive 314 GB and I’m not sure how to connect. My Raspberry Pi is working properly with the adapter. I attach the WD PiDrive to a USB port, but I don’t see the drive in the media folder on my RaspberryPi. It is not mounted. The reaspberryPi is working under Jessie (the latest version). I want to use the harddrive for storing movies. It’s not supposed to store the operating system for the RaspberryPi. That’s stored on the sd card. What do I miss?

Thank you very much for your help.

Yvonne

The drive needs to be partitioned and formatted before it can be used. Probably the best tool for doing that is gparted (sudo apt-get install gparted).

When you partition and format it, make sure you have /dev/sda selected and not mmcblk0! The latter is your SD card.

Thank you Bob. i will try this and when done I give you a reply.

yvonne

Dear Bob,

Sorry for the delay in answering. The external drive is not recognized by the system.
I bought the special cable set, but nevertheless the hrd drive is not mounted.
Do you have any other suggestion?

Thank you.

Kind regards,

Yvonne

The drive will not be automounted until it’s been prepared properly. The drive comes completely blank, or at least my PiDrive did. If you were using WD’s modified version of NOOBS, it would handle it for you automatically but that’s not what you want. So you have to prepare the drive yourself.

Did gparted list the drive in its dropdown menu of attached drives?

What do you get if you open a terminal and type “lsblk”?

Dear Bob,

Yes, I succeeded! My WD drive is formatted (fat32).
In the terminal after lsblk it’s listed.
My next question is where can I see the disk in the directory structure (in the explorer).
Media/pi/B307-443F is that the place to be? I can’t rename this folder in something like Plexmedia.
I want to place my videofiles inside this folder. I want to use this Raspi as a plex server.
Thank you so much for your help.

Kind regards,

Yvonne

Excellent! Sounds like it’s working.

By default it would indeed be mounted at /media/pi/some-unique-identifier.

I’m unfamiliar with Plex and how it’s configured, or its requirements as to paths and such.

The /media directory is actually for removable media such as CDROMs and USB sticks. It should still work, but if it were my system I’d create a directory such as /opt/plex/videos or some such and create an entry in /etc/fstab to mount the drive there. Personally I’d also reformat the drive as ext4 instead of fat32.

Anyway, progress is being made. Very good!

Dear Bob,
I’m not sure if I understand the mounting procedure in /etc/fstab.
I created a directory /opt/plex/videos on the raspberry pi sdcard.
I suppose I must make some kind of reference to the external harddrive in fstab.
I think I must write a line of code something like:
UUID=f0C81fb5-BEF0-40EB-67854-055afd /opt/plex/videos
How can I put my videos on the harddisk?
Thank you so much for your help and patience.

Yvonne

Hi Yvonne,
The file /etc/fstab is basically a list that maps physical block devices (hard drives) to locations in the filesystem. There are four entries on each line. The first is the device, and will be something like /dev/mmcblk0p1 or /dev/sda1. Drives can also be identified by a “Universal Unique IDentifier”, or UUID in which case the first field is something like UUID=f0C81fb5-BEF0-40EB-67854-055afd; using UUIDs is better for reasons I won’t go into right now but will explain if you’re curious; there’s some interesting history behind it.

The second field is a directory somewhere in the filesystem; with some restrictions it can be anywhere. This is the “mount point” where the device will be visible to the software.

The third field is the type of filesystem on the device, and will most likely be ext4 for a native linux partition, or vfat for a Windows type partition; there are a large number of possible types but those are the two most common especially on our Raspberry Pis.

The fourth field is mount option flags, usually “defaults” for the default options.

The fifth field is used by the “dump” command; none of my systems (Raspbian, Linux Mint and Slackware) even have a “dump” command. Best to set it to 0. The sixth field is the order in which filesystems should be checked via fsck at boot time; 0 means don’t check.

So a “typical” Raspi fstab might look like this:

/dev/mmcblk0p5 /boot vfat defaults 0 2
/dev/mmcblk0p6 / ext4 defaults,noatime 0 1

This means that /dev/mmcblk0p6 will be mounted at the root of the filesystem; “/”, while /dev/mmcblk0p5 will be mounted on the “/boot” directory.

Anyway, yes, you’d want a line such as:
UUID=f0C81fb5-BEF0-40EB-67854-055afd /opt/plex/videos ext4 defaults 0 0

After modifying /etc/fstab, you can reboot for it to take effect, or simply type “sudo mount -a”.

After the drive is mounted, you can copy files to /opt/plex/videos and they will be placed on the pidrive even though the directory appears to exist on the SD card. Well the directory itself is in fact on the SD card, but its contents are on the hard drive.

You can see this by doing this:
Copy a few files to /opt/plex/videos (they can be anything, don’t have to be videos for the purposes of the test).
Verify they’re there by listing the directory: ls -l /opt/plex/videos
Now type “sudo umount /opt/plex/videos” (note it’s umount, not mount) to unmount the drive.
List the directory again, you’ll see it’s empty.
Type “sudo mount /opt/plex/videos”, list the directory avgain, and you’ll see the files have returned.

You might want to open a terminal and type “man fstab” for more information on the fstab file. “man mount” will also have some good information on the subject.

If you have any questions I’d be happy to try to explain.

-Bob

Dear Bob,

Thank you so much for your great answer.
I edited the fstad like this:

#Original 3 lines of code
proc /proc proc defaults 0 0
/dev/mmcblk0p6 /boot vfat defaults 0 2
/dev/mmcblk0p7 / ext4 defaults,noatime 0 1

#I added the next line of code is that correct?
/dev/f0c81fb5-bef0-40eb-8985-055afdd7e930 / ext4 defaults, noatime 0 3
#or must it be:
/dev/sda1 / ext4 defaults, noatime 0 3
UUID=f0c81fb5-bef0-40eb-8985-055afdd7e930 /opt/plex/videos

Somewhere there must be the link to /opt/plex/videos, but I don’t know if I must write 2 lines of code?

Thanks again for your help

Yvonne

Close, but not quite. You want to add one line, and it would be this:
UUID=f0c81fb5-bef0-40eb-8985-055afdd7e930 /opt/plex/videos ext4 defaults

this line:
/dev/sda1 / ext4 defaults, noatime 0 3
won’t work in your case because it’s trying to mount /dev/sda1 at the root directory "/ " which already has /dev/mmcblk0p7 mounted there. Besides which, there’s no OS on the new drive so you wouldn’t want it mounted at / anyway.

Actually, instead of the line
UUID=f0c81fb5-bef0-40eb-8985-055afdd7e930 /opt/plex/videos ext4 defaults
that I gave you above, you could use instead
/dev/sda1 /opt/plex/videos ext4 defaults
since you can refer to the drive by either its “device file” in /dev/ or by its UUID.

but you don’t want to use both lines, has to be one or the other!

Let me know how this works.

-Bob

Dear Bob,

I think I made it!!! Or better you made it.
I had to use /dev/sda1 /opt/plex/videos ext4 defaults instead of the unique identifier.
I will now try to use it as the directory for the plex server.
Bob, thank you very very much for your help and patience.
Without you I wouldn’t have succeeded.
I have a last question. The harddrive is no longer in the upper right corner of the menu to eject it safely. Is this because the drive is mounted by code in fstab?
Many regards,

Yvonne

Hi Yvonne,

Super! Glad it works!

Not sure why the UUID didn’t work, most likely because there was a typo involved somewhere. Be that as it may, using /dev/sda1 will certainly work. Should you add a second hard drive in the future then it may, possibly, not work; under certain somewhat unusual circumstances the system may be confused as to which drive is which and in fact is why the UUID system was devised.

You are correct about why you no longer have a “safely eject” option. I’m assuming it’s not really set up as a removeable drive, is that correct.

Should you with to remove/eject it for whatever reason, you’ll have to use a command line. Either of these should work:
sudo umount /dev/sda1
or
sudo umount /opt/plex/videos

To re-mount it, one of these commands will do it:
sudo mount /dev/sda1
or
sudo mount /opt/plex/videos

You can refer to either the device itself (/dev/sda1) or the mount point (/opt/plex/videos) since there’s no ambiguity.

Best of luck!
-Bob

Thanks Bob and Yvonne - great discussion with lots of good information!