How to compact a registry hive?

4

2

I'm using a (non-administrator) roaming profile, with a size limit of 4MB.

As you can imagine, it is extremely difficult to stay within that size limit.

I've noticed that NTUser.dat, which holds my HKEY_CURRENT_USER hive, is 2560KB, single-handedly using more than half of that limit.

Is there any way to shrink the hive without administrator privileges?
I don't mind losing any settings or preferences stored in it.

SLaks

Posted 2010-04-14T19:36:22.680

Reputation: 7 596

I complained to the administrator, and my profile was completely reset.

NTUser.dat is now about 1MB. – SLaks – 2010-04-28T14:06:58.857

...4MB? Can that really not spare you any more space? – Earlz – 2011-06-10T20:49:05.283

@Earlz: Blame the IT admin. They say it's to prevent network congestion. – SLaks – 2011-06-10T20:53:37.340

Answers

2

I too would recommend NTRegOpt, though I have seen another program that had a nice Luna-esque themed GUI and had some nice touches like “locking” the system with a faked system-modal dialog that fades the rest of the screen to grey (like XP’s shutdown dialog), while it works. … The program I was thinking of is Auslogic’s Registry Defrag.

Unfortunately it is not free ($20), but it is quite nice and regularly updated to so it performs better and better.

Another one that’s nice (and free) is QuickSys’s Registry Defrag. I like that it has a relatively comprehensive list of hives to compact.

Oh, and when evaluating registry compactors, one thing to look out for is if the program can give you a preview by analyzing, without actually going ahead with the compaction. Another thing to look for is a backup function (though I think that’s standard).

Synetech

Posted 2010-04-14T19:36:22.680

Reputation: 63 242

1

I'm pleased you've managed to solve the problem, but for future reference (and because other people reading this won't be able to ask your admin to reset their profile), there are a couple of tools which can compact the registry hives:

NTRegOpt seems to be the preferred tool.

RegCompact Pro is another.

Both these tools are freeware, though RegCompact Pro has the noisy garish look of shareware; I always get the feeling it's going to ask me for $25 before finishing.

Also both tools will pretty much disable your PC while running, because they need almost exclusive access to the Registry while they work; and they'll seem to grind away for so long that you'll wonder if it's crashed.

Relax. Be patient, and let them do their job.

As ever, take backups of the registry before you start fiddling; and you'll probably get better results if you first uninstall as much rarely-used junk as you can, and let CCleaner have a look before compacting.

njd

Posted 2010-04-14T19:36:22.680

Reputation: 9 743

I’d definitely recommend NTRegOpt. As njd said, you have to just let it do it’s thing and wait, even though it looks like it’s stuck in a loop, doing nothing (it could certainly stand to have its progress system updated to be more accurate/responsive). It can take quite a while with a relatively large hive (eg from a system that was installed a while back and has had a lot of activity like programs installed); after all, it does have to dump every single item in the registry to a new one! – Synetech – 2011-06-07T02:19:19.393

0

I'm not sure about defragging a registry file without Admin privileges but... the excellent Sysinternals has a utility called PageDefrag that will do what you want.

gbjbaanb

Posted 2010-04-14T19:36:22.680

Reputation: 1 292

Fragmentation has nothing to do with size. Defragging won't help. – Hugh Allen – 2010-04-14T21:15:11.793

It doesn't seem to do hives for user profiles. Even if it did, it couldn't help unless I run it on the Domain Controller, which I don't have access to. – SLaks – 2010-04-15T00:45:40.767

1

@SLaks, I think PageDefrag (http://technet.microsoft.com/en-us/sysinternals/bb897426.aspx) does compact registry hives. You could get your administrator to run it for you (maybe at a scheduled down time). Performance would always be in their interest.

– nik – 2010-04-15T05:50:47.627

@nik: Not user hives. – SLaks – 2010-09-27T02:23:33.850

@SLaks, are you saying PageDefrag does not defrag user-hives? – nik – 2010-09-27T02:35:46.530

@nik: Yes; it only defrags system-level hives. (In %SYSTEMROOT%\system32\config\) – SLaks – 2010-09-27T02:37:24.823

@nik, no PageDefrag does not compact the hives, otherwise it would take much longer than it does. PageDefrag literally defrags them, that is, it takes the chunks of the file, containing whatever they may, and rearranges them on disk to be contiguous. Compacting dumps them out to a new file. And no, sadly PageDefrag does not defrag user hives, and worse, it hasn’t been updated since 2006 (before Windows 7), which explains why it doesn’t completely work (the defragmenting seems to work, but the config program isn’t quite right). Mark does not seem to have any plans on updating it. :-( – Synetech – 2011-06-07T02:26:54.680

@Synetech: There's little need to update PageDefrag. The built-in Defrag APIs in Vista & 7 are now able to defrag registry hives while the system is running. In fact, I think the only files that can't be defragged online now are the pagefile, hiberfile, and shadow copies. There's either too much churn to worry about defragging (shadow copies), or their initial space allocation never changes (page/hibernation). – afrazier – 2011-06-10T19:36:30.290

@afrazier, okay, that sounds good, but is it done automatically or only when you actually run a defrag? If I can replace my dead motherboard so that I can run Windows 7 again, I’ll keep an eye on PageDefrag to see if it ever actually does anything (ie, if the hives are already always in one piece). – Synetech – 2011-06-11T02:26:02.980

@Synetech: I'd imagine it's at least done whenever a defrag is run (automatically weekly, if you didn't disable it). Possibly whenever prefetch information is updated, but I'm not sure about that one. – afrazier – 2011-06-11T03:15:39.293