What free or open source software can I use with Mac hardware to verify integrity of every block of a disk where Core Storage is used?
Solution 1:
Install badblocks on Mac OS X (Leopard or less)
Mac OS X Ext2 Filesystem includes a badblocks
that can be used with Mac OS X.
Credit: doctormac: How to check for bad blocks on a mac with Mac OS X? (2011) reference to Bad blocks? badblocks! | Terminal (2007)
Solution 2:
Install badblocks on OS X (Lion or greater)
For me, installation of Ext2 Filesystem 1.4d4 (2006-12-03) fails on Build 12A269 of OS X 10.8.
Whether installation is possible on 10.7.x, I don't know.
badblocks
is currently not within MacPorts.
In 2009 someone mentioned using portutil
to install badblocks
but I don't know whether or how to go about that with Mountain Lion.
badblocks installed
Later, with Pacifist, I found badblocks
installed. (Either the result of a long ago successful installation of Ext2 Filesystem, or a partial result of today's supposedly failed installation).
I used it to check all blocks of a slice that is currently spare, then copied it to that slice:
sh-3.2$ gjp22$ diskutil list disk0
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *750.2 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS swap 32.0 GB disk0s2
3: Apple_Journal 536.9 MB disk0s3
4: Apple_HFS spare 671.1 MB disk0s4
5: Apple_CoreStorage 99.5 GB disk0s5
6: Apple_Boot Boot OS X 650.0 MB disk0s6
7: Apple_CoreStorage 616.3 GB disk0s7
8: Apple_Boot Boot OS X 134.2 MB disk0s8
sh-3.2$ gjp22$ sudo /usr/local/sbin/badblocks -v /dev/disk0s4
/usr/local/sbin/badblocks: Resource busy while trying to determine device size
sh-3.2$ gjp22$ diskutil unmount /Volumes/spare
Volume spare on disk0s4 unmounted
sh-3.2$ gjp22$ sudo /usr/local/sbin/badblocks -v /dev/disk0s4
Checking blocks 0 to 655360
Checking for bad blocks (read-only test): done
Pass completed, 0 bad blocks found.
sh-3.2$ gjp22$ diskutil mount /dev/disk0s4
Volume spare on /dev/disk0s4 mounted
sh-3.2$ gjp22$ sudo ditto /usr/local/sbin/badblocks /Volumes/spare/sbin/badblocks
badblocks alone
I tried using the copy of badblocks
with Recovery OS. It did not work:
-bash-3.2# sw_vers
ProductName: Mac OS X
ProductVersion: 10.8
BuildVersion: 12A269
-bash-3.2# mount | grep "on / "
/dev/disk1s2 on / (hfs, local, read-only)
-bash-3.2# diskutil list disk1
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme *1.3 GB disk1
1: Apple_partition_map 30.7 KB disk1s1
2: Apple_HFS Mac OS X Base System 1.3 GB disk1s2
-bash-3.2# diskutil unmount /Volumes/swap
Volume swap on disk0s2 unmounted
-bash-3.2# /Volumes/spare/sbin/badblocks -v /dev/disk0s2
Illegal instruction: 4
-bash-3.2#
Tentative conclusion
A full installation of OS X on a separate physical disk, followed by a partially successful installation of Ext2 Filesystem – to include at least badblocks
– should allow a complete check of any other disk.
Solution 3:
Start Ubuntu and run badblocks
Use an Ubuntu disc that works with your Mac, then run badblocks
with appropriate options.
Ubuntu Manpage: badblocks - search a device for bad blocks
DVD compatible with a MacBookPro5,2
- Ubuntu 8.10
DVDs not compatible with a MacBookPro5,2
- Ubuntu 12.04 desktop i386
- Xubuntu 12.04.1 desktop i386
- Ubuntu 12.10 desktop i386
Example A
Adapted from a Mac-oriented post in the ZEVO support forum:
I ran
badblocks
onto a dedicated PC with Ubuntu Live, disk connected via SATA 6.I opened four Terminal windows and began:
- two instances with option
-n
- two instances with options
-wsv
– at intervals of ten minutes (the second instance begun ten minutes after the first, and so on).
After seventy hours it was around 75% -n and 50% -w.
Yesterday I decided to stop
badblocks
and review S.M.A.R.T. values – a comparison with results of a first run ofsmartctl
(after unboxing this new disk). Nothing had changed.
That's not Mac hardware, but as some Mac hardware can use SATA 6, I like this example; a pleasantly thought-provoking approach to multiple concurrent runs of badblocks
against a single disk.
Example B
Started from Ubuntu 8.10, a partial test of a 750 GB Seagate Momentus® XT ST750LX003-1AC154 solid state hybrid internal to a MacBookPro5,2
ubuntu@ubuntu:/dev$ man badblocks
ubuntu@ubuntu:/dev$ badblocks -n -s -v /dev/sda
badblocks: Permission denied while trying to determine device size
ubuntu@ubuntu:/dev$ sudo badblocks -n -s -v /dev/sda
Checking for bad blocks in non-destructive read-write mode
From block 0 to 732574583
Checking for bad blocks (non-destructive read-write test)
Testing with random pattern: ^C1.30% done, 9:34 elapsed
Interrupt caught, cleaning up
ubuntu@ubuntu:/dev$ sudo badblocks -n -s -v /dev/sda
Checking for bad blocks in non-destructive read-write mode
From block 0 to 732574583
Checking for bad blocks (non-destructive read-write test)
Testing with random pattern: 0.23% done, 1:47 elapsed
0.92% done, 7:09 elapsed
1.00% done, 7:46 elapsed
25.13% done, 3:49:32 elapsed
25.13% done, 3:49:33 elapsed
25.13% done, 3:49:34 elapsed
25.13% done, 3:49:35 elapsed
I aborted the run to start OS X.
That was around 7.75 minutes for one percent, so for badblocks with those options to test that number of blocks (732574583) might take around 12.9 hours.
Overviews of the disk used for that test
macbookpro08-centrim:~ gjp22$ diskutil list disk0
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *750.2 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS swap 32.0 GB disk0s2
3: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF 536.9 MB disk0s3
4: Apple_HFS spare 671.1 MB disk0s4
5: Apple_CoreStorage 99.5 GB disk0s5
6: Apple_Boot Boot OS X 650.0 MB disk0s6
7: Apple_CoreStorage 616.3 GB disk0s7
8: Apple_Boot Boot OS X 134.2 MB disk0s8
macbookpro08-centrim:~ gjp22$ sudo gpt -r show -l /dev/disk0
Password:
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - "EFI System Partition"
409640 62500000 2 GPT part - "Apple_HFS_Untitled_2"
62909640 262144
63171784 1048576 3 GPT part - "journal"
64220360 1310720 4 GPT part - "spare"
65531080 194305104 5 GPT part - "OS"
259836184 1269544 6 GPT part - "Boot OS X"
261105728 1203781256 7 GPT part - "gjp22-cs"
1464886984 262144 8 GPT part - "Booter"
1465149128 7
1465149135 32 Sec GPT table
1465149167 1 Sec GPT header
If I understand correctly: around 1,465,149,169 blocks. So why might badblocks
determine that only 732,574,583 are to be tested? If not related to SSHD (see below) this might be a separate question.
Related
Solid State Hybrid Technology: HDD SSD SSHD | Seagate
In Super User:
- Is badblocks in read-write mode as effective with a solid state hybrid drive as with a hard disk drive?
For a simplified edition of this answer, I'd like to perform a similar test with a hard disk drive (not a hybrid) as an example.