User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

USB Flash Drive Root Ownership Can't Be Changed

Mon May 14, 2012 12:50 am

I'm used to building and administering *n*x systems with root permission and I'm running into trouble with the default permissions in the Pi Debian release when accessing a USB flash drive. The drive is owned by root after a sudo mount, which is understandable, but, I can't create any directories or files without using sudo, and even when I do that, I can't later change ownership, group, or mode permissions of any directories or files created on the USB drive either via sudo or directly as root (after having created a root password). I know that some Debian/Ubuntu releases have ACL control (e.g., getfacl, setfacl), but, it's not installed in the Pi Debian release.

Maybe staying up late the last couple of nights playing with the Pi has dulled my senses and I'm just overlooking something obvious, but, this one has me stumped and any help reminding me of what may be staring me right in the face would be greatly appreciated.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: USB Flash Drive Root Ownership Can't Be Changed

Mon May 14, 2012 1:25 am

Sounds like your USB disk is FAT32 or NTFS formatted, neither of which support *nix permissions system. You should be able to set the owner at mount time by passing the 'uid=user' option setting the user you want to own the files. You could also set 'umask=000' to set all files in the filesystem to rwxrwxrwx.

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: USB Flash Drive Root Ownership Can't Be Changed

Mon May 14, 2012 2:41 am

error404 wrote:Sounds like your USB disk is FAT32 or NTFS formatted, neither of which support *nix permissions system. You should be able to set the owner at mount time by passing the 'uid=user' option setting the user you want to own the files. You could also set 'umask=000' to set all files in the filesystem to rwxrwxrwx.
DOH! I knew it was something obvious. In the haze of the late night sessions I had split the USB flash drive into two equal-sized partitions, one FAT32 and the other ext4, just in case I plugged it into a system that couldn't recognize one or the other filesystem, since its purpose is for transferring files to/from the Pi until I get wireless networking up and running (no wired network as I'm on-the-road beyond Timbuktu). Sure enough, the FAT32 partition is the one that's being annoying, and the ext4 partition is behaving as expected.

sudo mount -o uid=pi,gid=pi /dev/sda1 /mnt/usb_flash_1

resulted in mounting the FAT32 partition with ownership/group as pi.

Since this doesn't appear to be in the wiki, yet, I'll go ahead and do a mini tutorial on this for the even newbier Pi users who aren't even aware of permissions.

This community rocks - THANKS! :)
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

User avatar
east
Posts: 1
Joined: Fri Oct 11, 2013 3:35 pm

Re: USB Flash Drive Root Ownership Can't Be Changed

Wed Oct 16, 2013 12:39 pm

Thank god for this post.

I was tearing my hair out trying to add files to a FAT32 USB but after reformatting it to ext4 my sftp client (WinSCP) now shows the permissions and the user.of the USB in the remote panel.
Attachments
clip.jpg
clip.jpg (46.09 KiB) Viewed 4788 times

Return to “Troubleshooting”