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?

  • 2
    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, 2011 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, 2011 at 14:02
  • 1
    - I do need the data indeed :)
    – Silvermist
    Jun 24, 2011 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, 2011 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. Jun 24, 2011 at 17:38

9 Answers 9


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

  • 1
    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, 2011 at 16:13
  • 6
    Then also try icacls hiberfil.sys /grant everyone:f - taking ownership doesn't automatically adjust the ACLs. Jun 24, 2011 at 16:32
  • 1
    @grawity, This is odd, If we aren't even booting into C:\ (like right now I'm in UEFI X:\ ), how could these Windows Access Restrictions even stop us? Win8.1 isn't even running, yet I'm getting Access Denied.
    – Pacerier
    Apr 24, 2015 at 17:39
  • @Pacerier the restrictions are on the file system not on the OS.
    – RJFalconer
    Jul 31, 2015 at 10:00

Combining the answers it's quite simple, no external programs needed.

From a dos prompt: icacls hiberfil.sys /grant everyone:f to get access to the file attrib -h -s hiberfil.sys to make it visible for deletion del hiberfil.sys to delete the file

For pagefile.sys it works the same way.

  • This didn't work for me; cmd simply says "Access denied". Mar 8, 2021 at 11:56
  • 1
    Very concise and perfectly functional on Win 10 Pro. I don't know why this is not the top answer.
    – Barton
    Jul 1, 2021 at 4:54
  • This one worked great without installing 3rd party tools, as long as you use Administrator mode for Command Prompt to avoid the "Access Denied" issue when running isacls. Since isacls is part of Windows, this is the answer as of 2022, IMHO. Nov 15, 2022 at 4:21
  • Access Denied might still happen even after taking ownership and granting full access because of high integrity level: icacls C:\hiberfil.sys /setintegritylevel Low Jul 4 at 16:07
  • Worked well for me on hiberfil.sys but it does not work on bootmgr for some reason. Integrity level didn't help either.
    – Slion
    Aug 18 at 11:07

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).

  • 2
    In addition to clicking "Unlock All" you can select delete in the Action dropdown.
    – Kevin
    Jun 24, 2011 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.

  • Strangely enough, this technique seems to have worked for me. I was prompted for an overwrite confirmation, and then after I did so, I was able to delete it. Mar 8, 2021 at 11:57

If you have only one drive, or you want to maintain the integrity of the files on your secondary drive (i.e. so you could later boot into it if needed), you'll want to disable the pagefile first (steps to disable pagefile from link).

If you don't care about preserving the drive, skip to step 5.

  1. Press Win+R (or Win+S) → enter SystemPropertiesPerformance.exe → press Enter → Click Advanced tab.
  2. Click Change under Virtual Memory and uncheck Automatically manage
    paging file size for all drives.
  3. Click on the partition you are trying to resize and set paging file size to No paging file. Click Set, then OK.
  4. Restart. You'll notice that both pagefile.sys and swapfile.sys are now gone from your disk.
  5. If the page file is still there, use Unlocker to delete the page file on restart.

I'm adding step 5 because the article seems to imply that the page file will disappear as soon as you restart.

This might not always be the case. When I restarted Windows 7 the file was still there. I couldn't delete the file because Windows 7 claimed the file was in use.

TAKEOWN didn't solve the problem either. Unlocker initially said that no locking handle was found.

However, Unlocker did give me an option to delete the file on restart, which worked great. @Kevin, Thanks for suggesting Unlocker.

  • Important parts of this answer is in the link which may go down in future making this answer un-helpful. Please post the contents of the link here & then link back for reference if you want to give credit
    – clhy
    Jan 27, 2016 at 3:04
  • 1
    Thanks for the comment! I'm new to stack exchange - maybe you can tell me if this looks better? Jan 28, 2016 at 4:45

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 :)


Windows Registry Editor Version 5.00

@="Take &ownership"

@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"


Windows Registry Editor Version 5.00

@="Take &ownership"

@="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"
  • Can you elaborate on "I used the super useful SysInternals tool to locate my entries"? Which tool? May 25, 2015 at 5:42

I used the commands I had already, mixed with some from this thread, specifically
user1686 had the missing command I needed. Here are the commands I used to make this work from a command prompt. I did this from WinPE, so I am not sure if it will work the same in Windows.


attrib -s -h drive:\pagefile.sys
del drive:\pagefile.sys

Hibernation file:

takeown /f drive:\hiberfil.sys
icacls drive:\hiberfil.sys /grant everyone:f
attrib -s -h drive:\hiberfil.sys
del drive:\hiberfil.sys

I can't put this in a comment because not enough rep, but for other people ending up here with a Google search, jdelange's answer works perfectly in Window 10's recovery console, where you can't use takeown or similar. Thank you so much!

Windows 10 Commandline from Recovery Boot:

icacls hiberfil.sys /grant everyone:f 
attrib -h -s hiberfil.sys 
del hiberfil.sys 
  • Why do you copy/paste another answer?
    – Toto
    Jul 20, 2022 at 18:27
  • I wasn't able to comment on the original post, to note that this is the solution for the particular scenario. Really, I just wanted to give the guy a thumbs up and note to others that this is the solution they need, when they can't "click" on anything. Too many answers assume the ability to install, which isn't possible in recovery.
    – Grey
    Jul 20, 2022 at 18:31
  • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review Jul 21, 2022 at 1:07

Use Treesize to list drive then just selected and hit del - it deletes them no probs (started as admin and used pro version but may work in free) Lots easier than all the above faff

  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 5, 2022 at 21:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .