LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-02-2003, 05:25 AM   #1
britcoms9
LQ Newbie
 
Registered: Sep 2003
Posts: 7

Rep: Reputation: 0
logical partition to a primary one


How do I convert a logical (extended) partitition to a primary one, without loosing all my data ?

I not to get Windows running again.

fdisk -l

DEVICE BOOT Id System

/dev/hd1 * f Win95 Ext'd (LBA)
/dev/hd2 82 Linux Swap
/dev/hd3 83 Linux
/dev/hd5 7 HPFS/NTFS
/dev/hd6 7 HPFS/NTFS
/dev/hd7 7 HPFS/NTFS
 
Old 09-02-2003, 09:33 AM   #2
fancypiper
Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 57
Are you wanting the disk space back for Windows? If so, you will lose all information on the Linux partitions.

# How do I uninstall Linux completely and keep/use Windows only?
How to Remove Linux and Install Windows 2000
How to Remove Linux and Install Windows XP
You can remove lilo from the mbr with
/sbin/lilo -u
You can remove grub or lilo from the mbr by booting with a Windows 98 boot floppy (at the prompt, type fdisk /mbr), or by using the Windows XP Recovery Console or the Windows 2000 Recovery Console
 
Old 09-02-2003, 09:38 AM   #3
quatsch
LQ Addict
 
Registered: Aug 2003
Location: New York, NY
Distribution: gentoo, gentooPPC
Posts: 1,661

Rep: Reputation: 47
fancypiper: the trouble is that britcoms9 has windows installed on a logical partition and hence cannot boot it (I'm curious as to how windows got to be on a logical partition in the first place, but that's another story). What he needs, if possible, is to convert a logical partition to a primary one.
 
Old 09-02-2003, 10:05 AM   #4
fancypiper
Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 57
I don't know of any way to do that. I would think that would be impossible as the logical partitions are part of the extended partition.

Back up your important data, zero out the drive and re-partition and re-install is the only way I am aware of.

Someone didn't follow the standard advise of putting windows on the first primary partition of a drive.

# Partitioning
Linux Partition HOWTO
Rute - Partitions, File Systems, Formatting, Mounting
 
Old 01-20-2008, 06:46 PM   #5
bobpaul
LQ Newbie
 
Registered: Aug 2005
Posts: 14

Rep: Reputation: 0
Quote:
Originally Posted by fancypiper View Post
I don't know of any way to do that. I would think that would be impossible as the logical partitions are part of the extended partition.
I know this is a really old thread, but it came up on Google every time I tried to search for solutions to this problem.

One can use parted or its GUIs (qtparted or gparted) to resize, shrink, and move partitions. Unfortunately, unlike Partition Magic, neither qtparted nor gparted off the option to convert a partition. Also, at this time parted can't change the start point of some partitions (reiserfs, ntfs, etc.)

As an example, here's the problem I had:
(it's important to use the -u option as sectors are far more accurate than cylinders.)

Code:
sudo fdisk -l -u /dev/sda

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders, total 156301488 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x3a8ad18e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63    16370234     8185086    7  HPFS/NTFS
/dev/sda2        16370235    47825504    15727635    7  HPFS/NTFS
/dev/sda3        47825505    70894844    11534670   83  Linux
/dev/sda4        70894845   156296384    42700770    f  W95 Ext'd (LBA)
/dev/sda5        70894971   152231939    40668484+  83  Linux
/dev/sda6       152232003   156296384     2032191   82  Linux swap
What I want to do is convert sda3 to a logical partition by moving the start point of the extended partition (sda4).

To do this, I first have to either shrink sda2 slightly or shrink and move the start point of sda3 slightly. One needs to do this as the start point of the extended partition cannot be the same as the start point of a logical partition inside. While no information is written at the start of an extended partition, we still need a small buffer. I chose to shrink sda3 by 10MB and move the start point. This resulted in the following:

Code:
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63    16370234     8185086    7  HPFS/NTFS
/dev/sda2        16370235    47825504    15727635    7  HPFS/NTFS
/dev/sda3        47841570    70894844    11526637+  83  Linux
/dev/sda4        70894845   156296384    42700770    f  W95 Ext'd (LBA)
/dev/sda5        70894971   152231939    40668484+  83  Linux
/dev/sda6       152232003   156296384     2032191   82  Linux swap
I now have a gap between the end of sda2 and the start of sda3. This will let me start an extended partition in this space.

I'll now open up fdisk (fdisk -u /dev/sda) and delete all partitions 2 through 6. This is safe because I'm only deleting the record of where the partition is located and not the data contained in the partition. As long as I use the exact same start and stop points when I create new partitions, all the data will still be there. Here's my new partition map:

Code:
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63    16370234     8185086    7  HPFS/NTFS
/dev/sda2        16370235    47825504    15727635    7  HPFS/NTFS
/dev/sda3        47825505   156301487    54237991+   5  Extended
/dev/sda5        47841570    70894844    11526637+  83  Linux
/dev/sda6        70894971   152231939    40668484+  83  Linux
/dev/sda7       152232003   156296384     2032191   82  Linux Swap

REMEMBER: when using fdisk, no changes are made until you issue the w command to write the changes. If you think you made a mistake, press Ctrl+C or use q to quit without saving the changes.

When creating logical partition 5 (what used to be called sda3). You'll notice there's now some space between the the start of the Extended partition and the first logical partition (what used to be /dev/sda3). There's also some space between the new sda5 and sda6 (which used to be sda5) that was previously taken up by the extended partition. We can recover this space later by running gparted again.

After resizing and moving what's now sda5 (and was origionally sda3) in gparted, I was left with:
Code:
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63    16370234     8185086    7  HPFS/NTFS
/dev/sda2        16370235    47825504    15727635    7  HPFS/NTFS
/dev/sda3        47825505   156301487    54237991+   5  Extended
/dev/sda5        47825568    70894844    11534638+  83  Linux
/dev/sda6        70894971   152231939    40668484+  83  Linux
/dev/sda7       152232003   156296384     2032191   82  Linux Swap
Your problem is actually easier.

For your problem, you would have wanted to do something similar. You have an extended partition that fills the entire drive. What you need is for the extended partition to stop at the end of partition partition 3 so that your 3 NTFS partitions are primary instead of logical.

Use fdisk -u -l to find the start and stop points of all of your partitions. Open 'fdisk -u /dev/hda' and delete all of your partitions. Now, create an extended partition that starts where the old hda1 did, but ends where the old hd3 did. Now create locical partitions with for hd2 and hd3 with the same start and end points as before. Finally, create primary partitions for hda5, hda6, and hda7 using the same start and stop as you previously had.

Try mounting your new partitions. If it doesn't work, simply open 'fdisk -u' again, delete all of your partitions, and recreate them exactly as 'fdisk -u -l' showed you earlier. This will at least restore you to where you were at the start.

Remember to always have a printout of 'fdisk -l -u' save somewhere before you start messing with partitions.

Last edited by bobpaul; 01-20-2008 at 07:07 PM. Reason: Formatting
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Primary or Logical? Brahl Linux - Newbie 1 01-29-2005 09:50 AM
Primary, Logical or Extended partition? mrpc_cambodia Linux - General 3 09-12-2004 11:10 PM
make logical partition primary SharpyWarpy Linux - General 2 06-01-2003 08:15 AM
Primary or Logical partition ? infernal Linux - Software 3 10-16-2001 05:16 PM
logical or primary partition Socrates Linux - Software 1 02-25-2001 03:50 AM


All times are GMT -5. The time now is 02:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration