Primary and Logical Partitions on MBR Disk
I recently installed a Linux distro to a hard disk that was initialled for MBR partitioning. My main interest at this point was to test whether the 'home-made' external drive (internal 3.5" drive in an enclosure) actually worked, so I didn't bother too much about the finer details of partitioning, simply creating the root, swap and home partitions as primary ones.
A few days later, I decided to install a second distro, and created the first partition as primary. Knowing the basic rule that the maximum number of primary partitions allowed on such a disk is four, I anticipated that there would be issues if I tried to create another such partition, but went ahead anyway, just to see what happened. Needless to say, the remaining free space was then labelled as 'unusable'.
I then restarted the second installation, with the intention of creating the partitions as 'logical'. I still anticipated a problem, as from what I had read logical partitions had to be enclosed within an 'extended' partition and I had no idea how to create one of those. Nonetheless, I proceeded to individually create the three partitions and designate them as 'logical'. To my surprise, the installation proceeded completely smoothly, and the distro (Ubuntu Mate 32 bit) was fully operative on the HDD a few minutes later. The Grub bootloader also worked properly, giving access to both Ubuntu and the other distro (Antix).
Could anyone perhaps explain to me how this works? I can only assume that the Ubuntu installation process created an extended partition automatically. Or does the extended partition business only apply to Windows?
Ichinin
Veteran

Joined: 3 Apr 2009
Gender: Male
Posts: 3,653
Location: A cold place with lots of blondes.
Generally you need something in the MBR (Master Boot Record) that allows you to chose what to boot. After that there are partitions on the drive that can be activated to boot from using the bootloader.
In Windows you have primary partitions (of one can be active at a time, the one that is booted from at first). Then there are a extended partition which there usually is just one (large one) that can be used to create logical partitions in, of any size at your discretion, like with primary partitions.
On some systems there are bootpartitions created by the manufactorer (compaq at least did have these a while ago, called F10 partitions) instead of having a Bios). There also exists HPA (Host Protected Areas) and DCO (Device Configuration Overlays) but these are usually hidden from the user, though there are ways to use them.
On linux, there are other boot systems that are used by the boot process, like LILO (Linux Loader) and GRUB to boot the system, and yes, they can have support for Booting Windows.
Unlike Windows, Linux (and most other Unix like systems) have a partition known as a Swap partition, this is basically "Virtual Memory" that the system uses to "swap down" programs from memory onto when you switch to other applications. Windows has this too, but it is a file located on the filesystem called pagefile.sys that resides in the root directory of the boot drive and it's flagged as hidded.
Partitions can be resized with tools like gparted, but my real recommendation to all this is to use a virtual machine to run your experiments on, like VirtualBox, Virtual PC (both are free) or VMWare products - VMWare products like Workstation costs a bit, but an older license is usually cheap if you can get one.
There is also VMWare VSphere (free, but require a server hardware to run and host Virtual machines on it) and a also separate PC to access them.
_________________
"It is far better to grasp the Universe as it really is than to persist in delusion, however satisfying and reassuring" (Carl Sagan)
Thanks for the reply, Ichinin. I've no experience of virtual machines or emulators , though they do seem to be an increasingly popular way to run Linux systems these days as opposed to dual booting and the like. I did use Gparted to examine the external drive I referred to in the original post, and the logical partitions of the Ubuntu installation are shown within an extended partition, which must have been created automatically, as I certainly didn't actively set it up.
A maximum of four primary partitions can be created. However, Logical partitions exist inside a primary one, which is then called an "extended partition". Logically, an extended partition can be seen as a virtual hard drive, with the same structure as an actual one (only better). This allows you to make logical partitions inside it as if it was an actual drive. Something like this:
_________________
“For small creatures such as we the vastness is bearable only through love.”
―Carl Sagan
You can have up to four primary partitions; you will then effectively have four logical partitions as well. Think of a logical partition as anything you can format and give a volume label (&/or in the FAT/NTFS world, a drive letter).
Extended partitions are just a special type of primary partition that contains an extra table to keep track of the additional partitions it can contain. In order to use an extended partition for data, though, you must have at least one logical partition. So, think of an Extended partition as a special primary partition that mimics a separate hard drive ('cause that's exactly what is happening).
_________________
“For small creatures such as we the vastness is bearable only through love.”
―Carl Sagan