Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I did not want to use up my last primary partition so I created my new swap partition as an extended partition. However, somewhat redundantly, it is created under sda4. This makes little sense as sda5 is the only partition in ext4. Why is it forced to be nested? Why can it not be created at the same level as the primary partitions, but it must be made a "child" partition? Do you understand what I am saying? This is an unnecessary distinction, as it is the only partition occupying the extended partition. I'd rather my swap be called sda4 and not be subordinated as sda5...

enter image description here

share|improve this question
add comment

3 Answers

You're mixing up logical and extended partitions. Go and read about PC partition structure.

You can have up to 4 primary-or-extended partitions, and at most one of it may be extended¹. An extended partition is a container for logical partitions¹. A primary partition or a logical partition is a container for a filesystem (or an LVM volume or some swap space or a BSD partition or other kind of volume that isn't a PC-style partition). The swap partition is nested in the extended partition because that's what it means to be a logical partition.

In your case, making the swap partition a logical partition rather than a primary partition won't change anything regarding the primary partition quota, since you don't otherwise have an extended partition. If you wanted to free one primary partition slot, you'd need to have at most two primary partitions in addition to one extended partition.

Note that Linux doesn't care whether it's installed on primary or logical partitions. You could make both your system partition and your swap partition logical. Or you could create one partition that's an LVM physical volume and create two LVM logical volumes, one for the root filesystem and one for swap. LVM gives you easier management within Linux at the expense of other OSes seeing the LVM physical volume as an opaque blob.

¹ That's not strictly required, but you'd have to go through hoops to circumvent that, and your fellow administrators will curse you.

share|improve this answer
add comment

Nothing says that it has to be. In your configuration, the swap partition is at the end of the disk, which is covered by the extended partition space. On my Ubuntu system, I have my root filesystem in the first 60GB partition, then a 4GB swap partition, then the extended partition. It depends on how you wish to have the system set up.

The architecture of the drives being used these days has a limitation of only three (3) physical partitions and one extended partition. Since you have two ntfs and one ext4 partition, any additional partition (swap) would need to go inside the extended partition.

share|improve this answer
    
The limitation is from the msdos partition table, not the drives, and the limit is 4 primary partitions. If you use a primary partition as an extended partition, that leaves 3 left. If you get rid of the extended partition then you can use the 4th partition for the swap. –  psusi Oct 22 '11 at 1:40
add comment

Unix is all about transparency and power and programmer's convenience, and not so big on making things look nice if it sacrifices those things even a little bit. So if there's a partition entry on the disk, there's a partition device to go with it. (The only exceptions are empty partition slots, but then, since there's no reserved space, there's nothing to write to.)

So when dealing with DOS partition tables, Linux reserves partition numbers 1 through 4 for the primary partitions, leaving 5 and up for logical partitions. Because the structure of the partition tables make it easier that way, because it's nice to know you're working with a primary partition if the number is 1-4, and because who am I to know that you won't want to write directly to the extended partition at some point?

(You think that's bad... Sun systems reserve partition 2 as a "whole disk" partition. Partition 2 must reserve the entire disk, and it must overlap with the other partitions on the disk.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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