1

Hi I'm trying to access files on an external hard drive connected to my Raspberry Pi 3 running Raspbian in order to put them up for sharing on a flask server.

I can't find a way to access files stored on the drive. I'd be grateful if anyone could tell me how external storage paths work in Raspbian as all the other questions like this one only worked for Windows or OS X.

1
  • Did you mount your disk as shown in this link. So, this basically mounts the externally connected drive as a disk and then it can be accessed by specifying the directory path in python Aug 5, 2020 at 17:13

2 Answers 2

1

Path is like this: /media/username/hard_drive/

You can access using above path or using os you can change your directory once like below.

import os
os.chdir("path/to/hard/drive")
1

You can access files by simply specifying the full/absolute path in python. External drives appear as part of the file system in Linux.

To find out where your drive is mounted run lsblk to list all block devices. You will get output in the shape of:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:16   1  14.3G  0 disk 
├─sda1   8:17   1   256M  0 part /boot
└─sda2   8:18   1  14.1G  0 part /
sdb      8:0    1 114.6G  0 disk 
└─sdb1   8:1    1 114.6G  0 part /media/<username>/<disk id>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.