Align USB flash drives to 4096 bytes as well such as SSDs? Check in Linux?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
To see if your partitions are aligned correctly, hit the Start menu and type in
Code:
msinfo32
. Enter Msinfo32 and go to Components > Storage > Disks. Look for your SSD on the list and find the "Partition Starting Offset" item. If this number is divisible by 4096 (that is, if dividing it by 4096 equals a whole number and not a decimal), your partition is correctly aligned.
I am looking for the same thing in Linux.
Are you supposed to align your USB flash drives to 4096 bytes as well as SSDs? Some of mine are aligned, some don't, strangely. Is there a detailed step by step guide to do that?
Last edited by permissive; 08-18-2013 at 09:01 AM.
I doubt you'd find much improvement. USB flash drives tend to be a collection of weird stuff going on inside. Not sure I'd ever attempt to fool with them. They may mount like a scsi but aren't internally a true drive. Maybe CF or SD flash may be more ISO like.
For SSDs, you want to avoid layouts that would have an erase block, which might be 256KB, that spans more than one filesystem. It's not for performance reasons, but for data integrity. You want to avoid operations in one filesystem causing part of another filesystem to be copied and reallocated. That's why modern partitioning tools default to 1-Megabyte alignment for partitions.
For SSDs, you want to avoid layouts that would have an erase block, which might be 256KB, that spans more than one filesystem. It's not for performance reasons, but for data integrity. You want to avoid operations in one filesystem causing part of another filesystem to be copied and reallocated. That's why modern partitioning tools default to 1-Megabyte alignment for partitions.
I am sorry I have no idea what do you mean by 256 kb and 1 Mb alignments. Perhaps a link to a definitive article would be helpful.
To see if your partitions are aligned correctly, hit the Start menu and type in
Code:
msinfo32
. Enter Msinfo32 and go to Components > Storage > Disks. Look for your SSD on the list and find the "Partition Starting Offset" item. If this number is divisible by 4096 (that is, if dividing it by 4096 equals a whole number and not a decimal), your partition is correctly aligned.
I am looking for the same thing in Linux.
To back to my original question - anyone has a solution for this?
Besides, this thread is definitely not the definitive one regarding usefulness even if one looks for SSD alignment.
There are links within the referenced links to help you. You did say "as well such as SSDs". Rather broken sentence but you did refer to 'SSD'. At least that is what I got from the title.
There is a hardware issue with usb flash drives. They are not all the same. They were never intended to replicate a hard drive. They may have some very odd coding in them to match odd memory chips or odd controllers. Don't bother to align them. You won't find any benefit.
You are welcome to try some of the already posted links to ways one might do it for a ssd. Do this only on a test usb flash. It may not work on all of them and may even bork the drive.
"Because of the internal layout and operation of SSDs, it is best to partition devices on an internal erase block boundary. Partitioning utilities in Red Hat Enterprise Linux 6 chooses sane defaults if the SSD exports topology information.
"However, if the device does not export topology information, Red Hat recommends that the first partition be created at a 1MB boundary."
For information about erase block sizes, I suggest any of the Google hits on "ssd erase block".
Thanks for your feedbacks. I'll look into the links.
About USB sticks were never intended to replace HDDs? They have come a long time, definitely. Think about USB3 sticks, certified to run Windows 8 from it. Along the same thinking, they would just run a Linux even faster than Windows.
-
OK, and anyone knows the answer to the 1st part of my Original Post? That would be more interesting or important than all we are talking about here. Thank you.
So it is the TRIM command in plain English? (First result in the search link) As it is default in modern operating systems, at least in Windows 7.
You seem to lack an understanding of how the flash memory used in flash drives and SSDs works. You cannot write ONEs to flash memory cells. You can only write ZEROs. Only by erasing an entire block can its cells be changed back to ONEs. The erase blocks are large, typically 256KB, 512KB, or even larger in newer, higher density devices. Your OS, on the other hand, will read and write data in sector-size units of 512 or 4096 bytes. When the flash memory controller sees a write that would update part of a block that is currently in use, it reads the entire block, reallocates that block to a new, currently erased block, and writes out the entire block including the modifications. The old block is then marked "free", and will be erased to all ONEs at some future time. Unless you are happy with having writes to one filesystem possibly causing part of a different filesystem to be reallocated and copied, it is undesirable to have an erase block that spans more than one filesystem.
Erasing a block is a relatively slow operation, so for efficiency the controller needs to maintain a pool of blocks that are in the erased state. The TRIM command is a way for the OS to tell the flash controller that the data in a block is no longer needed and the block can be marked "free." But the TRIM command is actually of fairly minor importance in modern drives. The flash device actually contains significantly more blocks than its advertised capacity, so there is always a pool of blocks not currently in use. In fact, enabling automatic TRIM can seriously hurt performance. Prior to SATA 3.1, TRIM was defined as a non-queueable command, so using the "discard" (automatic TRIM) option can cause slow write performance. Scheduling a once-a-day fstrim operation a a cron job might be preferable.
To see if your partitions are aligned correctly, hit the Start menu and type in
Code:
msinfo32
. Enter Msinfo32 and go to Components > Storage > Disks. Look for your SSD on the list and find the "Partition Starting Offset" item. If this number is divisible by 4096 (that is, if dividing it by 4096 equals a whole number and not a decimal), your partition is correctly aligned.
I am looking for the same thing in Linux.
OK, and actually anyone has anything to say about my original REAL question? If you say "I have no idea" that's OK to me, I stop quoting myself again and again.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.