LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-19-2010, 08:56 AM   #1
bubuntu
Member
 
Registered: Nov 2009
Location: Huntsville, Al
Distribution: Ubuntu
Posts: 34

Rep: Reputation: 2
How can I change an extended partition with 3 logical partitions to 3 primary


I'm new to linux and this forum so if this post is is the wrong forum please move it by all means.

Here's my problem. I installed Ubunbtu 9.10 and have partitions on my SATA drive as shown in the table below listed in-order of increasing sector number which I assume is how the partitions are placed physically on the disk. The table is from GParted output:

Partition-----File system---Size--------Flags
/dev/sda2------extended-----564GB-----lba
--/dev/sda6----ext4----------525GB------------Ubuntu installed here
--/dev/sda7----swap----------9GB
--/dev/sda5----ntfs----------29GB
/dev/sda1------ntfs----------32GB-------boot

What I want to do make sda5,6 and 7 be primary partitions with sda6 the boot partition. All without destroying my Ubuntu installation on sda6 since I have spent considerable time tweeking and installing various software. At the very least I want to reformat sda1 to ext4 without messing up the boot info.

The reason being i want to use sda5 and sda1 to install other linux distros. I think these partitions will have to be made extended so each install can have its own swap partition.

I'm assuming it's possible to have more than two operating systems on one drive and be able to boot to any one of them.

Thanks
 
Old 05-19-2010, 09:06 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by bubuntu View Post
What I want to do make sda5,6 and 7 be primary partitions with sda6 the boot partition.
It is a very bad idea to demand a solution that fits what you think is the answer.

Describe (properly) what you want to achieve, and ask for means of achieving it. Will cause much less angst - on both sides.

Edit: sorry, I was in a cranky mood last night.

Last edited by syg00; 05-20-2010 at 03:16 AM.
 
Old 05-20-2010, 07:50 AM   #3
bubuntu
Member
 
Registered: Nov 2009
Location: Huntsville, Al
Distribution: Ubuntu
Posts: 34

Original Poster
Rep: Reputation: 2
Hmm, point taken. I did propose a solution to a perceived problem. Maybe what I have is OK it just seems messy. Also my ultimate goals are not clear at this point. I thought if I "cleaned" up the partition structure I would gain some flexibility when I do have clear goals. So for the sake of argument my goals are my proposed "solution". I'll restate:

I have an extended partition containing 3 logical partitions which are; my Ubuntu installation, a swap partition and an empty partition. I want to make these into 3 primary partitions with one containing Ubuntu being the active boot partition.

Is this possible and not destroy my installation? If so how do I do it?
Is it a bad idea? Do you have a better idea?

It seems to me that having the active boot partition being the last partition is restrictive since I can't delete it or grow it larger without doing something with the boot info. Am I wrong?

Didn't see your edit -- no offence taken. I've been cranky once or twice myself.

Last edited by bubuntu; 05-20-2010 at 08:08 AM. Reason: Didn't see edit on response wanted to comment
 
Old 05-20-2010, 08:01 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Linux doesn't require any primary partition - nor the "boot" flag. Online guides that state otherwise are probably written by people that aren't even aware there are alternatives to Redmond.
The output above is at best margin in usefulness - try this from a Ubuntu terminal
Code:
sudo fdisk -l
And no, there is no easy way to convert logical to primary - nor any need probably.
 
Old 05-20-2010, 08:22 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
The gparted output does not give the full picture; it does not allow us to see where any fee space may be. Can you post the output of fdisk -l ?

Do you boot Windows from /dev/sda1?

A very flexible arrangement is to have a small (~200 MB) /boot primary for the files necessary to boot each Linux OS (or to "chain load" the Windows boot system). The other file systems for the Linux OSes can then be in extended partitions as now.

You do not need a separate swap partition for each Linux OS unless you want to be able to hibernate, boot another one and then un-hibernate.

For maximum flexibility, LVM is great. It allows you to treat disk space in partition(s) on disk(s) assigned to LVM as a pool which can be used to make virtual partitions. Many people do not think the complexity of LVM is worth the benefits on a workstation.

AFAIK it is not possible to change a logical partition (one within an extended partition) into a primary partition. The only option is to create a primary and copy the logical to it -- as a file system copy unless both partitions are the same size in which case it can be done as a partition copy.

Similarly AFAIK it is not possible to change the size of an extended partition while it contains logical partitions.

A backup is prudent at all times but especially when changing partitions.
 
Old 05-20-2010, 08:23 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
You could---in principle---change a logical to a primary, but it would involve some low-level editing and is probably not worth the trouble.

Delete, the partitions you don't want, and then make new ones. (After of course backing-up all of your data)
 
Old 05-20-2010, 08:26 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by syg00 View Post
Linux doesn't require any primary partition - nor the "boot" flag. Online guides that state otherwise are probably written by people that aren't even aware there are alternatives to Redmond.
+1 to that although there was an LQ thread recently about a BIOS that wouldn't boot unless there was a partition with a boot (active?) flag. It was one of the brands that does things in non-standard ways, perhaps a Gateway.
 
Old 05-20-2010, 08:27 AM   #8
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Similarly AFAIK it is not possible to change the size of an extended partition while it contains logical partitions.
The size of the extended partition does not define any space on the disk. I think it only serves to interact with partition editors. I think you CAN change it--regardless of what the logicals are. The issue is that typical partition editor does not allow it to be changed---but I'm pretty sure some do.
 
Old 05-20-2010, 10:56 PM   #9
bubuntu
Member
 
Registered: Nov 2009
Location: Huntsville, Al
Distribution: Ubuntu
Posts: 34

Original Poster
Rep: Reputation: 2
I see I have some homework to understand what's going on here.
Quote:
Originally Posted by syg00 View Post
Linux doesn't require any primary partition - nor the "boot" flag. Online guides that state otherwise are probably written by people that aren't even aware there are alternatives to Redmond.
Could you refer me to something which properly explains what happens during the boot process. All my research so far indicates an active boot partition is required which must be a primary partition. I'd like to understand this.


Quote:
Originally Posted by catkin View Post
Can you post the output of fdisk -l ?
Disk /dev/sda: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xb576f409

Device Boot Start End Blocks Id System
/dev/sda1 * 73648 77825 33559785 7 HPFS/NTFS
/dev/sda2 1 73647 591569496 f W95 Ext'd (Do you boot Windows from /dev/sda1?LBA)
/dev/sda5 69758 73647 31246393+ 7 HPFS/NTFS
/dev/sda6 1 68534 550499260+ 83 Linux
/dev/sda7 68535 69757 9823716 82 Linux swap / SolarisDo

Partition table entries are not in disk order

Disk /dev/sdb: 1014 MB, 1014497280 bytesDo
65 heads, 32 sectors/track, 952 cylinders
Units = cylinders of 2080 * 512 = 1064960 bytes
Disk identifier: 0xc3072e18
Do you boot Windows from /dev/sda1?
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 953 990704 6 FAT16
Partition 1 has different physical/logical endings:
phys=(967, 64, 32) logical=(952, 39, 32)

Quote:
Originally Posted by catkin View Post
Do you boot Windows from /dev/sda1?
No this partition and /dev/sda5 were left over from when I used this drive to back up my WinXP laptop drive before making it a dual boot XP and Ubuntu. Neither of these had the system on them theye were just used for copies of mydocuments. I left them to make it easy to copy the files to linux. I was going to delete them after doing so. That's when I discovered /dev/sda1 was a "boot" partition and so ended up posting this thread.

Quote:
Originally Posted by catkin View Post
For maximum flexibility, LVM is great.
I looked a LVM and got really confused so I sort of forgot about it. I will take another look though.
 
Old 05-20-2010, 11:16 PM   #10
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Quote:
Originally Posted by syg00 View Post
Linux doesn't require any primary partition - nor the "boot" flag. Online guides that state otherwise are probably written by people that aren't even aware there are alternatives to Redmond.
Could you refer me to something which properly explains what happens during the boot process. All my research so far indicates an active boot partition is required which must be a primary partition. I'd like to understand this.
If the articles are from the www (wonderful world of windows), then that's the right answer.....

How Linux boots (simplified--assuming the older GRUB):
1. BIOS looks for boot code in the MBR of devices that it is told to check--eg the hard drive. Assuming it finds boot code, it passes control to it. (This step is the same for Windows and Linux.)

2. The Linux boot code (GRUB) is "hard-coded" to look for the /boot/grub/menu.lst file on a specific partition.** It goes to that file, finds the options listed there, and displays them.

3. The operator selects an option and GRUB then transfers control to the selected kernel (and optionally the associated initrd file)

All this happens without regard to boot flags or the type of partition.

**When installing grub, this partition is identified in the "root" statement.
 
1 members found this post helpful.
Old 05-20-2010, 11:31 PM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Thanks for the extra information.

The original PC architecture required an active primary. The BIOS would load the program from the Master Boot Record (MBR), the MBR program would read the partition table to find the active primary and then load the boot program from the active primary which would load the OS. That is still the Windows way.

Linux uses more powerful MBR programs -- GRUB or LILO -- and they do not use the active primary mechanism. There's a good description of the Linux boot process here.

Regards your options for partition changes to install another Linux: Can sda1,2 and 5 be deleted? Can sda6 be shrunk? Do you have a backup of all valued files?
 
1 members found this post helpful.
Old 05-21-2010, 01:11 AM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by bubuntu View Post
No this partition and /dev/sda5 were left over from when I used this drive to back up my WinXP laptop drive before making it a dual boot XP and Ubuntu. Neither of these had the system on them theye were just used for copies of mydocuments.
So you are using grub - booting from /dev/sda6; hence it is not using a primary partition nor the boot flag. Evidence from your own system.

I don't know a good lucid online reference for the Linux boot sequence - other than the source of course. Always the ultimate reference in an open source argument/discussion.

That partition table is "interesting". My suggestion, from a liveCD delete /dev/sda1 and /dev/sda5 if you no longer need NTFS. Then enlarge the expanded partition to occupy that freed up space at the "end" of the disk. Being at the end of the disk, this won't cause any problems with your current boot - luckily.
Create logical partitions as needed for new Linx installs. They can reuse that swap, but it can cause issue for systems like Ubuntu that rely (these days) on UUID. Perhaps allow each new system to create a new small swap - unnecessary, but easiest if you are new to this.

Last edited by syg00; 05-21-2010 at 01:14 AM.
 
1 members found this post helpful.
Old 05-21-2010, 02:09 AM   #13
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by bubuntu View Post
I'm new to linux and this forum so if this post is is the wrong forum please move it by all means.

What I want to do make sda5,6 and 7 be primary partitions with sda6 the boot partition. All without destroying my Ubuntu installation on sda6 since I have spent considerable time tweeking and installing various software. At the very least I want to reformat sda1 to ext4 without messing up the boot info.
Forget it. Primary partitions atre listed in the MBR partition table. Logical partitions are listed somewhere else. In theory you -could- change logical partitions into primaries by copying the data from the logical partition table into the MBR partition table. But this operation is highly dangerous (for your data). Unless ytou are a Kamikaza pilot, I would not recommend it. Betting on the '0' in roulette is safer...

As other people explained: Linux does not require a partitrion to be bootable and primary. Linux only needs to know in which partition it can find a boot image. Only MS products require a primary partition with the BOOT flag set. This also remains from the late 80's when hard disks were a luxury add-on for a twin HighDensity floppy disk system.

Originally, you could make 4 partitions on a disk. On a 20 MB disk that was 3 more than most users required. Later, MS invented the logical partition when it found out that 4 partitions on one disk might be a little low. So ONE primary partition was converted into a container partition called an 'extended partition'. In this container fitted 'logical drives' and this name already shows what the intentions of M$ were.
Primary partitions were used to add full operating systems to (then) big HD's of 40 MB and up. You could easily install MS-DOS, CPM86 and some proprietary Siemens DOS for PLC programming. To switch between each DOS you would start up fdisk to change the BOOT flag for the required partition and then reset te computer. Yes, things were better in the past..

There may be a chance that the Paragon Partition Manager may be able to do what you want. Paragon is safe. But you have to buy it so for many Linux users this is a definite no-no. I have a coipy so I am not a no-no linuxer.

Quote:
The reason being i want to use sda5 and sda1 to install other linux distros. I think these partitions will have to be made extended so each install can have its own swap partition.

I'm assuming it's possible to have more than two operating systems on one drive and be able to boot to any one of them.

Thanks
Mount an extra HDD in your machine and make just 1 extended partition. Create as much 10 GB partitions as the total disk capacity allows for. Then use these partitions as mount points for the various distro's on test. ALWAYS use a new partition for /home in EVERY distro.

One swap partitions will do for all Linuxes. NEVER have multiple swap partitions active. As soon as one swap partition is filled and the second one is taken into service, system performance goes down like a brick. Massive swapping between memory, swapspace-1 and swapspace-2 will bring down the performance of your machine upto 80%.

The fact that Linux can do just about any thing, for free, for safe and for all, does not mean it can do any conceivable thing at no risk to the user. You learn by doing. Todayt you have learned one of the limitations of the system that can do all for free...
 
1 members found this post helpful.
Old 05-21-2010, 03:02 AM   #14
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by fruttenboel View Post
ALWAYS use a new partition for /home in EVERY distro.
That is debatable.

It is true that many of the config files in each /home/<user name> directory are distro-specific or at least package+version+release-specific and hence unwise to use them for more than one distro. But these files do not take up much space so can easily be accommodated in the distro's / file system, at least on SOHO systems with a handful of users.

There are no right answers, only choices. Personally I prefer a single, non-LVM file / system including /usr and /home. For personal data which the user(s) want to have available regardless of which OS is booted I prefer a separate file system. On single user systems it is mounted at /home/<user name>/data and on multiple user systems /home/<user name>/data is a symlink to the individual user's subdirectory on the data file system.
 
Old 05-21-2010, 04:17 AM   #15
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by catkin View Post
That is debatable.
In the case you give, it is open to debate.

In the case you have aquiered a taste for Linux. and you want to upgrade to a higher version, it is fine to know that you can leave your data as is. In most cases the dot files won't do the tricks anymore they used to do, but your data files are saved and can be copied easily.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What are Primary,logical and extended partition?? almon General 4 10-30-2007 12:33 PM
[SOLVED] Safety: Primary Partition and Extended (Logical) Partition MBA Whore Linux - Security 11 01-03-2007 02:05 PM
Swap partition...primary or extended|logical? mr.v. Linux - Newbie 1 07-06-2006 03:30 PM
Mount primary prtition. And first logical drive in an Extended DOS partition zillah Solaris / OpenSolaris 5 01-08-2006 05:16 AM
Primary, Logical or Extended partition? mrpc_cambodia Linux - General 3 09-12-2004 11:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:39 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration