>

DJ Dates

28Feb/110

A Window into the Hard Drive

This video shows the inside of a hard drive during various operations, such as copying and deleting files, defragmentation, and formatting the drive. This video is licensed under the creative commons BY-NC-SA license. Please feel free to use this video in your classroom.

Before we get started with the hard drive, let’s identify the different parts. The shiny disc in the harddrive is called the platter. Instead of being made out of polycarbonate plastic like a CD or DVD, the hard drive platter is made out of metals such as nickel, cobalt, and chromium. Often, hard drives will have more than one platter, such as in this hard drive which has two platters stacked on top of each other. In the middle of the hard drive platter is the spindle. This hard drive rotates the platter at 5400 revolutions per minute. High performance hard drives may rotate at speeds up to 7200 or 10,000 RPM.

The actuator arm rotates, moving the hard drive head across the surface of the platter while the platter is spinning. The arm only moves across a single axis, while the disc rotates underneath. At the end of the actuator arm is the read/write head. This hard drive has multiple heads, one for each side of each platter. At the end of the hard drive is the Parallel ATA cable which transfers data to and from the hard drive and the power connecter that is powering the drive. A more modern hard drive would probably use a Serial ATA data cable, which is much less bulky.
While we are looking at what happens we perform certain hard drive operations, we will have Windows task manager open showing the status of the CPU and memory.

When our hard drive is turned off, the hard drive head is parked in a safe location that does not contain any data. When we turn on the hard drive, the head will read a list of files on the hard drive. This particular hard drive is formatted as a FAT32 drive. The word FAT stands for File Allocation Table, the list of files on the drive and where the individual pieces of those files are located.

When we look at the contents of the hard drive, not only does Windows 7 read the file allocation table, but Windows attempts to create thumbnails for each file. This requires actually reading some of the contents of the file, so we see the head quickly skip across the surface of the disc. We also the CPU spike as thumbnails are generated from this high definition video file. This video file is the short film Sintel from the Blender Foundation which can be downloaded for free at www.sintel.org .

One of the issues that can impact hard drive performance is file fragmentation. Over time, as files are deleted or stored, parts of files may be stored in different physical locations of the disc. As one of these fragmented files are accessed, the head must traverse the disc reading these different locations. Windows has a built in disc defrag utility which can be accessed by right clicking on the hard drive, selecting Properties, the Tools tab, and then Defragment now.

Previous versions of Windows generated a visual diagram of the hard drive when defragmenting. Unfortunately, Windows 7 no longer has this feature, so we will use a different software package called Auslogics Disk Defrag, which can be downloaded for free from Auslogics.com.
Windows 7 shows my main hard drive as 0% fragmented, while Auslogics Disk Defrag reports my drive as 25% fragmented. When I analyze my external drive, I see that the drive is 99% fragmented. Red squares are fragmented areas of the disc, while green areas are non-fragmented areas. On my system drive, some areas are necessary for the operation of the disc or operating system, so that they cannot be moved. Empty areas appear as a light gray.

I can also look at individual files and see how they are fragmented and spread across the disc.

The first file is not fragmented at all, so we will copy this file to the desktop to see the behavior of the drive. As the file is not fragmented, the drive head barely moves because the file is all in one contiguous location.

As we scroll through the file listing, even in details format, we still see the head seek each file because each file must be read to display certain pieces of information, such as the duration of the video.

When we copy the most fragmented file, we see the head sweeping across the disc reading each location that contains parts of the file.
However, notice what happens if we copy the file to the desktop a second time.

The copy operation appears to complete instantly with no movement of the hard drive head. This is because the file has been cached into memory, which is much faster than the hard drive. Even if we delete these files off the desktop and copy them again, we find they are still cached in memory and appear to copy immediately. And notice the size of cached and free memory we have in task manager? Even though applications are not using a lot of memory, we can tell by free and cached memory that memory is being heavily used to cache the hard drive. If applications suddenly required more memory, it would be made available to applications and the hard drive would no longer be as cached. So it is almost always worthwhile to have a lot of memory in our computer.

When we defragment the hard drive, the defrag software will read from the original locations of the fragmented file on the hard drive and write to a new location where the file will not be fragmented. As this process occurs, we also see the drive head make changes to the file allocation table.
As this is a time consuming process, we will cancel it. Let’s take a look at the file that was being defragmented. We can see that parts of the file are still spread across the disc while other parts have been placed near the edge of the drive.

When we copy the file, we can see the head start at the end of the drive to copy the beginning of the disc and then jumps to the middle to finish copying the file.

When we delete a file from the hard drive, we are only deleting the record pointing to that file from the file allocation table. We can see this when we reanalyze the drive in the disk defrag software and still see the same areas of the disc being utilized. We also can see that the file has been put in the recycle bin on the drive.

When we quick format the drive, we see nearly the same thing happen. The file allocation table is briefly altered and disk defrag shows us an empty disc, but we know that all of the data still exists on the disc because we never saw those parts of the disc altered. Someone with the proper training could still recover the data from this disc even though it has been formatted. Some companies sell secure delete software that repeatedly writes over the same areas of the discs to attempt to completely eradicate any data that might remain.

When a full format is performed, the process takes much longer because the hard drive is thoroughly checked for bad sectors. However, even a full format may result in information being recoverable by someone with the proper tools and training.

Finally, when we are done with our external storage devices, we should make sure that we safely disconnect them from Windows. This ensures that caching and file accesses are complete so that files are not corrupted if we simply disconnected the drive.

When we turn off the drive, we see that the hard drive head returns to the park position.

This hard drive was fragmented by running a Cygwin Bash shell script that copied the movie Sintel to the hard drive 97 times. The first file is copied completely creating the single non-fragmented file. The 96 subsequent files are copied by executing the copy command and causing the command to spawn a new process, allowing the next iteration of the command to begin executing immediately before the previous command had completed copying the file. This is accomplished by the “&” sign at the end of this command. A Bash for loop executes this command 96 times, and we insert counter for the loop into the file name. The Cygwin Bash environment can be downloaded for Windows at www.cygwin.com .
Hard drives are normally only repaired and opened while in a clean room environment. The inside of a hard drive should be dust free and foreign particles could cause the hard drive to fail and lose data.

In order to create the window in the case of this hard drive, the hard drive case was opened in as dust free of an environment as I could manage. I ran the shower in my bathroom as hot as I could, to increase the humidity and pull dust out of the air. Then I opened the hard drive case and placed the naked drive in a Ziploc bag.

I then took a Dremel tool and cut out a hole in the top cover. The edges were then sanded and dust was removed.

Once part of the cover was removed, I cut a piece of Plexiglas roughly the same dimensions.

The Plexiglas window was glued in place on the cover with superglue and then placed under a stack of books to cure for 24 hours.

The Dremel tool was then used with a sanding bit to remove excess Plexiglas and provide access to the screws.

Once the modified cover was cleaned and dusted, I again ran a hot shower to pull dust out of the bathroom air, took the naked drive out of the Ziploc bag, and reattached the cover. Luckily, everything still works, but this is not a project to take lightly because you risk permanently damaging the hard drive.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.