For those who are not aware: USB flash drives have slow data write speed, but it's because most flash drives have 128k erase block size, while filesystems usually have 4k block size. This means that filesystem blocks are not aligned to flash drive blocks, resulting in overhead during disk writes (I'll leave it up to you to do the full read).
Usually the partition made at the factory sets everything as it should be, but if you have deleted the original partition table, then you will be in a bit of a mess because the partition tools (like gpart or fdisk on linux) will not align the newly created partitions correctly.
From what I have read, for proper alignment of filesystem: One should use 224 heads (32*7) and 56 sectors (8*7) per track to get 12544 (256*49) sectors per cylinder. Results in cylinder size of 49*128k.
If you have a new MBR table on the flash drive or if you placed a freebsd-boot partition (usually between 36k-64k in size) at the start of your GPT partitioned drive, then you must align the first useable partition to 128k for optimal write speed. Normally I would choose GPT partition, but Win XP cannot mount GPT. The assumption for flash drives (specially USB) is that they usually need to be mountable by all O/S.
If you intend the flash drive to be non-booting and can use it as GPT, then you might falsely think that placing a partition starting at zero will solve this. Unfortunately while the "initial alignment" issue will be correct, sectorsize will not: It will show 512 instead of the desired 128.
OK, enough of the background description. Now for the problem:
Create MBR table, add partition with 128k offset from zero and show results:
Great! We seem to have the correct offset needed for fast-write. Unfortunately that's half the problem. The other half is sectorsize, and I can't get gpart nor linux's fdisk to set 128k sectorsize! 512 will not (afaik) optimize the write speed.
The questions are:
1. Is there anything wrong in my description?
2. If not, how can I set 128k partition size?
BTW, this problem is valid for USB's and all SD cards (cameras, phones, etc.)
Usually the partition made at the factory sets everything as it should be, but if you have deleted the original partition table, then you will be in a bit of a mess because the partition tools (like gpart or fdisk on linux) will not align the newly created partitions correctly.
From what I have read, for proper alignment of filesystem: One should use 224 heads (32*7) and 56 sectors (8*7) per track to get 12544 (256*49) sectors per cylinder. Results in cylinder size of 49*128k.
If you have a new MBR table on the flash drive or if you placed a freebsd-boot partition (usually between 36k-64k in size) at the start of your GPT partitioned drive, then you must align the first useable partition to 128k for optimal write speed. Normally I would choose GPT partition, but Win XP cannot mount GPT. The assumption for flash drives (specially USB) is that they usually need to be mountable by all O/S.
If you intend the flash drive to be non-booting and can use it as GPT, then you might falsely think that placing a partition starting at zero will solve this. Unfortunately while the "initial alignment" issue will be correct, sectorsize will not: It will show 512 instead of the desired 128.
OK, enough of the background description. Now for the problem:
Create MBR table, add partition with 128k offset from zero and show results:
# gpart create -s mbr da0
# gpart add -b 65 -t linux-data /dev/da0
Code:
63 3946953 da0 MBR (1.9G)
63 63 - free - (31k)
126 3946887 1 linux-data (1.9G)
Code:
# diskinfo -v /dev/da0
512 # sectorsize
2020872192 # mediasize in bytes (1.9G)
3947016 # mediasize in sectors
0 # stripesize
0 # stripeoffset
245 # Cylinders according to firmware.
255 # Heads according to firmware.
63 # Sectors according to firmware.
1. Is there anything wrong in my description?
2. If not, how can I set 128k partition size?
BTW, this problem is valid for USB's and all SD cards (cameras, phones, etc.)