Shrink a Windows XP NTFS Partition to half size and Install Linux while keeping the Windows Boot Menu

Written by James McDonald

July 21, 2008

Disclaimer: This procedure can render your computer unbootable and corrupt your data if you do it wrong. Perform a backup prior to doing it and verify you can read the backup. Don’t attempt it on a critical laptop. I am in no way responsible if you attempt this and end up with an expensive brick or it results in data loss.

The scenario:

1 Dell Latitude D610 with a 60GB HDD
1 IT Guy about to go on holiday but not wanting just to take a Windows XP box

The dream:

Shrink the XP install down to 30GB and use the new volume to install Fedora 9. Keep the standard windows boot loader (i.e. Nothing to see here move along)

The how:

  1. Boot XP and run disk check (chkdsk c:) on the volume you want to shrink – this is a good idea
  2. Boot XP and run defrag (defrag c:) till it’s as contiguous volume as it’s going to be
  3. Grab a Knoppix CD and boot from it
  4. In Knoppix get a root console and do the following
  5. use fdisk -l to get the hard disk volumes – in my case it’s /dev/sda
  6. fdisk -l
    Disk /dev/sda: 60.0 GB, 60011642880 bytes
    255 heads, 63 sectors/track, 7296 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x41ab2316
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1           8       64228+  de  Dell Utility
    /dev/sda2   *           9        7296     XXXXXXX  7  HPFS/NTFS
  7. Use ntfsresize --info /dev/sda2 to get the minimum size of what you can shrink it to. We will be leaving the Dell Utility partition alone the C: drive is /dev/sda2
  8. ntfsresize --info /dev/sda2
  9. In this case I didn’t go to the minimum size I just divided the hard disk in half 60011642880/2 = 30005821440
  10. Use ntfsresize -s 30005821440 -n /dev/sda2 to test (-n or not really) if it seems OK
  11. ntfsresize -s 30005821440 -n /dev/sda2
  12. Then run ntfsresize -s <size IN BYTES> /dev/sda2 to do it for real
  13. ntfsresize -s 30005821440 /dev/sda2
  14. When it’s finished make a note of the new partition size in MiB that it has created you need this for fdisk
  15. run fdisk /dev/sda, make note if the partition you are shrinking has the bootable flag, partition type (7) and start sector. Delete the old partition (/dev/sda2)
  16. Create a new partition with the new partition size as specified by the output of the previous ntfsresize operation. When entering the partition size use +<size IN MiB>M e.g. (+28616M note: This size is a guess I am writing this from memory make sure you use the size recommended by ntfsresize as the size of the new partition), mark it bootable if it was before and set it to be NTFS (type 7). When it’s right, commit it to disk
  17. Reboot back into Windows twice. It will run chkdsk the first time and find new hardware, the second time is just to make sure it’s all in a consistent state
  18. Now install Fedora 9 onto the empty part of the hard disk. When prompted for the location of the GRUB bootloader code choose the /dev/sda3 partition which is the /boot partition of the linux installation. Don’t chose to install the GRUB bootloader to the MBR as this will wipe out your Windows bootloader
  19. Once you reboot you will find that you still have your Windows bootloader but no option to select Fedora 9 from the Windows boot menu.
  20. Here is a fdisk /dev/sda listing after installing Fedora 9
  21. fdisk /dev/sda
    Disk /dev/sda: 60.0 GB, 60011642880 bytes
    255 heads, 63 sectors/track, 7296 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x41ab2316
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1           8       64228+  de  Dell Utility
    /dev/sda2   *           9        3829    30692182+   7  HPFS/NTFS
    /dev/sda3            3830        3854      200812+  83  Linux
    /dev/sda4            3855        7296    27647865    5  Extended
    /dev/sda5            3855        7296    27647833+  8e  Linux LVM
  22. Using the Knoppix CD once again boot into Knoppix and gain a root console
  23. You now need to take a copy of the GRUB bootloader from /dev/sda3
  24. Plug a USB key in and copy the bootloader to it with dd if=/dev/sda3 of=/media/MYKEY/bootsect.bin count=1 bs=512 – I think these days you could mount and write straight to the NTFS partition but when I tried to get Knoppix to write directly to the NTFS partition it complained that the volume was dirty. This, I think, was because I had power cycled when Windows XP was half booted, so I just used the USB key to get a copy of the GRUB bootloader.
  25. dd if=/dev/sda3 of=/media/MYKEY/bootsect.bin count=1 bs=512
  26. Booting back into Windows copy the bootsect.bin file from the USB key to c:\
  27. Then making sure Windows Explorer has the show hidden files option enabled and hide system files disabled find c:\boot.ini, remove the readonly attribute, and add a Fedora 9 entry to it pointing to the Linux bootsector thusly:
  28. [boot loader]
    [operating systems]
    multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
    C:\bootsect.bin="Fedora 9"
  29. After another reboot you should now have both OS options on your standard Windows boot menu

The result:
I can now go on holidays with a dual boot Laptop containing a standard work OS and a Fedora 9 environment. If I need to give the laptop over to anyone, I can remove the boot.ini entry and hand it to them.

PS. Fedora 9 found the Intel wireless and I could connect straight up to my WAP with no issues. GNU/Linux Rocks!


  1. Conrad

    Great idea to boot from a live verison of Linux (I used Fedora) and use ntfsresize. I’m running a VM on XP and wanted to create a new partition on my HD to keep virtual disk files on [so they can grow into a chuunk of space without getting interleaved with other files & too fragmented]. Your solution was just the trick.

  2. james

    Thanks for the feedback Conrad.

    Once apon a time Knoppix was the only option. I didn’t realize that a distro’s Live CD would have all the tools require but it appears they do.

  3. MadMatt

    Thanks very much for the help it worked great for me. One item I may add to my stupidity…….but I will share as others may enjoy being helped as well. My XP machine had a dynamic disk for some reason to which microsoft do not have an undo feature. The disk can not be changed back to basic by any microsoft means.

    In me following the instructions my disk was coming up as type 42 STS. I tryed the resize keeping the disk as type 42 STS. Windows failed to boot or run chkdsk or recover with install disks.

    I went back to fdisk and changed the type to 7 NFTS and it worked. My computer booted again and the disk was changed back to basic.


    • james

      Thanks for posting this Matt. Seems like there is always some variation, or something to catch us out when we attempt these things.

  4. biohazard

    i think you can do it with a GPARTED LIVE CD, easily. You don’t need to use linux terminal. By the way, you need to backup your system before shrinking. so it’s risky you see. In the newer versions of linuxes (but gnome based, so not kde) the CD includes gparted and you can use dual boot ability;)

    • james

      Excellent tip. Looks like gparted has heaps of features and would, as you say take away the need to use the command line
      GPARTED Features

  5. Like Most people

    If you are afraid to type (command line) then you should not use a computer, sorry.

    thanks for the info James!

    • admin

      Hey I have moved to a Dreamhost VPS and I think the website is using too much RAM and getting the VPS killed by VServer.

      Which is really strange because my ‘usage’ in the DH control panel is averaging around a 100 MB RAM. Weird

  6. ryan

    Hi James. I got to step 11 and then wasn’t sure how to proceed. The fdisk /dev/sda command didn’t work and I wasn’t sure why step 11 says to delete the partition, since the tutorial is not for removing a partition but for resizing it to make room for an additional partition. So there must be something I’m not understanding there. I’m not sure what running fdisk /dev/sda was supposed to achieve, so I don’t know what if anything to do in its place. I realize this is an old tutorial by now, but maybe it can still work? Thank you

    • Ged

      The reason you’re going to delete a partition (/dev/sda2 in this case) is that you’re then immediately going to create two partitions (/dev/sda2 and /dev/sda3 in this case). The one original partition is replaced by two smaller partitions using up the same space on the disc. It doesn’t actually spell that out in the write-up. Is that any clearer?


Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…