2

I am running 12.04 live from cd and trying to copy some important files from a mounted hard disk to an external disk. (My previous installation of 10.04 crashed and I want to install 12.04, and back up some data before that).

When I try to copy files from the mounted disk to the external one, I get the following error:

There was an error copying the file into /media/New Volume/L300_Bkp_2012_06_04/pics
Error opening file: Permission denied

Is this related to the source(mounted hard disk) or the target (external disk)?

How do I get around this?

Jorge Castro
  • 71,754
aqm
  • 121
  • 1
  • 3
  • check if you have write permissions on the mounted disk. Type mount to see if /media/New Volume/ .... has somewhere the options "rw" – mbs Jul 05 '12 at 08:21

2 Answers2

2

This is mostly related to the mounted hard disk. You can try these to workaround the problem.

Using root power.

Press Alt+F2 to bring dash command prompt. In that window, type gksudo nautilus. This will open nautilus with root permission. Then you can copy the files safely. Remember to close the root powered nautilus after the work finished, also do only what you wanted to copy.

Take ownership of the mounted file system

If the above method does not work, You can use this.

Open a terminal, and type sudo chown user:user /media/New\ Volume to take ownership of the file system. Then copy the files and reboot. Please note, it is only recommended, if the above method does not work.

Hope this will solve the problem

( Credit: This thread )

Anwar
  • 76,649
2

The problem appears to be the target: /media/New\ Volume but may equally be the source if the permissions are set to not allow read access (default is usually to allow read but nothing else)

I don't recommend that you use gksudo nautilus if the source file system is damaged in any way - I've seen (or rather helped people recover) systems with command line which couldn't be done with Nautilus because it still had permissions problems for some reason.

I also don't recommend that you take ownership of either file system while booted off the CD. The username will ubuntu, or root if you use sudo. I also recommend that you do NOT write to the source file system (with chown, nautilus, or otherwise) if there's any chance it is damaged. If there's a problem it will make it worse.

Instead, just copy the data from the source (presumably the first internal disk or partition) to the external drive mounted on media, obviously /media/New\ Volume

To mount the first internal disk/partition using command line:

  sudo mount /dev/sda1/ /mnt

where sda is the first physical hard drive and the partition in question and (1) is the first partition on it.

Your data will then be accessible as /mnt/home/username unless you had a separate partition for /home

Assuming that your external drive has automounted at /media/New\ Volume and you have already made the directory L300_Bkp_2012_06_04 on it you can copy all of your home directory with the following command:

   sudo cp -rv /mnt/home/username/* /media/New\ Volume/L300_Bkp_2012_06_04/

If the external backup drive is formatted FAT then you will have no permissions problems when you come to copy the data back to your re-installed system. If the external drive is ext4 then the backup files and directories will belong to root and you may need to take ownership of them before you can copy them. After you boot the fresh system and log in with your username:

   sudo chown -R username:username /media/New\ Volume/L300_Bkp_2012_06_04/*

If you are not sure what disk and partition you are trying to recover the data from (ie /dev/sda1, /dev/sda2 etc) then ask and I'll add some detail.

Edit: If you want a backup regime that will do the same as the above copy command but can be used again and again to only copy new or changed files and which will also backup the hidden dot files (config files mostly) then replace

cp -rv

with

rsync -av 
fabricator4
  • 8,375