Re: Physical position of swap partition on the disk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Nov 30, 2020, at 02:35, Nicolas Kovacs <info@xxxxxxxxxxxxx> wrote:
> 
> Yesterday while installing a fresh CentOS server, I wondered how big of a deal
> the physical position of the swap partition on the disk is.
> 
> Here's an example of a simple MBR partitioning scheme on a legacy BIOS machine
> with a 60 GB SSD:
> 
>  * /dev/sda1: 500 MB /boot ext2
>  * /dev/sda2: 4 GB swap
>  * /dev/sda3: 55 GB / ext4
> 
> In the old (Slackware) days, I created the partitions manually using fdisk.
> 
> Now when I do something similar in Anaconda, I have to reason in terms of mount
> points. So in a similar order I create the /boot partition, the swap partition
> and the root partition.
> 
> What happens here is that Anaconda will always invert the root and swap
> partitions and put the swap partition at the end of the disk. So my setup looks
> like this:
> 
>  * /dev/sda1: 500 MB /boot ext2
>  * /dev/sda2: 55 GB / ext4
>  * /dev/sda3: 4 GB swap
> 
> I'd be curious to know what's the reason behind this, and if this kind of
> configuration detail is really significant.

When most of us had storage on rotational storage, the fastest, lowest latency access was close to the physical center of the disc, which corresponds to the start of the disk.  You’d want swap to be highly responsive in case it was used for active processes.

Now, SSDs don’t have the same physical characteristics, so it doesn’t matter. Also, cloud storage and virtual machines don’t even have real hardware.  

The partitioning is handled by different code starting in el7, and this seems to be the logic built in.  I feel like it was written to assume that root and swap are on LVM.  When it comes to resizing file systems, it might make sense to put the root ext4 at the end of the disk, so it is actually counterproductive to put swap at the end. 

--
Jonathan Billings <billings@xxxxxxxxxx>

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux