# Can mount external HD but ls results in Permission Denied

## jtp755

This is a little weird to me but here goes:

I bought a Vantec NexStar 3 yesterday that is IDE to USB. I first put in an 80Gb drive that was my /home dir from my desktop and took all the files off i needed and then i deleted all the partitions on it because i am reinstalling so i can give it to my brother. When i hooked up the drive to my laptop to get the files off it mounted and i could browse absolutely great and transfer files and all. So i unmounted and unhooked it and put in a 120 Gb drive that was my main drive from my desktop and i want to hopefully keep it in the external but when i hook it up to my laptop i can mount it as my user but an ls of /mnt/usb results in a permission denied. If i mount as root i can browse fine as root. its like on this particular drive my user doesnt have permission. I chowned /mnt/usb to root:users while it was unmounted and when it was mounted and no luck. I have tried rebooting. I have also ran fdisk /dev/sdb and deleted the partitions and created a new one and tried mounting again and it didnt work and mounting as root resulted in the files that was on there still being there. I checked in /var/log/messages and there are some errors about the volume being dirty and mounting it in Windows and running chkdsk andi have done that and it didnt find any problems and ran fine. The partiton type is ntfs. What happened with the 120Gb i think is i had tried installing Windows on it for my brother and it kept saying it couldnt copy files and would crap out. Maybe the drive is bad but i hope not. Any ideas?

----------

## opopanax

I'm assuming this is an ntfs drive.  Are you using some sort of automount feature, or are you actually issuing the mount command to get it to /mnt/usb?  Removable media is usually automounted in the /media/ directory, so try accessing it through there, instead.

If this doesn't work, stop trying to reformat your drive!!!  instead, post your /etc/fstab.

----------

## rsa4046

It's a bit confusing understanding what you're trying to do or have done (too much detail). First off, post your /etc/fstab, and indicate briefly what you're trying to do in terms of devices and file systems.

----------

## jtp755

my fstab:

```

# /etc/fstab: static file system information.

#

# noatime turns off atimes for increased performance (atimes normally aren't 

# needed; notail increases performance of ReiserFS (at the expense of storage 

# efficiency).  It's safe to drop the noatime options if you want and to 

# switch between notail / tail freely.

#

# The root filesystem should have a pass number of either 0 or 1.

# All other filesystems should have a pass number of 0 or greater than 1.

#

# See the manpage fstab(5) for more information.

#

# <fs>         <mountpoint>   <type>      <opts>      <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.

/dev/sda1      /boot      ext2      noauto,noatime   1 2

/dev/sda3      /      ext3      noatime      0 1

/dev/sda2      none      swap      sw      0 0

/dev/sda5               /usr            ext3            noatime         0 2

/dev/sda6               /usr/portage    reiserfs        notail,noatime  0 2

/dev/sda7               /var            ext3            noatime         0 2

/dev/sda8               /opt            ext3            noatime         0 2

/dev/sda9               /home           ext3            noatime         0 2

/dev/sdb1      /mnt/usbstick   auto      users,noauto   0 0

/dev/mmcblk0p1      /mnt/mmc-card   auto      users,noauto   0 0

/dev/dvdrw      /mnt/dvdrw   iso9660      users,ro,noauto,unhide   0 0

#/dev/fd0      /mnt/floppy   auto      noauto      0 0

# NOTE: The next line is critical for boot!

proc         /proc      proc      defaults   0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for 

# POSIX shared memory (shm_open, shm_unlink).

# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will

#  use almost no memory if not populated with files)

shm         /dev/shm   tmpfs      nodev,nosuid,noexec   0 0

```

i have been using either manually issuing the mount command or using ROX-Filer and going to the /mnt/usb dir and it auto mounts according to /etc/fstab i assume.

Briefly i am trying to get this 120Gb drive working in the external enclosure with an ntfs or win95 fat32 lba partition on it so i can transfer files between computers here and at work. What was weird is that i had an 80Gb drive in the enclosure last night and it worked perfectly fine.

i have 4 usb sticks that are fat32 lba and to open them i plug them in a in rox-filer i go to /mnt/usb and they mount and open.

----------

## rsa4046

 *jtp755 wrote:*   

> i have been using either manually issuing the mount command or using ROX-Filer and going to the /mnt/usb dir and it auto mounts according to /etc/fstab i assume.
> 
> Briefly i am trying to get this 120Gb drive working in the external enclosure with an ntfs partition on it so i can transfer files between computers here and at work. What was weird is that i had an 80Gb drive in the enclosure last night and it worked perfectly fine.

 Your /etc/fstab contains no provision to mount the device, right? (I'm assuming the drive is not /dev/sdb1). So assuming the ntfs on this usb drive's partition is in working order, and that /mnt/ntfs exists as the mount point, what happens when you issue:

```
# fdisk -l
```

and, using the partition reported above as HPFS/NTFS,

```

# mount -t ntfs <this partition> /mnt/ntfs
```

----------

## jtp755

when referring to /mnt/usb it ment /mnt/usbstick...sorry forgot to mention that. But i created a dir /mnt/ntfs and tried what you said and as root it works but as my user it doesnt. i edited /etc/fstab to have /dev/sdb1 point to /mnt/ntfs and i had the same problem with my user where i can mount it but not browse it.

i did a little testing and maybe of notice.....the /mnt/usbstick and /mnt/ntfs dir when nothing is plugged in is owned by root:root when i mount my usb stick it changes to jtp755:users and when i mount the 120 Gb it stays root:root. Im going to change the drive out back to the 80Gb and see what it changes to.

[edit] It stays root:root and i can open it but i cant put anything on it.

Ok so i put the 120Gb back in and when i mount it the perms change like this:

from: drwxr-xr-x

to: dr-x------

when the 80Gb or the usb stick is mounted it stays like the from

----------

## rsa4046

I think your usb stick is probably formatted as a fat32, and by default (I'm guessing here, but this has always been my experience) a user(s) option in fstab will give you read/write/execute. Give me a second to test something, will post back in a few minutes.

Corrected: A <users> option with fat32 will give r/w/x etc., but ntfs is ro by default of course, and if mounted by root without permission options, will not be browseable ... (see below)Last edited by rsa4046 on Sun Jul 15, 2007 7:02 pm; edited 1 time in total

----------

## jtp755

will do...im currently formatting the drive from windows as a ntfs partition

----------

## rsa4046

OK, here's what I tried. First, I tried to mount my ntfs volume (it's /dev/sdc1) and got similar denial as you probably did:

```
$ su

Password:

# mount -t ntfs /dev/sdc1 /mnt/ntfs

# exit

$ ls /mnt/ntfs

ls: cannot open directory /mnt/ntfs: Permission denied
```

Then I tried

```
$ su

Password:

# umount /mnt/ntfs

# mount -t ntfs -o user,noauto,umask=0022,ro /dev/sdc1 /mnt/ntfs

# exit

exit

$ cd /mnt/ntfs

$ ls -l

total 4718284

-r-xr-xr-x 1 root root          0 2006-12-27 16:15 AUTOEXEC.BAT*

-r-xr-xr-x 1 root root        211 2007-03-08 00:03 boot.ini*

dr-xr-xr-x 1 root root     557056 2007-06-08 09:43 Config.Msi/

-r-xr-xr-x 1 root root          0 2006-12-27 16:15 CONFIG.SYS*

dr-xr-xr-x 1 root root       4096 2007-04-29 03:20 cygwin/

dr-xr-xr-x 1 root root       4096 2007-05-15 09:36 Documents and Settings/

-r-xr-xr-x 1 root root 3219873792 2007-06-08 09:37 hiberfil.sys*

-r-xr-xr-x 2 root root      28672 2006-12-27 16:15 hpqimgrc.resources.dll*

-r-xr-xr-x 1 root root          0 2006-12-27 16:15 IO.SYS*

-r-xr-xr-x 1 root root          0 2006-12-27 16:15 MSDOS.SYS*

dr-xr-xr-x 1 root root          0 2007-03-09 23:17 MSOCache/

-r-xr-xr-x 1 root root      47564 2006-12-27 16:15 NTDETECT.COM*

-r-xr-xr-x 1 root root     250032 2006-12-27 16:15 ntldr*

dr-xr-xr-x 1 root root          0 2007-03-09 23:21 Office10/

-r-xr-xr-x 1 root root 1610612736 2007-06-08 09:37 pagefile.sys*

dr-xr-xr-x 1 root root       4096 2007-03-09 23:21 Perl/

dr-xr-xr-x 1 root root      24576 2007-06-08 09:42 Program Files/

dr-xr-xr-x 1 root root       4096 2007-03-10 02:38 Python25/

dr-xr-xr-x 1 root root          0 2007-06-08 09:44 RECYCLER/

-r-xr-xr-x 1 root root       1167 2007-04-29 00:30 _Sid.txt*

dr-xr-xr-x 1 root root       4096 2007-04-29 03:18 System Volume Information/

dr-xr-xr-x 1 root root          0 2007-03-10 02:38 temp/

dr-xr-xr-x 1 root root      98304 2007-06-08 09:43 WINDOWS/

```

So try the above mount options (user,noauto,umask=0022), and see it that works ...

----------

## jtp755

ok thanks...i will try it when it finishes formatting what exactly does the u mask do again? ill post back

----------

## rsa4046

umask set/gets the octal file mode creation mask; if ntfs is mounted by root with no umask declaration, permissions default to 

```
$ $ ls  /mnt

total 8

<snip>

dr-x------  1 root root 8192 2007-06-08 09:43 ntfs/
```

If not mounted, /mnt/ntfs appears as

```
$ ls /mnt 

<snip>

drwxr-xr-x  2 root root  48 2006-12-26 16:26 ntfs/
```

Setting umask=022 bumps permission to being able to execute (cd) for group and world to 

```
$ls /mnt

<snip>

dr-xr-xr-x  1 root root 8192 2007-06-08 09:43 ntfs/
```

Edit: corrected typos

----------

## rsa4046

Also, I wasn't sure from your description above if you are trying to write to ntfs as well as just read. If you're trying to write as well, be careful, sys-fs/fuse will give you write capability on ntfs. Be but aware that writing to ntfs from linux is not guaranteed to be absolutely free of the risk of corrupting the ntfs volume. Some report no trouble with this, others do.

----------

## rsa4046

Here's a link (there are probably better) that gives some info on umask options:

http://kb.paragon-software.com/paragon/include/templ/object2.jsp?catId=2125&objId=5047&statId=870309&foLang=en

HTH

Edit: later added:

You might also be able to achieve the same result in terms of read/execute access by forgetting umask and using uid/gid:

```
mount -t ntfs -o uid=<username>,gid=<groupname> /dev/sdc1 /mnt/ntfs
```

Still later, added:

Better link = "http://gentoo-wiki.com/HOWTO_Mount_MS_Windows_partitions_(FAT,NTFS)#umask:_octal_file_permissions"

----------

## jtp755

this whole thing has really aggrivated me. I wonder why it made a difference which drive was in there and why one worked fine and the other didnt. Any way....i tried all the things you said and never could get it like i needed...probably cause i need to write to ntfs so ive kinda started over and gone a different route right now. I deleted all partitions on the drive and created a new one that is the whole drive. I formated it using mkfs.ext3 and then mounted it and i could write to it so i chowned the /mnt/usbstick dir to myuser:users and did it recursivly and i now can move files to and from it.

the problem is i cant access a ext3 partition under windows on every computer at work so im going to make it a FAT32 partition but do it all from windows and i think that will work. Thank you for all your help and it helped alot on figuring out what was going on...except i still dont get why one HD worked and the other didnt other than the fact one was a reiserfs partition and the 120Gb was a ntfs. That might have been the whole problem all along. Thank you also for all of the links. Ill post back with any other findings!

----------

## rsa4046

If you need reliable read and write access from Linux to a Windows partition, then prolly fat32 is your best bet, provided you can live with the limitations of fat32 (partition size is limited to 32 GB, individual files cannot be larger than 4GB). FAT32 access from linux is very mature and safe.

If you need either a larger Windows partition or anticipate file sizes > 4 GB, then at least two options are open:

1. write access for ntfs provided by the kernel: this access is limited to rewriting of existing files, and does not support creation of new files or deletion of existing files. Prolly not what you want.

2. sys-fs/ntfsprogs package provides ntfsmount, similar to functionality and limitation as (1)

3. the ntfs-3g driver with fuse (http://www.ntfs-3g.org/, package = sys-fs/ntfs3g), I've used this and have had no problems thus far (knock), but my experience is limited.

As far as Windows access Linux partitions, there is at least one program that allows read access to ext3 partitions (can't recall the link). IMHO the best solution for seamless R/W access to linux partitions is by runnng linux as a co-operative Windows process: coLinux (http://www.colinux.org). Here a linux kernel runs in its own window (using gentoo or any distro you like) using an image on the NTFS disk, and from there this process can access other linux partitions. You can export these partitions using samba, and read/write with zero problems.

Outside of running virtual machines, those are the only choices I know about.

----------

## opopanax

The other problem with NTFS is exactly what you're experiencing -- auto-id of the partition by mount.  You can see that you have to be very explicit in your instructions to get it mounted, and if you're that explicit in fstab, because of the fickle nature of how usb devices are recognized, you're going to have problems mounting regular old fat32 usb keys/drives/whatever.

You might want to consider whether trucking this drive around is really the best solution, or if something like a tunnelling VPN or some kind of remote file server might serve your needs better?

----------

## jtp755

thanks for both of the past 2 posts. I think Fat32 is the best option for what i need. I know about and have used coLinux before but i need to be able to carry this drive to work and be able to plug into any computer and install drivers or misc other things. So i would have to install coLinux on every machine and that wont happen. Fuse might be an option but i need to figure out how i can make sure the data wont get corrupted or lost on some of the stuff. Thank you for reminding me about the limitations of FAT32....i could definitly make multiple partitions on the drive and the only time i would run into a problem with the 4GB file limit is when im moving VMWare virtual machines around.

sketelsen: thanks for sorta pointing out the last remaining bit of why we were having the problem. Yes, once i started being specific in my fstab my usb keys started acting funny. It just seems werid that i have 4 usb keys and an external 6Gb drive that work absolutly fine and then the 80Gb worked great and the 120Gb was giving me problems. As much as it may suck i do need to carry the drive back and forth to work, Not all the time but when i do i need it to work....lol. I have an ftp and a file server setup and that servers most of my needs but i need another lil umph. Thanks alot for your info tho.

----------

