6

Currently I have both Windows XP and Windows 7 installed as dual-boot. I've been wanting to remove my XP installation for a long time (was waiting to buy an external HDD to backup the data) to get some more space in my Windows 7 partition, since I'm running out of it.

Here are the partitions I have in my drive:

/sda1 - Primary - Windows XP - 150GB
/sda2 - Extended
--/sda5 - Logical - Data - 99GB
--/sda6 - Logical - Windows 7 - 50GB

They are shown like they are physically ordered in the HDD (from the left to the right, i.e sda1 comes first, then sda2, etc).

I backed up all of my data, and used GParted (from an Ubuntu LiveUSB) to try and:

  • Delete the whole partition that has Windows XP
  • Make my Windows 7 partition a primary one, so my system can boot from it
  • Extend the Windows 7 partition (that has 50GB) with the 150GB unallocated space left by the deleted Windows XP partition, so my Windows 7 partition ends up with 200GB

However, I tried using GParted and couldn't figure out how to do it. I'm not really sure how to change the sda6 partition into a Primary one, and put it in such a way so it can be extended with the space left from sda1 (after deletion). I'm fine with leaving sda5 as a logical partition. As far as I've tried, the only thing I can do after deleting the sda1 partition is extend sda2, which is not exactly what I want.

Thanks

EDIT: I also have the Windows 7 installation disk, so if the MBR table gets modified I can repair it from it.

  • 1
    Easiest way with GParted is to delete the Primary Windows XP Partition, then extend the logical partitions to use what the XP Partition used. Don't worry about converting them from Logical to Primary. – Lawrence Dec 14 '13 at 14:56
  • So there's no problem with there being no primary partitions? Also I'd take it there wouldn't be any issue with the partition extensions needed to increase the size of my Windows 7 partition, right? Basically, extending the Data partition to the left, then shrinking it from the right, then extending the Win7 partition to the left, wouldn't cause data loss and would work, right? – gonzaw Dec 14 '13 at 22:42
  • Nope, no problem. And yep, no issues there. Although I would definitely take a backup of the drive before you do anything just in case something does get corrupted. – Lawrence Dec 15 '13 at 7:38
  • Hello. I tried doing this, but yes, I can't boot into Win7 anymore. However, I tried using the Win7 disk, and it can't find my Win7 installation (to repair). I read that apparently I need to set my Win7 partition as active for it to find it, and the only way to do that is to set that partition as Primary (while I have it as logical as described above). Is that right? If so, is the only solution setting it as a primary partition? – gonzaw Dec 15 '13 at 21:32
  • Ah. Forgot you needed a primary partition to mark as bootable...You can have an empty partition as the active one, and then have everything else in the normal partition. Make a ~10 MB primary partition at the beginning and you should be right – Lawrence Dec 16 '13 at 0:49
4

You can use fixparts, a useful utility that exists in Linux, Windows, Mac OS and FreeBSD. You can download from this Web page. You can also find extensive documentation here.

Since you already have an Ubuntu live stick, I suggest you boot from that, choosing Try Ubuntu without installing. I cannot remember whether fixparts is already on the live; in any case, open a terminal and issue

   man fixparts

If you get a reply fine, otherwise you can install it by means of

   sudo apt-get install gdisk

(thanks to @RodSmith for pointing this out).

Now I will assume your boot stick is /dev/sdb, while your fixed disk is /dev/sda. If it is not so, please change what follows accordingly.

Mount briefly your HDD:

      sudo mount /dev/sda5 /mnt

Save the current partition table in a safe place:

   sfdisk -d /dev/sda > /mnt/parts.txt

Please remember that files on the USB stick are temporary: they are lost as soon as you turn the pc off. So you will have to save the file above on a different drive than the stick; and this is why I suggested to mount the partition above. If you need to re-load the partition table above, the command is:

  sfdisk -f /dev/sda < /mnt/parts.txt

Now unmount the partition above,

   sudo umount /mnt

and start fixparts:

   fixparts /dev/sda

And now p will print the partition table, h will print available commands, r turns a logical partition into primary partition, w writes changes to the disk.

The Tutorial referenced above explains under which conditions you can turn a primary partition into a logical one, and viceversa, but even more revealing is the follwoing table that fixparts will present you:

                                                     Can Be   Can Be
  Number  Boot  Start Sector   End Sector   Status   Logical  Primary   Code
     1      *             62      1171799   logical     Y        Y      0x07
     2               1171800      1562399   primary              Y      0x83
     3               1562462      3124799   primary              Y      0x0C
     5               3124862      3980213   primary              Y      0xAF

which presents very clearly which partition can change status logical/primary.

When done, write changes (w) to disk, reboot without the USB stick.

Edit:

Make sure your /etc/apt/sources.list contains all of the following lines:

  deb http://us.archive.ubuntu.com/ubuntu/ saucy main restricted
  deb http://us.archive.ubuntu.com/ubuntu/ saucy-updates main restricted
  deb http://us.archive.ubuntu.com/ubuntu/ saucy universe
  deb http://us.archive.ubuntu.com/ubuntu/ saucy-updates universe
  deb http://us.archive.ubuntu.com/ubuntu/ saucy multiverse
  deb http://us.archive.ubuntu.com/ubuntu/ saucy-updates multiverse
  deb http://us.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse
  deb http://security.ubuntu.com/ubuntu/ saucy-security main restricted
  deb http://security.ubuntu.com/ubuntu/ saucy-security universe
  deb http://security.ubuntu.com/ubuntu/ saucy-security multiverse
  deb http://archive.canonical.com/ubuntu/ saucy partner
  deb http://extras.ubuntu.com/ubuntu/ saucy main

This is for Ubuntu Saucy Salamander (13.10), adapt to the version you are running (precise?).

| improve this answer | |
  • 1
    The fixparts program is part of the gdisk package in Ubuntu, so sudo apt-get install gdisk should make the program available. – Rod Smith Dec 14 '13 at 17:41
  • Hi. After I use fixparts to change the logical partition to a primary one, can I then use GParted to move the partitions around? Or do I have to do everything from inside fixparts or the terminal? Also, in my case, I would just move my extended partition where Windows XP was, then move the (new) Windows 7 primary partition back, and then extend it? Would that work? Thanks – gonzaw Dec 14 '13 at 22:40
  • Hello. I tried doing this, but when I do sudo apt-get install gdisk I receive this message: E: Unable to locate package gdisk. I already deleted/moved partitions around, and I can't boot into Win7 as logical partition, so I need to turn it into a primary one I think. – gonzaw Dec 15 '13 at 21:30
  • @gonzaw I have update my reply to accommodate your concern. – MariusMatutiae Dec 15 '13 at 21:44
  • Hi. I'm running Ubuntu 12.04 LTS. Can I copy+paste those lines you posted in my /etc/apt/sources.list file? – gonzaw Dec 15 '13 at 21:53
0

Actually your Windows 7 installation might get confused if you would successfully change it from a logical to primary partition, since that would most definitely change its partition number, and the boot loader would probably not find it anymore (maybe win7 has gotten smarter but XP sure used to choke on this). I would suggest following Lawrence advice and just removing the sda1 partition and then resizing the extended partition to account for the additional free space and then in the next step add the current free space to your data partition or move that one and then resize your OS partition.

As always with changes of this nature make sure any data you don't want to lose is backed up on and external medium.

| improve this answer | |
  • Surely if there was an MBR problem then Windows 7 can fix that in a second. I never had problems in the days of Partition Magic, moving partitions, converting partitions from primary to logical or logical to primary or whatever. Gparted seems to be ridiculously limited not offering much in the way of converting primary<->logical. – barlop Dec 14 '13 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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