Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

A while ago I swapped my main hard disk for a SSD. Now the old one is used as a secondary hard disk, and my OS is a fresh windows install on the main SSD disk.

Nevertheless, there are still huge pagefile.sys and hiberfile.sys on that secondary hard drive. Those are not the ones used by the current windows, as those do exist on C:.

I tried to attrib -s -h them, but it refused with "Access denied".

Any idea how to delete those old unused system files and reclaim the space?

share|improve this question
1  
if all else fails, you can delete them from a linux live disk - say, using unetbootin if you don't want to waste a disk on it –  Journeyman Geek Jun 24 '11 at 13:49
    
If you don't need any of the data then formatting the disk should recover the space, but I'm assuming in this case you do. –  ChrisF Jun 24 '11 at 14:02
    
- I do need the data indeed :) –  Silvermist Jun 24 '11 at 16:15
1  
- Linux is an option but I'd rather keep that for last, as it sounds like it would take a while to do, and I have 0 experience with unix commands –  Silvermist Jun 24 '11 at 16:16
    
Most Linux live-cds boot into a desktop environment, so you just open the file manager and delete your files. Not all, however, automatically mount NTFS partitions. Two that I know of that do mount them are Ubuntu and Centos. –  Joe Internet Jun 24 '11 at 17:38

5 Answers 5

up vote 9 down vote accepted

The files are protected using NTFS ACLs. Use takeown to take ownership of them.

share|improve this answer
    
Takeown worked but I still could not delete. Ran commmand prompt as administrator : F:\>takeown /f hiberfil.sys SUCCESS: The file (or folder): "F:\hiberfil.sys" now owned by user "Me". F:\>attrib hiberfil.sys -s -h Access denied - F:\hiberfil.sys F:\>del hiberfil.sys Could Not Find F:\hiberfil.sys –  Silvermist Jun 24 '11 at 16:13
2  
Then also try icacls hiberfil.sys /grant everyone:f - taking ownership doesn't automatically adjust the ACLs. –  grawity Jun 24 '11 at 16:32
    
Icacl worked fine! Thanks a lot. –  Silvermist Jun 25 '11 at 5:22

You probably need to take ownership. And maybe remove the read-only setting? Re taking ownership: this can be achieved manually, but I prefer to add an (extended, hold shift) context menu.

I used the super useful SysInternals tool to locate my entries, F6 takes me to the registry where I can export the entries. You can copy and paste these into .reg files, save then open them to quickly add :)

Take&ownership-all.REG

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take &ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
"Extended"=""

[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

Take&ownership-Directory.REG

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\runas] @="Take &ownership" "HasLUAShield"="" "NoWorkingDirectory"="" "Extended"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command] @="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t" "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

share|improve this answer

To delete hiberfil.sys on the active drive use one of these methods

In Windows 8

  • Control Panel > Hardware and Sound > Power Options
  • Click Change settings that are currently unavailable if it appears
  • Uncheck Enable Hybrid Boot and Show Hibernate options

In Windows 7 and Windows Vista

  • Open an administrator command prompt and issue the command powercfg -h off

In Windows XP

  • Control Panel > Power Options > Hibernate tab
  • uncheck Enable Hibernation and click on Apply followed by Ok
  • Reboot and delete the hiberfil.sys file
share|improve this answer

Use unlocker to do this. It can not only remove the locking handles that are giving you an "access is denied" message, but can also delete the files at the same time (in case the program tries to reacquire the handle).

share|improve this answer
    
In addition to clicking "Unlock All" you can select delete in the Action dropdown. –  Kevin Jun 24 '11 at 16:53

I had tried all these methods since migrating my OS to an SSD a year ago. Takeown seems to work, but the file cannot be found to delete, it does not show up doing a DIR from the command prompt, in file browsers, ect... Hiberfil is already disabled via command prompt, but I tried to re-enable it and disable it, still no go.

It was like the file was there, but not there.

What worked for me was creating a 'New > Text Document', Renaming that to Hiberfile.sys. I had to do this in a folder because it would not let me create anything except for a folder in my main F: drive. I then Paste it to F:\, then deleting that file. Freed up the 32GB I had tried to get back a few times over the past year.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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