Suppose that I have only non-root access on a desktop Linux machine.

I want to work with an external, pluggable storage device (hdd, flash drive or memory card) with an ext{2,3,4} file system.

Since I have physical control over the storage device, it seems that I should be able to do whatever I want with it, regardless of my privileges on the current system.

I can mount it using pmount. But how do I access files that have such permissions that I wouldn't be able to access them if they were on a local file system? (For example, files owned by root with permissions 0600)

  • Anything that lets you do this on an external drive will also allow you to do the same thing on any drive, because there is no inherent difference between internal and external storage. Sounds like a bad idea to enable that.
    – user
    Feb 6 '13 at 10:40
  • As many things in Unix, it's a matter of policy. The sysadmin should be able to define such a policy (e.g.: treat these particular filesystems as local, everything else as external). Feb 6 '13 at 10:51
  • He can. That's the point of fstab and udev.
    – user21228
    Feb 6 '13 at 12:11

Whilst you may think you can do what you want, you are still limited by the current system's definition of user permissions. You have physical access to the computer, it doesn't mean you can do what you want through the operating system, you have to do it some other way. The operating system will simply not allow you to do this without the appropriate permissions.

  • But there's no inherent reason for the OS to conflate its own permissions (including permissions on the local file systems) with permissions on the external drive. Feb 6 '13 at 10:14
  • @RomanCheplyaka I don't see why you would expect anything different for an external filesystem.
    – Chris Down
    Feb 6 '13 at 11:30

Yes, if you aren't accessing the filesystem from the system its permissions were designed for, the permissions are purely indicative.

However, this is a somewhat uncommon case, so typical tools aren't set up for that. Usually, if you want to access some external media, the simplest way is to mount it and browse it as the root user.

If all you have is pmount and no root access, then the partitions are binding for you. This is only relevant for security in rare scenarios (e.g. permanently-connected but not permanently-mounted backup drive that you have no physical access to).

If you have access to the raw device, you can use a FUSE filesystem (if available). Alternatively, you can try accessing the device from a virtual machine; for example, you may be allowed to use VirtualBox with USB device forwarding (let the guest, with an OS that you control, handle that USB device).

If you have root access but would prefer to browse as an unprivileged user, mount the filesystem normally, then apply a permission translation filesystem layer. Bindfs can do this:

bindfs --perms=a+rX:a-w /media/sdz99 ~roman/mnt/myview
  • Thanks. Bindfs looks very relevant, although, as you say, it requires root (because it works with already mounted file systems, not raw devices). Are there FUSE file systems that can work with devices and can alter permissions? Feb 7 '13 at 6:04
  • As I previously said... root... BTW, "if you aren't accessing the filesystem from the system its permissions were designed for, the permissions are purely indicative" doesn't mean anything. Permissions are set filesystem-wise but the one who enforces it is always the OS, not the disk itself. Therefore, there is not "indicative" permission, there is no "My OS name and uniq ID"-flag in the filesystem that the OS could use to determine if the permissions were "designed" for it (this would be a serious security flaw). FUSE mounts with user privilege, not root privilege.
    – user21228
    Feb 7 '13 at 9:49
  • @RomanCheplyaka IIRC there's a FUSE filesystem for ext2 but it hasn't been maintained in a while, it doesn't support ext3 or ext4 (it can read ext3, I guess). You still need to have access to the raw device. In that case a VM where you're root is often the most convenient way. Feb 7 '13 at 11:15

(Avoiding covering what the others have said...)

Can you start a container or virtual machine using the external disk? In that case, you could potentially have root on the VM/CT even if you don't on the host.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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