Sunday, September 5, 2010

Fixing Permissions on an External Hard Drive

Today I pulled a hard drive from my old computer and hooked it up to my new computer, planning to move the data to the new drive and then use the old drive as a backup disk. Mostly this plan worked well, except that I wasn't allowed to delete many files and folders, even though I was an Administrator. Curious.

The problem turned out to be that I was on a workgroup, not a domain, and so the systems didn't have any common notion of "Administrator". Although Explorer knows how to request elevated permissions, this still isn't enough. You have to "Take Ownership" of the files in order to delete them, and there's no way to do this from Explorer.

I found a solution in the winmatrix forum, but it only works for files, not directories. You can't set the Full Control permission on a directory, so you end up being locked out of directories if you try and use these commands:

takeown /f filepath /r
icacls filepath /grant yourusername:f /t


Note that I've added /r and /t to the commands, which is required for the them to operate recursively.

Instead, I did the steps below. These steps assume that the new drive is on E:.
  1. Open a Command Prompt with Run As Administrator.
  2. Run this command: takeown /f e:\ /r
  3. Right-Click on the root of the copied drive.
  4. Select Properties.
  5. Click the Security tab.
  6. Click the Edit button.
  7. Select Authenticated Users.
  8. Click the checkbox under Allow for Full Control.
  9. Run this command: icacls e:\*.* /reset /t
    This command will force all permissions to mirror the permissions on the root of the drive that you set in #6. You must have the *.* or the root directory will be reset, which you don't want.
After these commands completed, I was able to delete all of the desired files. Executing these commands can take quite a while if you have many files on your disk.

24 comments:

  1. thanx, worked well

    ReplyDelete
  2. Thankyou SO much. I'd just set up a new system and needed to resolve a external HDD permission issue. After hours of searching this done it.

    ReplyDelete
  3. I wasn't looking for deletion of the files but for discovery by Windows 8, this helped me out by resetting all of the mess I created changing permissions, now my problem is resolved!!!

    ReplyDelete
  4. Worked like a charm, thanks you.

    ReplyDelete
  5. thanks thanks thanks! had screwed up permissions on ext. drive connected to wndr3700 router after trying to set certain folders for access by friends on the 'net...d'OH!
    this worked for me, too!!!
    once more--thanks!

    ReplyDelete
  6. It worked unlike everything made by Microsoft......PERFECTLY.
    Thank you SO much. Major help and prevented more down time from a bad registry from an OS I had to re-install which is why I needed to move files from an HDD. I'm bookmarking your site for the future.

    ReplyDelete
  7. woooaaaahhh,...... thank you soooo much... :) cheers.....

    ReplyDelete
  8. Rock On !! That worked for me :)

    ReplyDelete
  9. It works for me. You safe my day. I like you bro =)

    ReplyDelete
  10. Thanks for taking the time... all done and working o.k

    ReplyDelete
  11. THANK YOU!!!!!! You saved me 2.2 TB worth of files

    ReplyDelete
  12. How can I go about making my external hdd accessible to any computer I plug it in to and how do I make that permanent? I'd hate to have to do this every time I plug it in somewhere.

    ReplyDelete
    Replies
    1. In my example code, instead of "yourusername", use "Everyone". I believe that works across computers.

      Delete
  13. Worked exactly as described. Thanks!

    ReplyDelete
  14. Thanks! I tried everything and just messed things up worse. Your how to saved my bacon

    ReplyDelete
  15. no doubt, this is perfectly worked for me !

    thank you :)

    ReplyDelete
  16. i love you. i wish i found this 9 hours ago.

    ReplyDelete
  17. Fantastic, this is definitely the fix! Thanks for posting.

    ReplyDelete