[ This article was first published in the November, 2008, issue of
Larry’s Final Cut Pro Newsletter. Click here to subscribe. ]
Two issues ago, I reported that when a hard disk is powered down and stored on the shelf, after time the magnetic data will tend to slowly “evaporate.” (Here’s the original article.)
The basic problem is that magnetic data stored on the drive fades, or loses it charge, over time causing you to lose all the data on that hard disk. (I’ve been told the term for this data loss is “bit flux.”) This data can start to disappear as early as a year after the hard disk is powered off.
As you can imagine, this caused quite a stir.
After talking with a lot of hard disk folks, I learned that the easiest solution is to refresh the data on the hard disk before it starts to “fade.” All hard drives are programmed to refresh data as the heads skim along the drive. But that only happens when the hard drive is powered up and operational — something not possible when it is sitting on a shelf.
What I didn’t know was how to do a refresh… until recently.
Thanks to Robert Gobeille, I now have a solution and an explanation. Feel free to share this with your friends.
When Bob first sent me the procedure, I asked him to please double-check that this is safe, find out how long a scan takes, and tell me how to escape out of it. From those questions, Robert put together the Q&A below.
– – – THE PROCEDURE – – –
- Log into your computer as an administrator.
- Open Applications > Utilities > Terminal
- At the terminal prompt, type: sudo cat /dev/rdisk0> /dev/nullNote: There is a space AFTER “sudo,” “cat,” and the “>” sign.
– – – BOB’S EXPLANATION – – –
This will do no harm. The following may cause your eyes to glaze, but I’ll attempt to explain all this and keep it simple. Here is the command again:
sudo cat /dev/rdisk0 > /dev/null
“sudo” is a command that says “run the following command with root (administrator) privileges. You need this privilege level to read the disk as if it is one big file (as opposed to reading each individual files).
“cat” is a command that says copy the following file.
“/dev/rdisk0” is the name of your primary disk. It is a file name just like a .mov but it happens to represent the entire disk. Since this follows “cat”, this is the file you are copying. (Note the use of the letter “r’ in front of the word “disk”.)
” > /dev/null” says to copy the file (/dev/disk0) to the file named /dev/null /dev/null is a special type of device. Anything you write to it will be thrown away. It’s like copying things to a black hole.
So the above command means to read the entire disk and copy it to nowhere. I know this sounds strange, and yes I could write a program that reads the entire disk without “copying to nowhere”, but the above is pretty simple.
Start Activity Monitor.app (in your Applications/Utilities directory) and select “Disk Activity”. Then run the above command. You will see lots of data read but none written.
Q: How long will this take?
A: I’m running it on my MacBook Pro as I write this. I see data read at 12 MB/s and the disk capacity is 232GB. So this should take around 5 hours. Nobody will probably run this on a MacBook. A Mac Pro should be considerably faster.
Q: How do I measure how long this takes?
A: Change the command to: sudo time cat /dev/rdisk0 > /dev/null and it print out how long it took, when it is done. The output will look funky. For example, “12345.67 real 2.34 user 345.89 sys” The 12345.67 is the seconds it took to run the command.
Q: How do I terminate this command once it starts?
A: In the same terminal window where you executed this command, press Control+C. That is, hold down the Control key and press the letter C.
Q: The command above says that it is reading the file /dev/disk0, but I have several disks. How do I know the correct name of the disk that I want to scan?
A: Excellent question! This is a critical point that I forgot to address above. Go into Disk Utility (in your Applications/Utilities directory). You will see all your mounted disks in the left column. This list is indented. It will say something like “232.9 GB Hitachi” and underneath that will be your volume name indented, like “Macintosh HD”. – Click on the top line (the “232.9 GB Hitachi” line in my example) – Click on the Info button – Read the “Disk Identifier” line. It will say something like “disk0”. Where Disk Utility is saying “disk0” or “disk1” or “disk2”, … put an “r” in front. This is the name you use in the command (/dev/rdisk0 in this case).
Q: Will this hurt anything? What if I say /dev/rdisk0, like your first example, but I should have put in /dev/rdisk3 (which I learned from the last question)?
A: If you specify the wrong disk, you will simply read the wrong disk. There is no harm in reading a disk. Obviously, you need to read the correct disk to refresh the disk but you will do no harm.
Thanks, Bob. This explains what I wanted to know.
UPDATE – June, 2009
[ This article was first published in the June, 2009, issue of
Larry’s Final Cut Pro Newsletter. Click here to subscribe. ]
Last summer, I learned and shared with you that when a hard disk is unplugged and stored on a shelf a process called “bit flux” will slowly let the magnetic data stored on the hard disk fade away. (Here’s the original article.)
While the time this fading takes varies, it can be as short as one year or as long as three. What is sure is that your data will slowly disappear until the hard drive is no longer useable. (Note: if your hard disk is always, or mostly always, powered on and attached to your computer, this is non-issue.)
The way to prevent this problem is to connect your hard disk to your computer about once a year and refresh all the sectors on the drive.
Recently, Dave Fix, Senior Systems Administrator at Mr. X, Inc. sent me the following which can help with this restoration process.
In your article about refreshing hard disk storage, I thought I’d let you know that another way you can refresh storage is to run the badblocks command on a hard drive. This should be 100% safe, as it does NO writing to the drive (unless a bad sector is detected, at which point it will re-write the bad-sector map on the disk).
The command is: sudo badblocks -b 4096 -p 1 -c 32768 /dev/rdisk0
I asked Dave to explain what the various parameters did. He replied:
-b 4096 : Sets the block size to 4096 bytes. This can improve the speed at which the tool operates.
-p 1 : Tells it to perform one pass. If you want to perform more than one pass, set this number higher.
-c 32768 : Tells it to test 32768 blocks at a time. The default is 10. Telling it to test more at once can take up more memory, however. If you’re running a lower-memory system (less than 2GB RAM), set this to 8192.
/dev/hda : is the hard drive to be tested.
I then said that I am always VERY reluctant to advise running terminal commands due to the potential for complete disaster. Does this command, as written, have the potential to do any harm?
badblocks, by default, will perform a read-only non-destructive test of the hard drive, and we don’t add any parameters that could affect that operation, so this should be perfectly safe. 🙂
Larry adds: This command is run from the Terminal. If you have never run a terminal command before, show this to a friend who has and work on this together.
IMPORTANT NOTE: The phrase “/dev/rdisk0” is the name of the hard drive you are refreshing. To determine what to enter here, go into Disk Utility (in your Applications/Utilities directory). You will see all your mounted disks in the left column. This list is indented. It will say something like “232.9 GB Hitachi” and underneath that will be your volume name indented, like “Macintosh HD”.
– Click on the top line (the “232.9 GB Hitachi” line in my example)
– Click on the Info button
– Read the “Disk Identifier” line. It will say something like “disk0”.
Where Disk Utility is saying “disk0” or “disk1” or “disk2”, … put an “r” in front. This is the name you use in the command (/dev/rdisk0 in this case).
NEW & Updated!
Edit smarter with Larry’s latest training, all available in our store.