とりあえずMacBookの充電関係が修理できたので起動時間が遅いのと,何かしらアプリケーションの立ち上がりが遅いのが気になりだした。HDDからSSDに交換するととても早くなるようなことが,散見されていたので自分でも試してみたくなった。
iPodのSDXCに使っているせいもあってサムスン製品の信頼度は高い。程度の良さそうな(?)Samsung EVO 850の120GBを入手して,MacBookの純正と交換する。
この形式のMacBookはバッテリー交換やHDD交換のメンテナンスがやりやすく,ラッチを上げるとHDDにアクセスできるのでビスをゆるめてHDDを取り外しSSDと入れ替えする。
MacOSが認識できないファイルシステムなのでディスクユーティリティーでフォーマットして,システムの日付を過去の日付にしておく。
事前に作っておいたEl Captainのインストールメディア(160GBHDD)から起動して内蔵SSDにMacOSをインストールする。
今回はHDDからSSDへの変更なので起動ディスクをUSBで外付けにしてそのまま転送する。MacOS El Captainをインストール後に移行アシスタントを使ってHDDからSSDにユーザーデータやネットワークの設定を移行する。
転送中のプログレスバーだけでなく転送速度も表示してくれるのがありがたい。
HDDの容量は減ってしまったけどシステムの起動やアプリケーションの立ち上がりが,かなりスピードアップした。
純正HDDはなぜが1.5Gbpsでしかネゴシエーションしていなくて立ち上がりが遅い原因はディスクI/Oだったようだ。
SSDは何度も書き込みを繰り返すと寿命がくるので交換したSSDの状態をしりたいのでsmartmontoolsをインストールする。
brewをインストールするとビルドに必要なXcode Command Line Toolsも一緒にインストールしてくれて簡単で助かるなぁ。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install smartmontools
smartmontoolがインストール出来たのでsmartctlを使ってSSDの健全度を把握する。
$ smartctl -A /dev/disk0s2
$ smartctl -A /dev/disk0s2
smartctl 6.6 2017-11-05 r4594 [Darwin 14.5.0 x86_64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 100 100 046 Pre-fail Always - 0
2 Throughput_Performance 0x0005 100 100 030 Pre-fail Offline - 0
3 Spin_Up_Time 0x0003 100 100 025 Pre-fail Always - 0
4 Start_Stop_Count 0x0032 093 093 000 Old_age Always - 33961
5 Reallocated_Sector_Ct 0x0033 100 100 024 Pre-fail Always - 0
7 Seek_Error_Rate 0x000f 100 100 047 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 100 100 019 Pre-fail Offline - 0
9 Power_On_Hours 0x0032 064 064 000 Old_age Always - 18172
10 Spin_Retry_Count 0x0013 100 100 020 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 096 096 000 Old_age Always - 20122
160 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 095 095 000 Old_age Always - 859117454744
193 Load_Cycle_Count 0x0032 072 072 000 Old_age Always - 576690
194 Temperature_Celsius 0x0022 100 100 000 Old_age Always - 32 (Min/Max 4/54)
195 Hardware_ECC_Recovered 0x001a 100 100 000 Old_age Always - 0
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x003e 200 253 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x000f 100 100 060 Pre-fail Always - 0
203 Run_Out_Cancel 0x0002 100 100 000 Old_age Always - 0
240 Head_Flying_Hours 0x003e 200 200 000 Old_age Always - 0
254 Free_Fall_Sensor 0x0032 100 100 000 Old_age Always - 7467
$ smartctl -i /dev/disk0s2
$ smartctl -i /dev/disk0s2
smartctl 6.6 2017-11-05 r4594 [Darwin 15.0.0 x86_64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: Samsung SSD 850 120GB
Serial Number:
LU WWN Device Id: 5 002538 d427a203c
Firmware Version: MVT01B6Q
User Capacity: 120,034,123,776 bytes [120 GB]
Sector Size: 512 bytes logical/physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: ACS-2, ATA8-ACS T13/1699-D revision 4c
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is: Thu May 31 20:10:16 2018 JST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
$ smartctl -a /dev/disk0s2
$ smartctl -a /dev/disk0s2
smartctl 6.6 2017-11-05 r4594 [Darwin 15.0.0 x86_64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: Samsung SSD 850 120GB
Serial Number:
LU WWN Device Id: 5 002538 d427a203c
Firmware Version: MVT01B6Q
User Capacity: 120,034,123,776 bytes [120 GB]
Sector Size: 512 bytes logical/physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: ACS-2, ATA8-ACS T13/1699-D revision 4c
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is: Thu May 31 20:10:22 2018 JST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 0) seconds.
Offline data collection
capabilities: (0x53) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
No Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 64) minutes.
SCT capabilities: (0x003d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 16
12 Power_Cycle_Count 0x0032 099 099 000 Old_age Always - 34
177 Wear_Leveling_Count 0x0013 100 100 000 Pre-fail Always - 0
179 Used_Rsvd_Blk_Cnt_Tot 0x0013 100 100 010 Pre-fail Always - 0
181 Program_Fail_Cnt_Total 0x0032 100 100 010 Old_age Always - 0
182 Erase_Fail_Count_Total 0x0032 100 100 010 Old_age Always - 0
183 Runtime_Bad_Block 0x0013 100 100 010 Pre-fail Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0032 065 059 000 Old_age Always - 35
195 Hardware_ECC_Recovered 0x001a 200 200 000 Old_age Always - 0
199 UDMA_CRC_Error_Count 0x003e 100 100 000 Old_age Always - 0
235 Unknown_Attribute 0x0012 099 099 000 Old_age Always - 24
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 236397927
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
255 0 65535 Read_scanning was never started
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
けどsmartctlのRAW VALUE(生の値)の十進数表記を見てもよくわからないのでaskubuntuのフォーラムにあったスクリプトをつかったらSSDの状態がわかりやすく出力された。
ssdchk.sh
#!/bin/bash
#######################################
# Variables #
#######################################
SSD_DEVICE="/dev/disk0s2"
ON_TIME_TAG="Power_On_Hours"
WEAR_COUNT_TAG="Wear_Leveling_Count"
LBAS_WRITTEN_TAG="Total_LBAs_Written"
LBA_SIZE=512 # Value in bytes
BYTES_PER_MB=1048576
BYTES_PER_GB=1073741824
BYTES_PER_TB=1099511627776
#######################################
# Get total data written... #
#######################################
# Get SMART attributes
SMART_INFO=$(sudo /usr/local/Cellar/smartmontools/6.6/bin/smartctl -A "$SSD_DEVICE")
# Extract required attributes
ON_TIME=$(echo "$SMART_INFO" | grep "$ON_TIME_TAG" | awk '{print $10}')
WEAR_COUNT=$(echo "$SMART_INFO" | grep "$WEAR_COUNT_TAG" | awk '{print $4}' | sed 's/^0*//')
LBAS_WRITTEN=$(echo "$SMART_INFO" | grep "$LBAS_WRITTEN_TAG" | awk '{print $10}')
# Convert LBAs -> bytes
BYTES_WRITTEN=$(echo "$LBAS_WRITTEN * $LBA_SIZE" | bc)
MB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_MB" | bc)
GB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_GB" | bc)
TB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_TB" | bc)
# Output results...
echo "------------------------------"
echo " SSD Status: $SSD_DEVICE"
echo "------------------------------"
echo " On time: $(echo $ON_TIME | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta') hr"
echo "------------------------------"
echo " Data written:"
echo " MB: $(echo $MB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo " GB: $(echo $GB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo " TB: $(echo $TB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo "------------------------------"
echo " Mean write rate:"
echo " MB/hr: $(echo "scale=3; $MB_WRITTEN / $ON_TIME" | bc | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo "------------------------------"
echo " Drive health: ${WEAR_COUNT} %"
echo "------------------------------"
$ ./ssdchk.sh
------------------------------
SSD Status: /dev/disk0s2
------------------------------
On time: 16 hr
------------------------------
Data written:
MB: 117247.710
GB: 114.499
TB: .111
------------------------------
Mean write rate:
MB/hr: 7327.981
------------------------------
Drive health: 100 %
必要な部分が抜き出されて分かりやすい。そしてこのSSDはあまり使われていない。
smartctlは便利でいいのだけどUSBなどで外付けのHDDやSSDの状態を知りたいときにはあまり使えないので(いろいろ道具はあるみたいだけどWindows用だし..)SATA接続して状態を把握した。
ネゴシエーションスピードも3Gbps出ているのでこの時代のマシンでは上等だと思う。
よく分かっていないがTRIM機能を有効にしたほうが早くなるようなのでTRIMを有効にする。
trim有効
$ sudo trimforce enable
Password:
IMPORTANT NOTICE: This tool force-enables TRIM for all relevant attached
devices, even though such devices may not have been validated for data
integrity while using TRIM. Use of this tool to enable TRIM may result in
unintended data loss or data corruption. It should not be used in a commercial
operating environment or with important data. Before using this tool, you
should back up all of your data and regularly back up data while TRIM is
enabled. This tool is provided on an “as is” basis. APPLE MAKES NO WARRANTIES,
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
REGARDING THIS TOOL OR ITS USE ALONE OR IN COMBINATION WITH YOUR DEVICES,
SYSTEMS, OR SERVICES. BY USING THIS TOOL TO ENABLE TRIM, YOU AGREE THAT, TO THE
EXTENT PERMITTED BY APPLICABLE LAW, USE OF THE TOOL IS AT YOUR SOLE RISK AND
THAT THE ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY AND
EFFORT IS WITH YOU.
Are you sure you wish to proceed (y/N)? y
Your system will immediately reboot when this is complete.
Is this OK (y/N)? y
Enabling TRIM...
.
.
Operation succeeded. Your system will reboot momentarily, please wait...
自動的に再起動がかかるんだな. 起動時間はどうなったかというと
デバイス種類 | 経過時間 | 状態 |
---|---|---|
HDD | 1分53秒 | ユーザ選択画面 |
SSD | 28秒 | ユーザ選択画面 |
起動中のプログレスバーが異常に早いし,起動時間は半分以下になっている。 もうMacBookが発売されて10年経っているけど,これほど息の長いマシンになるとは思わなかった。