Thursday, January 1, 2015

Remove HP Recovery partition to install Linux

Problem: I want to install Ubuntu Linux next to Windows on my new HP Probook 430 G2 laptop, but it comes with 4 primary partitions pre-installed. This is the maximum number of partitions allowed, which makes it impossible to install Linux in dual boot.

I googled a lot of solutions but finally settled on making a set of recovery disks and deleting the HP_RECOVERY partition as outlined in the HP support article "Removing the HP Recovery Partition".

Shrink volume in Windows 7

In order to install Ubuntu on a new HP Probook 430 G2, with Windows 7 pre-installed, I wanted to shrink the C: volume in order to make more space for Ubuntu.

So I did the usual:
- in Start Menu search box, I typed "partition"
- click on "Create and format hard disk partitions"
- I right-clicked on the C: volume and chose "Shrink volume"
- in the following window I could shrink the C: volume to about half its size. But the problem was that I wanted to shrink my partition more than what was allowed.

To cut short to the solution, here's how I unblocked the remaining space:

In short:

  • I disabled virtual memory
  • I disabled file indexing and deleted the index files
  • I also deleted shadow copies
  • Restart, shrink partition as desired
  • As far as desired, re-enable virtual memory and/or file indexing and make a restore point.

In long and detailed:
  • I disabled virtual memory (first steps are copied from Microsoft site):
    • Open System by clicking the Start button Picture of the Start button, right-clicking Computer, and then clicking Properties.
    • In the left pane, click Advanced system settings.  Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.
    • On the Advanced tab, under Performance, click Settings.
    • Click the Advanced tab, and then, under Virtual memory, click Change.
    • Clear the Automatically manage paging file size for all drives check box.
    • Click on "No paging file" (further down in the same window)
    • Restart
  • Note: It might be necessary to disable also the creation of Recovery Points, which in my case wasn't active to begin with, so I can't help you here.
  • Upon restart, I still had the same problem. So I tried manually shrinking the volume using Diskpart (to find info on this, start the partition manager as explained at the beginning of this article, right-click on C: volume, choose "Shrink partition", and in the following popup window click the link that says "See Shrink a basic volume" which brings you to a help page with all explanations). 
    • Diskpart didn't succeed in shrinking the volume more than the graphical interface did, of course, but it did write an event in the system logs. As explained in Windows help about shrinking volumes, in the Application logs you can search for event 259 which details the file that blocks further shrinking. So click on Start Menu, type "log" in the search box and choose "view event logs". There, under "Event viewer" -> "Summary page events" in the section "Information", look for event ID 259 and, at the right (in the "actions" pane, click on "view all instances of this event). Click on the last one, chronologically, and there you should see the file name of the file blocking the further shrinking.
    • So here I found out that the indexing service was involved. 
  • So I disabled the windows indexing and deleted the index files:
    • To disable the service:
      • in Start Menu, type "services" and click above on "services"
      • Look for "Windows Search", right-click on it, stop the service and and put "startup service" to "disabled" so on restart it doesn't start again.
    • Then I deleted the index files:
      • first find out where they are
        • in Start Menu type "regedit" in the search box and click on "regedit" above.
        • find HK_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> Windows Search and click on it. To the right, next to DataDirectory, you'll find the right directory (in my case %ProgramData%\Microsoft\Search\Data).
      • Then delete them as administrator: I opened a Windows Explorer window as administrator (type "explorer" in Start menu search field, right-click on Windows Explorer and select "Run as administrator"). Then I typed in the directory box on top "%ProgramData%\Microsoft\" (without the quotation marks), right-clicked on the "Search" subdirectory and chose "delete".
  • I deleted shadow copies:
    • I opened a command prompt as administrator (Start Menu -> All Programs -> Accesories -> Command prompt -> right-click and select: "run as administrator")
    • Typde "vssadmin list shadows" in command prompt
    • Typed "wmic" in command prompt and pressed enter. Then typed "shadowcopy delete" and at the prompt, selected "'Y" for every shadow copy.
  • Then I restarted and was able to shrink the partition to the desired size.


If you appreciated this article for some reason or another, please share it (see the buttons below), and, of course, don't forget to Flattr! (Why?)