How to change logical partition into primary one?
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?).
Related videos on Youtube
gonzaw
Updated on September 18, 2022Comments
-
gonzaw over 1 year
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 fromsda1
(after deletion). I'm fine with leavingsda5
as a logical partition. As far as I've tried, the only thing I can do after deleting thesda1
partition is extendsda2
, 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.
-
Lawrence over 10 yearsEasiest 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.
-
gonzaw over 10 yearsSo 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?
-
Lawrence over 10 yearsNope, 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.
-
gonzaw over 10 yearsHello. 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?
-
Lawrence over 10 yearsAh. 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
-
gonzaw over 10 yearsI ended up changing the Win7 partition to primary, as Marius described. Thanks for the advice anyways!
-
barlop over 10 yearsSurely 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.
-
Rod Smith over 10 yearsThe
fixparts
program is part of thegdisk
package in Ubuntu, sosudo apt-get install gdisk
should make the program available. -
gonzaw over 10 yearsHi. 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 over 10 yearsHello. 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. -
MariusMatutiae over 10 years@gonzaw I have update my reply to accommodate your concern.
-
gonzaw over 10 yearsHi. I'm running Ubuntu 12.04 LTS. Can I copy+paste those lines you posted in my /etc/apt/sources.list file?
-
MariusMatutiae over 10 years@gonzaw You must change saucy with precise everywhere, otherwise yes.
-
gonzaw over 10 yearsHi. It still doesn't work. Does it need to be configured further? If I restart my PC the changes will be gone, right?
-
MariusMatutiae over 10 yearsAre you sure you have a working network connection? Yes, all changes will be gone when you turn pc off. Download fixparts from this Web page: sourceforge.net/projects/gptfdisk/files/gptfdisk/0.8.8/… Get the deb package suitable for your architecture, install it with sudo dpkg -i fixparts-something-or-other.deb
-
gonzaw over 10 yearsGreat thanks, it installed correctly! I'll now try to see if I can change the partition to primary and see if this process finishes without problems
-
palerdot almost 10 yearsI came across the following warning the fixparts website mentioned in this post.
Do not use gdisk if you want to use FixParts! More than one person has made that mistake, despite explicit advice to use FixParts. Unlike FixParts, gdisk is designed to work on GUID Partition Table (GPT) disks, and it will automatically convert from MBR to GPT format. This will have the effect of fixing the problems that FixParts fixes, but in most cases, and especially if Windows boots from the disk, such a conversion is inappropriate.
Just double check the docs before attempting anything on your disk.