Do I only need one swap partition for multiple Linux distros? (and other questions)

17,125

do I need to have a swap partition for each distro or can LFS use the swap partition I already have?

As goldilock says, unless you are hibernating (suspend to disk), yes. Otherwise no, because you could overwrite swap of a hibernated system - either it's saved state or the part that was used as regular swap at suspend time.

If so, would the swap partition have to be a primary partition, or does it not matter?

No, it doesn't matter at all. You can use swap in file on a regular filesystem, if need be (there is a small overhead, but it's also more flexible). You can even swap to NFS, if you're bold enough.

On the other hand, if you ran Windows 7 on the machine, chances are you have enough memory not to need swap at all under normal circumstances - even with "just" 2GB RAM you can do a whole lot of stuff without swap (basic desktop environment will use ~200MB). Not that swap would be unnecessary, but the need for it these days is much smaller then 10 years ago.

since deleting Windows 7 (sda 1-3), my Linux partitions are still numbered 5-7. If I create a new partition, will it be called sda1?

Since the disk is using the MBR partitioning scheme, the numbers, all logical partitions will have number 5 and higher. Unless you expand the extended partition that contains the logical ones, the only remaining space is likely available only for primary partitions, which will be numbered 1-3, provided the extended partition has number 4. See wiki on MBR for more details.

Is there any practical difference between a primary and a logical partition?

Not these days. BIOSes usually weren't able to boot from logical partitions (because they only read the MBR). Today the bootloaders usually know how to do this, so the only thing BIOS does in the system loading process is to read the bootloader trampoline from MBR (or boot sector in a primary partition) and that takes care of everything else by first loading rest of the bootloader, which in turn loads the kernel.

is an extended partition just a primary partition that contains logical partitions?

Yes, you can view it as such with a tiny bit of abstraction - it behaves as such, but the partition metadata is stored differently (as a linked list instead of an array with 4 elements which is what MBR is). As for question in the comment - yes you can only have one extended partition. But once you finalize your setup a bit (or even earlier), you might want to switch to GPT. It might even be possible to do it non-destructively (depends on the exact partitions layout).

Share:
17,125

Related videos on Youtube

Korgan Rivera
Author by

Korgan Rivera

Updated on September 18, 2022

Comments

  • Korgan Rivera
    Korgan Rivera over 1 year

    I have Linux Mint 14 installed as my only OS. I have one extended partition containing /swap, / and /home, and I have some unallocated space on my drive.

    I'm guessing that Mint decided to put this all on an extended partition instead of three primary partitions.

    So I want to build Linux From Scratch using some of my unallocated space. My first question is, do I need to have a swap partition for each distro or can LFS use the swap partition I already have? If so, would the swap partition have to be a primary partition, or does it not matter?

    Is there any practical difference between a primary and a logical partition?

    A question about definition: is an extended partition just a primary partition that contains logical partitions?

    Finally, since deleting Windows 7 (sda 1-3), my Linux partitions are still numbered 5-7. If I create a new partition, will it be called sda1?

  • Korgan Rivera
    Korgan Rivera over 11 years
    That makes sense. I read that you can only have one extended partition. Is that true?
  • peterph
    peterph over 11 years
    @KorganRivera I've elaborated the answer a bit more.
  • Korgan Rivera
    Korgan Rivera over 11 years
    Thanks. :) That answers all my questions. It sounds like MBR limits me. If I wanted a dozen partitions, it just can't happen.
  • peterph
    peterph over 11 years
    @KorganRivera yes, you'd have to use GPT (or another partitioning scheme) for that.