[SOLVED] Problem if LFS partition (MBR) not on physical sector boundary?
Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Problem if LFS partition (MBR) not on physical sector boundary?
I have been trying to get LFS going, but encountering problems. This is the 3rd time that I have started the process. I don't want to make any incorrect assumptions.
Instead of using lsblk to find my logical partition to mount, I used fdisk -l. This is the output:
Code:
root@silver:/home/bill# fdisk -l
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x1b27c934
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 372738047 372736000 177.8G 83 Linux
/dev/sda2 960210942 976771071 16560130 7.9G 5 Extended
/dev/sda3 372738048 942082047 569344000 271.5G 83 Linux
/dev/sda4 942082048 960208895 18126848 8.7G 82 Linux swap / Solaris
/dev/sda5 960210944 976771071 16560128 7.9G 82 Linux swap / Solaris
Partition 3 does not start on physical sector boundary.
sda3 was created by gPartd, and I aligned it with the Mib option.
I just wanted to confirm that there is no problem here - that is, I won't have problems further along the process with this condition.
BTW, I am using Debian 8.1, and it is loaded in sda1.
root@silver:/home/bill#Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x1b27c934
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 372738047 372736000 177.8G 83 Linux
/dev/sda2 960210942 976771071 16560130 7.9G 5 Extended
/dev/sda3 372738048 942082047 569344000 271.5G 83 Linux
/dev/sda4 942082048 960208895 18126848 8.7G 82 Linux swap / Solaris
/dev/sda5 960210944 976771071 16560128 7.9G 82 Linux swap / Solaris
Partition 3 does not start on physical sector boundary.
That's totally bizarre, since it's partition 2, not 3, that is misaligned. That misalignment doesn't matter. The only thing misaligned is the 1-sector extended partition header. With the exception of use by partitioning tools, that gets read just once when the system boots and is never written.
Thanks for the feedback. I noticed the mis-alignment of the extended partition (sda2). But I know ZERO about how MBR extended partitions work. Could it be a bug in fdisk? MBR is not used so much now, so maybe a bug crept into the software undetected during testing.
In any case, I will proceed under the assumption that this will not cause me a problem during the build.s
The warning tells you that a partition is not aligned on a physical sector boundary, i.e., a disk "hardware" sector. On a traditional harddisk, you would not run into this issue, since logical sectors are equal to physical sectors: both are 512 bytes.
Computer systems and operating systems generally assume hard-coded sector sizes of 512 bytes, and this assumption is so omnipresent that it is nearly impossible to change without hard work and global coordination.
Modern harddisks, however, use physical sectors of 2048 bytes (i.e., 8 logical sectors); you can see that in the fdisk output, on the "Sector size (logical/physical):" line. Physical disk I/O is, therefore, done in 2048-byte chunks (i.e., 8 logical sectors at a time). For optimal performance, it is generally assumed that disk partitions had better be aligned on physical sector boundaries, so that, when the start of the partition is to be read (or updated), the first eight logical sectors can be read (or written) in one operation.
The warning about the misalignment simply means that there is a partition that does not begin on a physical sector boundary (i.e., on a multiple of eight logical sectors). There's nothing really wrong with this, except that disk I/O performance may be adversely affected when misaligned data structures are to be accessed.
Due to these new developments, and to the expectations that future disks will likely use even larger physical sectors (e.g., perhaps 16, 32, 64 KiB, maybe even 1 MiB?), the generally recommended "best practice" nowadays is to align all partitions on 1-MiB boundaries (i.e, multiples of 2048 logical, 512-byte, sectors).
Thanks for your insight and historical perspective. Thanks for confirming for me that the LFS build will not be adversely affected by this warning - only potential inefficiencies.
Will there be inefficiencies since the only partition not aligned on a 2048 byte boundary is the sda2 partition (which defines the start of the extended partition)? rknichols says no. This is still puzzling as fdisk points out the the sda3 partition is the one that is not aligned properly.
This LFS build has been great for keeping my "little gray cells" (Hercule Poirot) active (I'm 64, and wrote my first computer program in 1971). I'm on my 4th build, and have yet to get past the temporary system. Thanks for everyone's help!
Will there be inefficiencies since the only partition not aligned on a 2048 byte boundary is the sda2 partition (which defines the start of the extended partition)? rknichols says no.
rknichols is right. Whether or not the extended partition is properly aligned, doesn't really matter, since (if I remember correctly) only its very first sector holds any significant data anyway; it represents the head of the linked list of logical partitions that are contained in the extended partition.
Quote:
This is still puzzling as fdisk points out the the sda3 partition is the one that is not aligned properly.
As rknichols points out, fdisk is mistaken. It probably notices that the containing extended partition is improperly aligned, and incorrectly reports an issue with the first logical partition that it holds. In my opinion, it could just as well ignore improper alignment of the extended partition, because that is entirely inconsequential.
Liniux has so many details/things to learn. I believe that I could spend the rest of my life learning it, and still only know about 10% of what there is to know.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.