Partition aligment

Here you can discuss ReactOS related topics.

Moderator: Moderator Team

reactosuser7
Posts: 86
Joined: Wed Sep 28, 2016 11:53 pm

Partition aligment

Post by reactosuser7 » Thu Jan 18, 2018 7:32 am

Up to Windows XP there is a problem with partition aligment.
Have ReactOS the same problem (in a real HDD) ?

Programs
http://diskat.net/

ThFabba
Developer
Posts: 154
Joined: Sun Jul 11, 2010 11:39 am

Re: Partition aligment

Post by ThFabba » Sat Jan 20, 2018 5:44 pm

"There is a problem"? Can you be more specific?

reactosuser7
Posts: 86
Joined: Wed Sep 28, 2016 11:53 pm

Re: Partition aligment

Post by reactosuser7 » Sun Jan 21, 2018 5:12 am

Partition aligment is important to HDD and SSD performance.

See more (translate) here:
https://www.neoteo.com/comprueba-la-ali ... -tu-disco/

<< The lack of alignment in a partition is something that has accompanied us for many years. With the output of Windows Vista and Windows 7 , the problem has been solved from the root, and any new partition you make under these operating systems will not have alignment problems. However, if you are one of the many riders who are still operating under Windows XP , or have upgraded to a larger system while maintaining a partition created in that operating system, an alignment correction is probably necessary.

... alignment of partitions. In simple terms, a misaligned partition suffers from a lag between the logical and physical sectors, thus increasing the input / output operations on a disk, and reducing its performance . In a single independent partition, the problem is not so serious, since both the operating system and the programs work without any inconvenience. But under certain configurations, (for example, disks in RAID mode) , the loss of performance can be considerable. Where can you find these cases? Mainly, on systems under Windows XP. Due to a bug, XP creates all the new partitions from the physical sector 63 (its value is 62, since 0 is a sector) , which causes them to be misaligned from the beginning .
>>

In Windows 7 Microsoft resolves the problem. ReactOS is now targeting Windows XP, so we need to know if partition aligment problem is present.

reactosuser7
Posts: 86
Joined: Wed Sep 28, 2016 11:53 pm

Re: Partition aligment

Post by reactosuser7 » Sun Jan 21, 2018 5:42 am

On an virtualized installed Windows XP, diskat says the partition is aligment. But in a real hardware installation there is partition aligment problem.

PurpleGurl
Posts: 1619
Joined: Fri Aug 07, 2009 5:11 am
Location: USA

Re: Partition aligment

Post by PurpleGurl » Tue Jan 23, 2018 10:20 am

The issue here only involves drives with 4k sectors.The first user sector under Windows XP, by default, is on sector 63 or whatever, not 64. So that causes drives with 4k sectors to degrade in performance, since this imposes a bottleneck similar to that found in the 8088 and 80386SX CPUs. So what the alignment tools do is essentially move everything up a sector and remap things in the partitions and file indices accordingly. So the performance loss is reclaimed. This change is slightly non-standard, but modern drive utilities have no problem. They are relaxed enough to not consider this corrupt. It would be nice if when creating a new partition that we automatically moved things up to where both the logical and physical allocation units lined up. Obviously, if it is an established drive, moved from another PC, there is nothing to do unless the user runs an alignment utility on it. But if it is new, we could create the partition and first usable sector to be compatible with the Advanced Format drives.

Windows Vista (and higher) solves it with GPT if allowed to use it, and if I remember right, that is quite wasteful in the amount of space reserved before the first available sector.

Please forgive if there are any errors in this.
Last edited by PurpleGurl on Mon Jul 02, 2018 2:59 am, edited 1 time in total.

middings
Posts: 909
Joined: Tue May 07, 2013 9:18 pm
Location: California, USA

Re: Partition aligment

Post by middings » Tue Jan 23, 2018 9:50 pm

I thought the partition alignment difficulty was resolved in Microsoft Server 2003 SP2.
https://support.microsoft.com/en-us/hel ... erver-2003

cernodile
Posts: 53
Joined: Wed Nov 01, 2017 7:01 pm
Location: Estonia
Contact:

Re: Partition aligment

Post by cernodile » Wed Jan 24, 2018 12:46 pm

middings wrote:I thought the partition alignment difficulty was resolved in Microsoft Server 2003 SP2.
https://support.microsoft.com/en-us/hel ... erver-2003
I guess if we're targeting Server 2003, we won't have the issue XP had. Wouldn't make sense to include issues like this on purpose.

PurpleGurl
Posts: 1619
Joined: Fri Aug 07, 2009 5:11 am
Location: USA

Re: Partition aligment

Post by PurpleGurl » Wed Jan 24, 2018 9:40 pm

middings wrote:I thought the partition alignment difficulty was resolved in Microsoft Server 2003 SP2.
https://support.microsoft.com/en-us/hel ... erver-2003
That seems to be a different issue unless this is what the OP meant. That involves alignment due to RAID/striping causing delays. That has to do with the Disk Management tool, and I guess we should do that too.

The description I gave has to do with AFD drives which use 4k sectors instead of 512 byte sectors. One reason manufacturers did the change was because this scheme uses 5/8 the boundary and CRC space on the media as compared to before.

It would be nice to be able to create a partition table when setting up and the first user sector be moved up one from the default of XP (ie., sector 64 vs sector 63), etc. So no separate alignment tool nor time loss or risk in running it is necessary if the partition is created this way.

val
Posts: 69
Joined: Fri Feb 10, 2017 5:22 am

Re: Partition aligment

Post by val » Wed Jan 24, 2018 10:01 pm

Windows Vista (and higher) solves it with GPT if allowed to use it, and if I remember right, that is quite wasteful in the amount of space reserved before the first available sector.
It's not exactly "wasteful". GPT allows for having a lot of partitions. This requires space for GPT Partition Array, holding needed information. Second there are some obscure hardware requirements for different protocols (SCSI, SATA) for "best performance practices", demanding from FW/OS/utilities align partitions on different boundaries. UEFI specification chews this in a whole long paragraph trying to explain what is that and where to consult, refering to the endless SCSI/SATA capabilities registers and commands. ... And then, at the end, honestly tells - you know what, you'd better off to align on something big enough, like say 1 MB, that for sure, everybody would be happy with. :D
just look at pages 107-108 of the UEFI specification. below is the relieving summary at the end. :D
To avoid the need to determine the physical block size and the optimal transfer length granularity, software may align GPT partitions at significantly larger boundaries. For example, assuming logical block 0 is aligned, it may use LBAs that are multiples of 2,048 to align to 1,048,576 byte (1 MiB) boundaries, which supports most common physical block sizes and RAID stripe sizes.

reactosuser7
Posts: 86
Joined: Wed Sep 28, 2016 11:53 pm

Re: Partition aligment

Post by reactosuser7 » Thu Jan 25, 2018 2:39 am

The only way to confirm is to install ReactOS in a real HDD...

middings
Posts: 909
Joined: Tue May 07, 2013 9:18 pm
Location: California, USA

Re: Partition aligment

Post by middings » Sat Jan 27, 2018 8:39 am

PurpleGurl wrote:
middings wrote:I thought the partition alignment difficulty was resolved in Microsoft Server 2003 SP2.
https://support.microsoft.com/en-us/hel ... erver-2003
That seems to be a different issue unless this is what the OP meant.
I followed the link the OP supplied. Perhaps I misunderstood or pasted the wrong link.
The description I gave has to do with AFD drives which use 4k sectors instead of 512 byte sectors. One reason manufacturers did the change was because this scheme uses 5/8 the boundary and CRC space on the media as compared to before.
Here is a link to a very recently updated MSDN article about AFD (Advanced Format Disk) drives.
https://msdn.microsoft.com/en-us/window ... ity-update

According to the table included in this article and the note that follows the table, Microsoft Windows XP and Microsoft Server 2003 might fail to operate correctly with AFD drives. The result could be data corruption or loss. Perhaps the ReactOS developers (devs) can avoid this problem. AFD drives had not been invented when Windows XP and Server 2003 were released to the public.
Last edited by middings on Sat Jan 27, 2018 1:25 pm, edited 1 time in total.

Wierd
Posts: 147
Joined: Sat Dec 18, 2004 10:12 am

Re: Partition aligment

Post by Wierd » Sat Jan 27, 2018 9:31 am

Systems with eMMC storage (cloudbooks, converted chromebooks, tablets, etc) also have issues with partition alignment, as in those cases you have flash erase block alignment related issues. Traditional HDDs expect 512 byte sectors, but the sector size on flash storage chips is closer to something between 4k and 64k, depending on chip architecture.

Unless you like the storage in your cloudbook to degrade very quickly and burn through its erase cycles like washed up singer on heroin, you need to assure partition alignment and size are appropriate, as well as assuring disk structures are suitably sized.

val
Posts: 69
Joined: Fri Feb 10, 2017 5:22 am

Re: Partition aligment

Post by val » Sat Jan 27, 2018 3:57 pm

This equally applies to SSD/SD/eMMC storage devices. They all expose 512 byte sectors for the host. But all have much larger Erase Units partitioning on internal NAND arrays. Internal microcontroller kind of takes care of this. But there are even bare NAND devices, where OS should take care of wear leveling. If ReactOS targeted mini PCs like these numerous arm SBCs and not so numerous mips counterparts, that would be one of the main goals of the proper supporting storage devoces, but since ReactOS targets oldish x86 PCs, with almost 100% spinning rusty HDDs, the whole problem boils down to aligning partitions at 64th sector (LBA 63) on legacy MBR and on 1 MB at GPT on the installation time.

Wierd
Posts: 147
Joined: Sat Dec 18, 2004 10:12 am

Re: Partition aligment

Post by Wierd » Sun Jan 28, 2018 3:55 pm

We can probably get by with EXT3/4 and abuse the RAID feature set on eMMC/SD/NAND, much like how proper alignment and filesystem structure size is done on linux by doing the same.

Basically, when you create the file system, you tell it some seemingly absurd stuff about how it is a raid device with one member, which has stripe and stride widths that just so happen to make the disk structures align perfectly with the erase unit sizes of the underlying medium.

https://thelastmaimou.wordpress.com/201 ... d-strides/

This causes the EXT file system driver to withhold writes that dont fully fill up a write stripe (erase block) until the full stripe is filled with data (EG, you are writing a very large file), or until a flush is required (small file + sync). It also ensures that many small files will not walk all over each other's erase units (if properly aligned anyway) because each one will have a stride size per inode that assures this.

Now, getting the *CORRECT* values for your flash device is black magic voodoo, that requires some experimentation, and is prone to human error. (Because memory module makers dont want to tell you exactly what the erase block size is, and all that fun stuff. This is especially true on "disposable" flash memory, like USB sticks and SD Cards. Noplace in the documentation for your device will you find this information. You have to derive it yourself.)

Currently, the best tool for this is flashbench.
https://github.com/bradfa/flashbench

It is not noobie friendly.

It might be possible to determine if a device is an SSD by probing SMART, and seeing if the disk RPM is zero. Then, if the disk is an SSD of some sort, run a flashbench like read test against it to determine what its most efficient block sizes are, then configure the filesystem structures accordingly. That would be something 1st stage installer could do when it makes partitions. End users dont really need to know about things like noatime, stride, stripe, and pals-- which are very damn useful for properly setting up flash based storage devices so they dont burn out like a rockstar on heroin. (Personal anecdote, I burned up a 128gb micro SD card in my converted chromebook through ignoring partition alignment and disk structure sizes. It took less than 1 year to happen. When I did the system rebuild with the new microSD, I did the flashbench thing, learned that I have 16k erase blocks, then partitioned and formatted the system appropriately. I run linux on it, so I also set up tmpfs mounts at certain heavy-write locations, like the browser cache, to avoid unnecessary writes. Works great.)

val
Posts: 69
Joined: Fri Feb 10, 2017 5:22 am

Re: Partition aligment

Post by val » Sun Jan 28, 2018 4:30 pm

these tricks with withholding writes might cause data loss in practice, this is everything I can say yet, And ext file system types are foreign for this architecture, don't think they will be primary FSs anytime. But this might have been done on the lower level (by appropriate drivers on NAND-backed devices). at least theoretically.

And just a remark, "browser cache" in RAM is not exactly a browser cache, right? unless your linux distro does really support suspend-to-ram acpi state. and you use it. does it? do you use it? It's a weird overcome, because well, it actually doesn't use what is supposed to be used - secondary persistent storage. And finally, there is direct file caching into RAM by the OS, much better than making RAM look like disk (tmpfs).

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests