![]() |
![]() |
![]() |
#1 |
Registered User
Join Date: Mar 2013
Location: Lahti / Finland
Age: 49
Posts: 358
|
Format CompactFlash Card with 8 MB Aligned Partitions
CompactFlash generally have 2, 4, or 8 MB erase block size. When writing to memory card whole Erase block must be read, modified and write back to the drive. Because of this, partitions on CompactFlash card should be aligned so that they begin and end at the edges of the erase blocks.
Is this ideal way to do it on HDToolBox? 64 Heads 64 Blocks per Track 4096 Blocks per Cylinder ( = 2 MB ) ![]() Last edited by ShK; 03 July 2018 at 11:00. |
![]() |
![]() |
#2 |
Registered User
![]() Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,104
|
I'm not entirely sure it makes that much of a difference since the OS will still place files arbitrarily within the partitioned space. If filesystems had a blocksize in the MB range, perhaps it would make more sense, but with such a huge difference in size between 8MB and even the largest blocksize of 32KB (with most other filesystems using just 512 bytes), I just can't see the benefit.
Is there some aspect I'm missing here? |
![]() |
![]() |
#3 |
Registered User
Join Date: Mar 2013
Location: Lahti / Finland
Age: 49
Posts: 358
|
I thought that each block gets more often erased and rewritten TWICE when misaligned?
|
![]() |
![]() |
#4 |
Registered User
![]() Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,104
|
Yes, that will happen, but every other 8MB border within the partitions (a 2GB partition has ~256 such borders) will also cause both blocks to be erased and rewritten if a block straddles them, so aligning the partition is the difference between having 256 such events and 254, assuming a full partition. But a 512 byte blocksize means that no block will ever straddle the 8MB border. The more worrying aspect is that writing in small block sizes of 512 bytes means that (worst case scenario) writing a 1MB file requires the page to be erased and rewritten potentially 2048 times. Hopefully caches etc. would significantly reduce that number. Increasing the blocksize to 32KB with FFS would reduce that number to 32 erase and rewrite operations, at the expense of introducing blocks that straddle the 8MB page border. In that case, aligning the partitions would eliminate the case where 1 in 32 written blocks required two pages to be erased instead of 1, but it's still far fewer cycles than the 512 byte worst case.
|
![]() |
![]() |
#5 |
Registered User
Join Date: Mar 2013
Location: Lahti / Finland
Age: 49
Posts: 358
|
PFS3 seems to automatically flush all write cached buffers in few seconds after last write. How big is that cache?
e. It caches only index block(s), which are of pointers to the data blocks? Last edited by ShK; 03 July 2018 at 13:35. |
![]() |
![]() |
#6 |
Registered User
![]() Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,104
|
I honestly don't know what size the cache is, but most filesystems behave in a similar way. None of them will know of any alignment other than with their block size however, which for PFS is 512 bytes.
|
![]() |
![]() |
#7 |
Registered User
Join Date: Mar 2013
Location: Lahti / Finland
Age: 49
Posts: 358
|
I ended up this type geometry to maximize lifespan of the standard Kingston CF Card 4GB (Flower image):
https://wiki.linaro.org/WorkingGroup...lashCardSurvey (List of the CF cards characteristics is in end of the page) Allocation Unit = 2 MB (2097152 b) 4096 blocks <--- ERASE SIZE Write Size = 16 KB (16384 b) 32 blocks <--- FILE SYSTEM BLOCK SIZE -- 3997163520 b / 512 b = 7806960 blocks 7806960 blocks / 4096 blocks (2097152 b) = 1905,99609375 erase pages 1905 erase pages * 4096 blocks (2097152 b) = 7802880 blocks ![]() 7802880 blocks / 64 Heads (Tracks per cylinder) / 64 Blocks per Track = 1905 Cylinders 1905 Cylinders (cylinders per HDD or tracks per layer) 64 Heads (Tracks per cylinder) 64 Blocks per Track 4096 Blocks per Cylinder (64 Heads * 64 Blocks per Track = 4096 Blocks = 2 MB) ![]() File system block size = Kingston CF Write Size 16 KB (16384 b) ![]() 128 buffers * File system block size 16384 B = 2097152 B = 2 MB ![]() Each Cyl. is exact the same size as erase size. Last edited by ShK; 05 July 2018 at 06:50. |
![]() |
![]() |
#8 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,003
|
What are you trying to accomplish?
|
![]() |
![]() |
#9 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,185
|
This is not true. Heads is not a synonym for sectors. Blocks is a synonym for sectors (at least in the context of HDToolbox. Actually the word blocks is used wrongly here).
Sectors = Sectors per track a.k.a. Blocks per track Heads = Tracks per cylinder Cylinders = cylinders per HDD or tracks per layer. However, neither of these values has any meaning for modern harddrives, especially not for SSDs and flash memory drives. Your approach to align a cylinder to an erasable block and a file system block to a writable page is a good method for SSDs and such. |
![]() |
![]() |
#10 |
Registered User
Join Date: Mar 2013
Location: Lahti / Finland
Age: 49
Posts: 358
|
Thanks for the clarification.
![]() |
![]() |
![]() |
#11 |
Registered User
Join Date: Mar 2013
Location: Lahti / Finland
Age: 49
Posts: 358
|
I am not sure how these goes in HW level, but maybe it's even more ideal to have 'Blocks per Track' same as Kingston CF Write Size, which is 16 KB (16384 b) = 32 blocks. Would it sync better to all in real? Maybe not because these does not mean anything with CF...
1905 Cylinders (cylinders per HDD or tracks per layer) 128 Heads (Tracks per cylinder) 32 Blocks per Track (Kingston CF Write Size) 4096 Blocks per Cylinder (Kingston CF Erase Block Size) File system block size = Kingston CF Write Size (16384 b) 128 buffers * File system block size 16384 B = Kingston CF Erase Block Size (2 MB) |
![]() |
![]() |
#12 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,185
|
Heads and blocks per cylinder have no meaning at all. The only define the source values to calculate blocks per cylinder. So whether you use 128 * 32 or 32 * 128 or 1 * 4096 does not matter at all.
The only value which matters is the number of blocks per cylinder because partitions are aligned on cylinder boundary. Also the number of buffers has no relation to the hardware. The file system uses buffers to store data temporarily. The more buffers you use the better for performance. But each buffer costs RAM. Especially with large block sizes you quickly eat up a lot of memory. In your example with 128 buffers of 16kb each you lose 2 MB memory per partitiion. Buffers are used by the file system for many different purposes, but mainly for directory and meta data. You won't ever get it to write a 2 MB chunk at once. |
![]() |
![]() |
#13 |
Registered User
Join Date: Mar 2013
Location: Lahti / Finland
Age: 49
Posts: 358
|
IDE commands (ATA5 or lower) have "sector count" field which is 8-bits, so MaxTransfer can have a maximum value of 255 (e.g. 255 * 512 = 130560b = $1FE00). MaxTransfer must also be divisible by the sector size (512) due to a bug in the WorkBench format code.
Even targeting MaxTransfer of 0x7FFFFF with the real SCSI2SD to erase page's size does not bring an advantage, because no program would ever attempt to write 8MB at once. But would it give any advantage to put the MaxTransfer size equal to the writable page size (in case of a Kingston $4000)? At least it should not slow down writing. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
PC & Amiga Partitions on one CF Card | amigoun | support.Other | 4 | 08 February 2015 06:47 |
PFS3 partitions full after format? | emuola | project.ClassicWB | 3 | 19 August 2012 16:25 |
[FS] CF-CompactFlash Card - 1GB for AMIGA | LTAC | MarketPlace | 0 | 25 March 2012 18:20 |
FS: 32 GB CompactFlash card | DJBase | MarketPlace | 1 | 07 January 2009 11:12 |
Force AVI recording to start aligned to odd/even frames | LocalH | request.UAE Wishlist | 0 | 16 September 2004 02:50 |
|
|