Pages

Wednesday, March 17, 2010

I was using Windows XP in a VMware Workstation 7 virtual machine (VM), running on Ubuntu 9.10 (Karmic Koala). In WinXP, I had moved some files to a new folder on a compressed external USB hard drive, and now I wanted to fiddle with the contents of that folder. Unfortunately, I got this message:

[Filename] is not accessible.

Access is denied.

I found a post that suggested that this might have something to do with folder sharing. I went into VMware's VM > Settings > Options > Shared Folders. There, I saw that the external drive was not included in the folders that were being shared. I clicked Add, typed the name of the external drive, and went browsing for its host path. But I couldn't add it; the dialog box was not seeing it. It also wasn't visible in Ubuntu's Nautilus (i.e., File Browser), presumably because I had already connected to it in the VM, via VMware's VM > Removable Devices menu pick. So now I disconnected it there, went back to Ubuntu, and waited for it to show up in Nautilus. It didn't show up. I went back to the VM to see what was going on, but it was definitely disconnected and was no longer visible in Windows Explorer.

Meanwhile, though, the external hard drive's light was on. It was doing something, even though it did not seem to be recognized by any physical or virtual machines. Some hours earlier, I had started it on a project of decompressing one of its folders. That folder contained some large files. So now it seemed that the drive was going to just stay locked in that process until it was done. I left it for quite a while but, hours later, the hard drive light was still on, steady, without flickering. I shut it down and started it back up. Now, after a minute, Ubuntu saw it. I went into the VM and connected to it. When the VM saw it, I went back into VM > Settings > Options > Shared Folders and tried to add it. But the VM still couldn't see it. I suspected that the VM was reading from the fstab. To explore that possibility, I disconnected from the USB drive in the VM, went back to Ubuntu, and, following some advice from one of my old posts, when Ubuntu saw the external drive again, I opened Terminal and typed "sudo blkid" and copied the UUID for the drive in question (named DAILY). In a separate Terminal session, I typed "sudo gedit /etc/fstab" and added that UUID in two lines that looked like this:

# Entry for /dev/sde5 :

UUID=ADBG2454DBD /media/DAILY ntfs-3g defaults,locale=en_US.UTF-8 0 0

I went back into the VM and connected to the external USB drive again, and then tried again with the VM's Shared Folders option. DAILY was still not visible there. Maybe it was a question of what drives were visible when the VM started up? This external drive was probably not connected and turned on at that time. I rebooted the VM to see what would happen if DAILY was connected the whole time. That definitely took care of the drive recognition problem, but I still got the "not accessible" error when I tried to go into the folder I was trying to view. So I went back into the VM's Shared Folders setting and tried to add DAILY to the list of shared partitions. Unfortunately, it was still not listed. Ah, but back in Ubuntu, I had an error message:

Unable to mount DAILY

Error mounting: mount exited with exit code 1: helper failed with:

mount: only root can mount /dev/sde5 on /media/DAILY

This gave me an idea. Did I have to be running Workstation as root in order to add DAILY as a Shared Folder in the VM? I disconnected DAILY from the VM and went to Ubuntu to take a look at the drive permissions. DAILY wasn't visible on Nautilus until I clicked the computer icon in the toolbar. When I did that, it became visible on the right side of Nautilus, and that also reproduced the "Unable to mount DAILY" error message. So it seemed that message had been generated by Ubuntu's effort to mount DAILY when I disconnected it from the VM. But why did root have to mount DAILY? I right-clicked on DAILY (on the right side of Nautilus) and went to Properties > Permissions. But it said the permissions could not be determined. So, OK, I ran "sudo nautilus" and tried that again. But DAILY wasn't visible in Nautilus. So I exited that and tried "sudo blkid." DAILY was still at /dev/sde5. nixCraft told me to make a mount point for it (in this case, "sudo mkdir /media/DAILY"). Now "sudo fdisk -l" told me that /dev/sde 5 was NTFS, in which case I could use "sudo mount -t ntfs -o nls=utf8,umask=0222 /dev/sde5 /media/DAILY" to mount it. Now at least I was able to see that its permissions were root (not me). Using "sudo nautilus," I went to File System > media and right-clicked on DAILY. But I was not able to change its permissions; they changed back after I tried. Following Merlin's advice, I went into Ubuntu's System > Administration > Users and Groups. There, it looked like "ray" was the name of both my user and my group. So I typed "sudo chown -R ray:ray /media/DAILY" to change the ownership of that drive (and everything on it) to ray. This caused the external drive to grind away for maybe five minutes. But the Permissions were still the same: root. Sebastian Abate made me think I might have to unmount the drive to change the permissions, and that the change of permissions would actually apply to the mount point, so I typed "sudo umount /media/DAILY." Then I tried the "sudo chown" command again. This time, of course, it did not make the external drive grind away. Now I tried Sebastian's version of the "sudo mount" command: first "sudo chmod 777 /media/DAILY" and that was the answer. I now owned DAILY.

I went back into the VM, connected the external drive, and tried to play with it in Windows Explorer. As I may have realized before (a day or two had passed by this point), the problem was peculiar to just one folder that I had created while the drive was owned by root. So, OK, it seemed I needed to disconnect the drive from the VM again, go back to Ubuntu, and run "chmod -R 777 /media/DAILY." The -R option would run the chmod command recursively, through everything on DAILY. But that gave me "cannot access `/media/DAILY': Input/output error." It sounded like this might have been caused by an improper shutdown, so I plugged the DAILY external drive into a WinXP computer, right-clicked on it, and did Properties > Tools > Check Now > Automatically fix file system errors > Start > Yes. So now it would check that drive after I rebooted the Windows computer. Meanwhile, I tried to manipulate that troublesome folder in Windows Explorer on that Windows machine, and what did I see but the same "access is denied" message! It wasn't an Ubuntu or VM issue; it was an ntfs hard drive issue. I rebooted and let CHKDSK do its thing. Unfortunately, that didn't do it. It seemed this folder was really very screwed up. I rebooted with the Windows XP installation CD and ran CHKDSK /R from its Recovery Console. For this 750GB hard drive, this took more than 24 hours to run twice (i.e., until CHKDSK /R reported no more errors fixed). When it was done, I went back into that uncooperative folder. Access was still denied. I rebooted that dual-booting computer into Ubuntu and examined the folder there. Ubuntu had no problems with it. Right-clicking showed me that the folder was owned by root. I re-ran chmod, this time specifying "sudo chmod -R 777 /media/DAILY/EXTERNAL," where "EXTERNAL" was the name of the folder in question. This changed nothing. I backed up another step to "sudo chown -R ray:ray /media/DAILY/EXTERNAL." Then I re-ran chmod. Still no change of permissions. I tried "sudo nautilus," with Windows-style manual change of permissions but, as before, no effect. WinXP's CHKDSK may have been good for the drive generally, but it did not seem to have changed anything regarding the recalcitrant directory.

Using Nautilus, I created a new folder, EXTERNAL2, and (in normal user mode, not root mode) I copied everything from EXTERNAL to EXTERNAL2. Permissions were not changed. I ran chown and chmod on EXTERNAL2. As before, this changed nothing. Using VMware Workstation, I went into a WinXP VM, set up DAILY as a shared folder, mapped it in Windows Explorer (Tools > Map Network Drive), and used WinEx to take another look. Unlike in WinEx elsewhere, here I was able to view the contents of EXTERNAL and EXTERNAL2. I deleted the contents of EXTERNAL2 in WinEx and copied them again from EXTERNAL. Again, that in itself did not change permissions, nor did the same chown and chmod commands make any difference. In Nautilus, I deleted EXTERNAL and renamed EXTERNAL2 to be EXTERNAL. To delete EXTERNAL, I had to manually delete some files with names like .fuse_hidden0000ef520000009d. In some cases, though, those files seemed to be recreated after deletion. I found that I could delete them, one folder at a time, using the right-click Delete rather than hitting the Delete key, followed by F5. So I did wind up with EXTERNAL2 renamed, in WinEx, to be EXTERNAL. I bailed out of Ubuntu and rebooted into WinXP. I noticed that, while the letters of EXTERNAL had previously been colored blue (indicating that it was a compressed folder, where it seemed that the problem may have arisen from an interruption of the compression process), this newly remade EXTERNAL folder was black (indicating no compression). I was now able to go into EXTERNAL, see its contents, and rearrange its files and folders. I still did not know how to change its permissions in Ubuntu, but apparently that was not going to prevent me from working with it in Windows.

Summary

I think what fixed the drive was to view it in Ubuntu's Nautilus, make a copy of it, and then delete the original. I did not figure out how to change its permissions, but I was nonetheless now able to use it in Windows XP.