Unix/Disk
ファイルシステムをRawレベルコマンドで操作する
デバイスイメージを作成
- 1GBのイメージにパーティションを作成
# dd if=/dev/zero of=raw.bin bs=1M count=1024 bytes (1.1 GB) copied, 28.8497 s, 37.2 MB/s # fdisk raw.bin # 通常のデバイスと同様にパーティションを作成できる Device Boot Start End Blocks Id System raw.bin1 2048 2097151 1047552 83 Linux
loopデバイスを使う方法
- ファイルシステムを作成
# losetup -o $((512*2048)) /dev/loop0 raw.bin # mkfs.ext3 /dev/loop0 # mount /dev/loop0 /mnt
オフセットオプションの利用
- ファイルシステムを作成
# mkfs.vfat -F32 --offset 2048 raw.bin
- ファイルシステムとしてマウント
# mount -o offset=$((512*2048)) raw.bin mnt
- syslinuxでブートコードを書き込む
# syslinux -i raw.bin --offset $((512*2048))
HDDを診断する
0. ディスク情報確認
このあたりが要注意。
1 | Raw_Read_Error_Rate |
5 | Reallocated_Sector_Ct |
196 | Reallocation Event Count |
197 | Current_Pending_Sector |
198 | Offline_Uncorrectable |
# /usr/sbin/smartctl -a /dev/sda ... (省略) ... 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 0x000b 100 100 016 Pre-fail Always - 0 2 Throughput_Performance 0x0005 139 139 054 Pre-fail Offline - 72 3 Spin_Up_Time 0x0007 156 156 024 Pre-fail Always - 212 (Average 275) 4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 11 5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0 7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0 8 Seek_Time_Performance 0x0005 121 121 020 Pre-fail Offline - 34 9 Power_On_Hours 0x0012 099 099 000 Old_age Always - 9558 10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 11 192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 40 193 Load_Cycle_Count 0x0012 100 100 000 Old_age Always - 40 194 Temperature_Celsius 0x0002 122 122 000 Old_age Always - 49 (Lifetime Min/Max 25/58) 196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0 197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0 198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0 199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0
1. ショートテスト開始
# /usr/sbin/smartctl -t short /dev/sda smartctl version 5.38 [i486-slackware-linux-gnu] Copyright (C) 2002-8 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Short self-test routine immediately in off-line mode". Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 1 minutes for test to complete. Test will complete after Sun Nov 15 22:20:21 2015 Use smartctl -X to abort test.
Sun Nov 15 22:20:21 2015 にテスト終了予定。
2. テスト結果
時間まで待って結果を確認する
# /usr/sbin/smartctl -H smartctl version 5.38 [i486-slackware-linux-gnu] Copyright (C) 2002-8 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED # /usr/sbin/smartctl -l selftest /dev/sda smartctl version 5.38 [i486-slackware-linux-gnu] Copyright (C) 2002-8 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF READ SMART DATA SECTION === SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Short offline Completed without error 00% 9557 - # 2 Short offline Completed without error 00% 113 - # 3 Short offline Completed without error 00% 38 -
---
update at 2024/10/09 19:28:37
※注:当サイトは特定環境において確認できた事象のみを記述しています。他の環境での動作は一切保証しません。