Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a 4GB USB stick which I partitioned using sudo cfdisk /dev/sdb and formatted using sudo mkfs /dev/sdb1. It's currently set to ID 83 with System Linux when I run sudo fdisk -l on my Debian Squeeze.

I use pmount to mount the external USB drives. So doing a pmount /dev/sdb1 mounts it to /media/usb0 because I have the ff. line in /etc/fstab:

/dev/sdb1    /media/usb0    auto    rw,user,noauto    0    0

After issuing the pmount command, the USB is mounted to /media/usb0 -- doing an ls -l /media/usb0 gives me:

drwx------ 2 root root 16384 Mar   2 20:08 lost+found

So I go about my business and try to copy a file to /media/usb0 but I get the error below:

$ cp ~/ /media/usb0
cp: cannot create regular file `/media/usb0/': Permission denied

But when I issue the same cp command with sudo, I am able to copy the file.

Why does this happen? I tried other USB drive I have and I am able to write to them without this error. Was there something wrong with the way I formatted or repartitioned the USB stick?

share|improve this question
up vote 4 down vote accepted

You formatted the sdb1 partition using an ext* file system (either ext2, ext3, or ext4; I cannot recall the default). This is the default file system on Linux systems, and uses Unix file permissions to determine who can modify files or directories. Fresh filesystems always start off with the root (/media/usb0 in this case) being owned by root:root, and usually with permissions only allowing modification by the owner.

To see this for yoruself, mount the filesystem, then run ls -ld /media/usb0 to see the current ownership/perms. My guess is:

drwx------ 2 root root 16384 Mar   2 20:08 /media/usb0

A simple fix would be to a) chown the mounted file system to your own Linux account, or b) to give everyone write permission with chmod.

However, in the end, this wouldn't be a good solution, since the files created would become owned by your UID, not the username; this would quickly result in account mismatches when the USB drive is connected to a different system. Assuming you can connect it at all, that is – Windows does not support ext3 without extra trickery, so NTFS (mkfs.ntfs) or FAT32 (mkfs.vfat) would be a much better choice for the file system.

share|improve this answer
I tried doing sudo mkfs.ntfs /dev/sdb1 and sudo mkfs.vfat /dev/sdb1 but I get the error sudo: mkfs.xxxx: command not found where xxxx is either ntfs and vfat. How do I get that to work on Debian Squeeze? – Eric Mar 2 '12 at 13:09
@Eric: Install ntfs-3g + ntfsprogs + dosfstools. – grawity Mar 2 '12 at 13:18
Ok, I installed that. Now when I try to mount, I get this error: ntfs-3g-mount: failed to open /dev/fuse: Permission denied. What do I do about this? – Eric Mar 2 '12 at 14:11

This happens on later Debian systems (e.g. jessie) as well with certain fat32 or ext3,4 formatted USB flash drives. You need to remove (or comment out) the following line from your /etc/fstab:

/dev/sdb1    /media/usb0    auto    rw,user,noauto    0    0

After this you'll have your USB drive mounted automatically under your regular user account's permission and not root. See detailed info on Debian forums on this link.

After that your USB drive will mount smoothly with your user write permission :)

share|improve this answer
Thanks, that did the trick. (Debian Jessie + KDE) – cete3 Apr 6 '15 at 21:11

Use sudo and change permissions with chmod command.

See my answer in that question to see how to use chmod:

I suggest you to use chmod 777 to allow all (using ls -l it will show drwxrwxrwx).

share|improve this answer

If your filesystem is FAT16 or FAT32 you have to use this command:

sudo mount -t vfat /dev/sdb1 /media/usb0 -o uid=1000,gid=1000,utf8,dmask=027,fmask=137

For more info visit the link

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .