Azsorlex26
Posts: 16
Joined: Sat Feb 10, 2018 8:41 am
Location: Australia

Unable to view USB on the command line

Sat Feb 17, 2018 10:53 pm

Hello there. So, I have a "simple" problem that I for the life of me cannot figure out. As the title explains, I can't access my usb drive through the command line, whether that be through SSH or the pi itself. However, as soon as I go into the desktop environment (either through VNC or the pi itself), I can access my drive; I can even view it on the command line as long as I don't reboot the system.

Whenever I type ls /media/pi/A_ROZSA, the CL returns: ls: cannot open directory '/media/pi/A_ROZSA': Permission denied. I've tried doing my research on how to fix this, however the people always talk about it as if you're supposed to know the solution as soon as you purchase your pi. Please explain the solution step-by-step to me; I'm still an amateur to Raspbian. Looking forward to your responses!

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Unable to view USB on the command line

Sat Feb 17, 2018 11:41 pm

What you're seeing is the default behaviour. With the desktop running there is a background process that detects and mounts any inserted drives. In the command line this isn't running so you have to perform the mount yourself.

Assuming your USB drive is appearing as /dev/sda with a partition at /dev/sda1 the quick and dirty fix is:

Code: Select all

sudo mount /dev/sda1 /mnt
and

Code: Select all

sudo umount /mnt
before you unpug it.

However that might not give you the permissions on the drive that you want. How you get those depends on a number of factors including how the drive has been formatted (FAT, NTFS, ext4, etc). Nor will it mount it in /media/...

Read up on "mount", "fstab", and optionally systemd mounts.

The last two posts in this thread mayalso be of use: viewtopic.php?f=28&t=205016&sid=3fa4344 ... a658f8078d
This space unintentionally left blank.

Azsorlex26
Posts: 16
Joined: Sat Feb 10, 2018 8:41 am
Location: Australia

Re: Unable to view USB on the command line

Sun Feb 18, 2018 1:58 am

Thanks for your input :D

I tried what you gave me and it worked! At first I thought it didn't work because I forgot that the directory was changed :oops:, but I got it working. Thanks for your help! It was much appreciated :D

Return to “Troubleshooting”