PDA

View Full Version : [ubuntu] Problem with second drive; permission denied



ericstrom
September 27th, 2010, 03:33 AM
I recently set up a 2nd IDE drive to auto-mount. Seems to mount just fine. I have it under /media. But then I try to move or copy files (in this case Document 1) to it and I get the following error message:

Error opening file '/media/Drive-b/Unsaved Document 1': Permission denied

What do I need to change so I can use the drive ?

(currently running Lucid Lynx 10.04)

Clever_Username
September 27th, 2010, 03:38 AM
deleted

ericstrom
September 27th, 2010, 03:44 AM
You wrote .... "Can you post an ls -l on the file your trying to move?"

What does that mean ? How do I "post an ls -l" on a file ?

Note, I also tried moving another file to the drive and got the same permission denied message.

SentientFluid
September 27th, 2010, 04:52 AM
Open Terminal (Applications > Accessories > Terminal) and type
ls -l /media

Copy and paste the results here.

ericstrom
September 27th, 2010, 05:06 AM
Thanks for helping SentimentFluid. Here's the results:


eric@desktop:~$ ls -l /media
total 8
drwxr-xr-x 3 root root 4096 2010-09-25 09:44 Drive-b
lrwxrwxrwx 1 root root 7 2010-08-08 15:33 floppy -> floppy0
drwxr-xr-x 2 root root 4096 2010-08-08 15:33 floppy0

sidzen
September 27th, 2010, 05:21 AM
Go to your /home/username/ directory in the original or first drive and, in terminal, do as the man from Saskatoon said and enter the command < ls -al >. The ownerships here are what you want on the second drive, too.

Say your username is joe. you do a < ls -al > in your home directory and it says ownership is joe:joe , like below


drwxr-xr-x 2 joe joe 4096 Aug 29 16:29 PicturesSo, the command < chown > is necessary to do this.

So, go to /media/devicename/home/ and do the following, quick and dirty access

chown -R joe:joe username/*

bsalem
September 27th, 2010, 08:39 PM
Go look at the properties of the mounted filesystem on /media. If it is a Linux Native partition(s), fine, its a permissions problem alone, but if the filesystem is NTFS or some other foreign type, there could be additional issues. If an NTFS filesystem (Created by Windows ) is corrupt Linux will usually not be able to fix it. and it will be mounted read-only. You will need to use Windows to repair it, sometimes just needing to boot into Windows once, and the filesystem will come back under Linux read/write. At the command line under Linux a 'mount' command will show you how it is mounted, the 'df' command gives less, but it least it will tell you which partition goes with which mount point. Be sure the file system is mounted has the type and mount point you expect.

garyed
September 27th, 2010, 09:00 PM
It looks like only root has permission to write to Drive-b.
If you're using the terminal try using sudo in front of the command & see if that works.

sudo cp /media/Dirve-b/location-to-filename /location-to-new-filename

ericstrom
September 28th, 2010, 02:26 AM
I tried the solution by Gary (but fixed the text so it read Drive-b, not Dirve-b). So the exact command I used is:

sudo cp /media/Drive-b/location-to-filename /location-to-new-filename

I got the following message back

cp: cannot stat `/media/Drive-b/location-to-filename': No such file or directory

What does this mean ? And more importantly, what do I try next ?

garyed
September 28th, 2010, 04:19 AM
Are you typing the same command that you originally typed that gave you the permissions error but with sudo in front of it?
The cannot stat error is usually from a command that can't be executed like on a file not found or a partition not mounted.
Try this to check & make sure Drive-b is really mounted first:

mount

Then try the original command that gave the permissions error with sudo in front of it. See what if any errors you get. I'm assuming you have an NTFS partition & they can be tricky sometimes. You might have to edit your /etc/fstab file to get it working.
good luck

ericstrom
September 28th, 2010, 04:43 AM
The original error came from simply trying to move and save files to the new drive. Nothing exotic.

Not using NTFS....have it set up as ext4.

I noticed that the media folder and the /media/drive-b folders do not have folder sharing enabled. I'm not even sure what that means but I'm wondering if that's the issue ?

Per Gary's suggestion, I opened up terminal and typed "mount". Here's the results:

/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
none on /var/lib/ureadahead/debugfs type debugfs (rw,relatime)
/dev/sdb1 on /media/Drive-b type ext4 (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/eric/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=eric)

Seems like the new drive is mounting. It shows up in "Places" and I think the above output from terminal suggests it has mounted.

No problem modifying fstab. I just don't know what to modify it to. The current fstab is as follows:

UUID=06eb3868-4edd-4f71-92ca-ad0d871a9a20 /media/Drive-b ext4 defaults 0 2

garyed
September 28th, 2010, 08:17 PM
It doesn't look like you have any problem mounting so it doesn't look like there's any need to mess with fstab yet. If you can read the drive then its mounted. It might just be a matter of the syntax in your command line.
Lets say you have a file in your present home directory called "test".
The path will be ~/test.
To copy that file into the other drives home directory do:


sudo cp ~/test /media/Drive-b/home

egalvan
September 28th, 2010, 08:46 PM
Error opening file '/media/Drive-b/Unsaved Document 1': Permission denied


per your

ls -l /media
total 8
drwxr-xr-x 3 root root 4096 2010-09-25 09:44 Drive-b
lrwxrwxrwx 1 root root 7 2010-08-08 15:33 floppy -> floppy0
drwxr-xr-x 2 root root 4096 2010-08-08 15:33 floppy0

partition Drive-b is owned by root.
this is a permission (ownership) problem.
the ownership of the partition and all files inside should be changed to your username.
Or, alternatively, always open the partition in 'administration' mode

As an aside, I would be careful using mixed-case file names in *nix...
upper and lower case are different..

Drive-b
is NOT the same as
drive-b

something to be aware of, as
Linux is Not Windows

ericstrom
September 28th, 2010, 09:21 PM
Eglavan wrote ...."the ownership of the partition and all files inside should be changed to your username"

May I ask, exactly how does one go about changing the ownership of a partition ? Particularly when the partition is in a folder (/media) that is off root.

egalvan
September 28th, 2010, 09:55 PM
Eglavan wrote ...."the ownership of the partition and all files inside should be changed to your username"

May I ask, exactly how does one go about changing the ownership of a partition ?
Particularly when the partition is in a folder (/media) that is off root.
running

man chown
brings up a list of chown options...


EXAMPLES
chown root /u
Change the owner of /u to "root".

chown root:staff /u
Likewise, but also change its group to "staff".

chown -hR root /u
Change the owner of /u and subfiles to "root".


The highlighted portions should give you clues...

In the end. remember that everything in your file-system flows from '/'
which is, of course, owned by root.
Technically speaking, all your files are belong to root :)

egalvan
September 28th, 2010, 11:19 PM
OK, took me a while, but I found my notes on this...

about a year ago I purchased a 750gb drive, and an external USB-eSATA docking station.

I used PartedMagic LiveCD to partition and format the drive to ext3.

When I rebooted under Hardy, surprise, the drive was owned by root.


sudo chown ernest:ernest /media/750-data1

changed it to my username on that machine.

adding the -hR options will also change the files ownership.

N.B. at one time, this was mounted under /mnt, but I preferred having it auto-mount to the desktop, so changed it to /media.
the change in ownership came AFTER the change to /media.
I also set the disk-label to 750-data1.
When I plug it into any other Linux using USB, it is automatically found, and the icon is called 750-data1.
labeling partitions is a great time-saver under Linux.

ericstrom
September 29th, 2010, 12:37 AM
One last question on this; I promise !

Why is the command is it ernest:ernest and not just ernest ?

In other words, the suggested command is

sudo chown ernest:ernest /media/750-data1

but wondering why it wouldn't be:

sudo chown ernest /media/750-data1 or possibly sudo chown -R ernest /media/750-data1

ericstrom
October 1st, 2010, 01:46 AM
Thanks all for the great help. Problem solved !

oldsoundguy
October 1st, 2010, 01:52 AM
system> administration> disk utility. Make sure it is formatted properly and that it is partitioned and you have checked permissions .. and then mount it.

formaldehyde_spoon
October 1st, 2010, 02:35 AM
Add 'user' option to relevant line in fstab.