Helping people with computers... one answer at a time.
Slack space is unused, inaccessible space on a hard drive. I'll look at where it comes from, what you can do, and why it usually doesn't matter much.
I've heard quite a bit about disk slack space even though I don't completely understand that. From what I understand, it's the wasted space within the clusters (e.g. if you have a 2 KB file, the rest of the cluster is wasted) and that making smaller clusters (by repartitioning the drive) will make it smaller. What exactly is it, is that a big problem, and what can you do to reduce it in an already-partitioned system?
I wouldn't call it a big problem per se; most folks never notice any issues related to slack space. At worst, it simply means that your hard disk might run out of room a little sooner than it really needs to.
You're right in your analysis of what slack space is within clusters, but partitioning isn't really related and it's certainly not the answer.
I'll review how files are written to disk, what slack space is, and what you can do to minimize it.
If you even care, that is.
But first, we have to define a couple of terms.
Physical disks are organized into sectors, which are blocks of bytes (or characters) of data. Disk reads and writes always operate on the entire sector. Changing even one byte in the sector means that the entire sector will be read, the byte changed, and the updated data written back to the sector.
Most often, a sector will contain 512 bytes. (512 is a convenient power of two. Computers love powers of two .)
Sectors are a characteristic of the hard disk hardware and are completely independent of operating system, file system, or just about anything else outside of the hard disk itself.
Clusters are collections of contiguous sectors.
When you format a hard disk, part of that format determines the cluster size to be used when accessing that disk.
Clusters operate a lot like the sectors that they contain; each cluster is treated as single unit. When files are stored on a hard disk, they're allocated just enough clusters to contain the data.
Clusters may be configured to as little as one sector each to as many as eight, 16, 32, or even more.
Let's assume that you have a hard disk with 512 byte sectors and that each cluster is comprised of eight sectors. That means that each cluster will be 4096 bytes in length.
Now, let's create a file that's exactly one byte in length.
An entire cluster will be allocated to that file - all 4096 bytes will be removed from the available disk space and dedicated to this file.
One byte of that cluster will be used.
The remaining 4095 bytes would be what we call "slack space" - the unused, yet spoken-for space left over as an artifact of how file disk space allocation happens.
Multiply that over a lot of files and it might add up.
The most slack space that you'll ever see for any single file is one byte less than the disks cluster size. So the one-byte file that I used as an example above is a worst-case example. Assuming that file sizes are random, your average slack space per file will be roughly one half of the cluster size.
What that means is that the amount of disk space "lost" to slack is going to be roughly equal to the number of files that you have on your hard disk, times an average 2048 bytes.
The most common scenario where slack space might start to matter is if you have a lot of files that are smaller than half the cluster size and your hard disk happens to have a large-ish cluster size.
So if you're collecting a lot of files that are less than say 2048 bytes in size, then perhaps it might save you some disk space to choose a smaller cluster size.
Honestly, the quickest way to determine a hard drive's cluster size in Windows is to fire up a Windows Command Prompt (be sure to run it as Administrator) and run the CHKDSK command:
"Allocation Unit" is synonymous with "cluster size". As you can see on this drive, my cluster size is 4096 bytes.
Changing the cluster size is simple, yet it's a lot of work.
Reformat the drive.
The only time that you have an option of changing the cluster size is when you reformat the drive.
If you have an existing drive full of data, you'll have to copy off the data, reformat, and copy the data back.
If you're using the command line "Format", it's the "/A" parameter that allows you to specify the Allocation unit, or cluster, size. (Run "FORMAT /?" for a list of all options and allowed values.)
If, on the other hand, you use Windows Explorer, right-click the drive in question and click Format.... You'll get these options:
Note the "Allocation unit size" drop-down menu. Here, you can choose the allocation unit size that you wish the newly formatted drive to use.
The smallest is 512 - the current hardware sector size† - cluster sizes smaller than this simply don't make sense. The largest will vary depending on the file system that you choose. The default for NTFS is typically 4096 and represents a reasonable compromise for disk-space usage, performance, and fragmentation as smaller clusters will typically result in more fragmentation.
In general, unless you have a specific reason to change it, I'd typically leave it at the default.
The good news is that as drives get bigger and cheaper, the impact of slack space becomes small enough to typically remain a non-issue.
† A new breed of hard drive is becoming more common place that uses "Advanced Format" sectors of 4096 bytes. This promises some significant performance gains, but it also presents some compatibility issues as well. Windows, for example, does not natively support 4k sectors, but rather relies on the drives supporting a 512 byte sector "emulation mode".
Comments on this entry are closed.
If you have a question, start by using the search box up at the top of the page - there's a very good chance that your question has already been answered on Ask Leo!.
If you don't find your answer, head out to http://askleo.com/ask to ask your question.