fdisk sector size and alignment issues
I executed the command:
# fdisk /dev/sda1
The output was:
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Command (m for help): p
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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
Disk identifier: 0xe0c5913d
Device Boot Start End Blocks Id System
/dev/sda1 63 40965749 20482843+ 1c Hidden W95 FAT32 (LBA)
Partition 1 does not start on physical sector boundary.
/dev/sda2 * 40966144 334567423 146800640 7 HPFS/NTFS/exFAT
/dev/sda3 334567424 753997823 209715200 83 Linux
/dev/sda4 753999870 1953525167 599762649 5 Extended
Partition 4 does not start on physical sector boundary.
/dev/sda5 753999872 1949376511 597688320 83 Linux
/dev/sda6 1949378560 1953525167 2073304 82 Linux swap / Solaris
I"m in trouble because the following items:
The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted.
Partition 1 does not start on physical sector boundary.
Partition 4 does not start on physical sector boundary.
How am I allowed to solve one or more of those items without loosing my files and partitions?
What're the issues I will have leaving all as it's?
Solution 1:
The logical sector size being smaller than the physical sector size is normal for most modern disks. This is simply how Advanced Format disks are most often implemented. Some external disks use the same (4096-byte) sector size for both physical and logical sectors, and I've heard that some high-end internal disks now do the same, but most disks these days are Advanced Format models with 512-byte logical sectors and 4096-byte physical sectors. There's nothing you can (or should try to) do about this.
That said, properly aligning partitions for Advanced Format disks is important. I ran some tests on Advanced Format disks to determine what happens when their partitions are misaligned and published the results here. In brief, the extent of the problem varies greatly from one filesystem to another and from one disk to another, but there's almost always a significant (and sometimes huge) performance penalty associated with misaligned partitions.
Your /dev/sda4
, however, does not directly hold a filesystem; it's an extended partition, which means that it is simply a container for other partitions. The data directly associated with /dev/sda4
is simply two (logical) sectors, which are probably not even adjacent to one another, so they can't be properly aligned. Real performance penalties would come from alignment of the partitions contained within /dev/sda4
. In your case, /dev/sda4
holds /dev/sda5
and /dev/sda6
, both of which are properly aligned. Thus, you don't need to worry about /dev/sda5
. The warning you're seeing is simply code that's being over-enthusiastic about reporting a "problem" when one doesn't exist.
Your /dev/sda1
, on the other hand, is not properly aligned -- it begins on sector 63, which is not divisible by 8. Whether you should do anything about that depends on how much you use that partition, how you use it (file size, reads vs. writes, etc.), how important it is that you get optimum performance from it, whether you've got adequate backups, etc. I recommend you read the article I referenced earlier, then decide whether to fix the problem. (I didn't report FAT results in that article for space reasons, but FAT performance suffered pretty badly -- IIRC, not as badly as ReiserFS, but at least as badly as most other Linux-native filesystems.)
If you decide you want to fix /dev/sda1
, you should begin by backing it up. With that done, one way to fix it is to delete it, create a new partition in its place, and restore its files. Another way (after backing up) is to resize the partition in GParted. Make a tiny change to the start point; any recent version of GParted should round to a multiple of 2048 sectors, and you'll be fine. Moving the start point of a partition is always riskier and takes longer than moving the end point. As the partition is only 19GiB in size, the operation shouldn't take a ridiculous amount of time, even moving the start point, but it won't be instantaneous.
As a side note and background, only fairly old tools misalign partitions on modern Advanced Format disks. My guess is you used such a tool (an old version of Linux's fdisk
or a DOS FDISK
, perhaps) to create /dev/sda1
, then used a more modern tool (a more recent fdisk
, parted
, or GParted, perhaps) to create the rest of your partitions.