2

I am trying to save my files on my Hard Drive that has a crashed OS. I created a Bootable USB with Ubuntu and successfully booted.

I can see my folders, but I can't actually open them because I don't have permission.

I tried to do this:

sudo chmod 777 -R Pictures

Where Pictures is the name of the folder I want to change permissions to.

All I want to be able to do is to copy the folders & files from my Hard Drive to my USB drive.

How do I do that?

  • did you use the entire path to the folder? (/media/<drivename>/home/<username>/Pictures)? Also, I usually put -R before the permission numbers. – mchid Dec 18 '14 at 21:28
  • @mchid Yep I did. Also, the recursive portion of the command works (i.e. something happens on all the files in the folder). The issue is that the permissions don't seem to be changed after the operation has finished. – marcamillion Dec 18 '14 at 21:47
1

Running from a live DVD, if you cannot cd into the folder because of "permission denied" you can use the following command to login as root:

sudo su

Logging in as root is not typically recommended and should only be done as a last resort and not just to be lazy! You can use the following command to log out of root:

exit
  • I tried both of these, and when I try to CD into the folder I just changed permissions of it still says "Permission Denied". I also noticed that beside some of the files it says chmod: changing permissions '/path/to/Pictures/some-picture.jpg': Read-only file system. So not sure if that means that the chown and chmod is failing, but I see that message on both commands. – marcamillion Dec 18 '14 at 21:41
  • 1
    @marcamillion if that is the case, use the command sudo su first and then try to cd into the folder. – mchid Dec 18 '14 at 21:43
  • When I do ls -l, the Pictures folder looks like this: drwx---------- 1 501 dialout 161 Jul 14 04:43 Pictures. Not sure if that helps any. – marcamillion Dec 18 '14 at 21:44
  • 1
    no, run the command sudo su press enter and then run the cd command – mchid Dec 18 '14 at 21:46
  • 2
    Thanks, I know the read only part, but the heart of marcamillion's problem is his drive is mounting so he can't see it. He just wants to back up files, not touching them and it may be a FAT FS that would ignore chmod permissions anyway. Something wrong in the mounting it appears. BUT he's running live anyway, and if running as root works that's good enough. – Xen2050 Dec 18 '14 at 22:05
1

I think you only need the mount option uid=[youruserid]

In a terminal you can type echo $UID or id -u to find out your user id.

If the drive's fs is fat, ntfs, cd-rom, udf, and a few others uid=value will "Set the owner and group of all files" to whose id is specified.

If the partition's already mounted (mount to see it & what device it is, or blkid) you might be able to just use

sudo mount -o remount,uid=[youruserid] /dev/[device] [mountpoint]

where [device] is the "sda1" or "sdc2" or whatever the right drive is, and [mountpoint] is the folder it's mounted to (with full path, often /media/something or similar.
(read [device] and [mountpoint] from the above mount or blkid commands)

Using sudo mount -o remount,uid=[youruserid] /dev/[device] alone might work, definitely works if there's an fstab entry for it.

  • 1
    remount is more flexible... I just tried a test, as long as the device is only mounted in one place (only mounted once) a remount doesn't need the mount point, "remembers" it since it's already mounted - Or maybe that's only if it's in fstab... – Xen2050 Dec 18 '14 at 22:36
0

It probably has to do with how the drive is mounted. If the drive is not mounted with proper ownership, you wont be able to access it. unmount the drive with umount. Then mount it again with the proper permissions: Lets say your UID is 1000 and the drive is a FAT partition then your mount statement should look a bit like this

sudo mount -t vfat /dev/sdwhateveryourdriveis ~/mnt -o uid=1000,gid=1000,utf8,dmask=027,fmask=137

This options flag (-o) should set the proper permissions for the directories on your drive. use the dmask and fmask values above and you your UID for uid

  • How do I figure out all of that stuff? i.e. what the UID, GID, mount name, etc.? – marcamillion Dec 18 '14 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.