SET MAXされたドライブを戻す

 このSET MAXされたドライブを全部使えるようにしたい。

kinneko@llmbuild:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
(snip)
sdb      8:16   0 232.9G  0 disk
├─sdb1   8:17   0 220.9G  0 part
├─sdb2   8:18   0     1K  0 part
└─sdb5   8:21   0    12G  0 part

 ATA のSET MAXで容量を制限されたドライブは、通常は HPA (Host Protected Area) を hdparm -Nで解除することで、全エリアが使えるようになる。-Nオプションでは、現在の最大セクタ数とドライブ本来の最大セクタ数を表示する。

$ sudo hdparm -N /dev/sdb
/dev/sdb:
max sectors   = 488397168/781422768, HPA is enabled

 このドライブでは、左右の数字が一致していないので、SET MAXされているのがわかる。右の数字が本来の容量だ。

 中身はなんだったっけ...

$ lsblk -f /dev/sdb
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sdb
├─sdb1
│    ext4   1.0         d4b7ff5f-a389-43ef-ba48-a60b41f98922
├─sdb2
│
└─sdb5
swap   1           5b6bc11a-eb46-48e3-aa3f-9727e93c6c32

 これまた古いね... homeにもなんもないし消しても問題はなさそう。

$ sudo mount /dev/sdb1 /mnt
$ cat /mnt/etc/os-release
NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
$ sudo umount /mnt

 一時的に全容量へ戻すには、以下を実行する。この設定は、電源断・ハードウェアリセットで元に戻ってしまう。

 sudo hdparm -N 781422768 /dev/sdb

 恒久的に戻す場合は p を付けて実行する。今回はこちらで。

$ sudo hdparm -N p781422768 /dev/sdb
/dev/sdb:
setting max visible sectors to 781422768 (permanent)
max sectors   = 781422768/781422768, HPA is disabled

 確認のために、いったん完全に電源を切って再投入する。ドライブをあとで入れてないので、ドライブ名が変わった。

 SET MAXは無効になっている。

$ sudo hdparm -N /dev/sda

 /dev/sda:

 max sectors = 781422768/781422768, HPA is disabled

 なんかドライブのアクセス音がジジジジとうるさい感じ。使わないほうがいいかも。

 うーん、これはダメだな... ECCでも訂正できなかった読み取りエラーが13回もあるわ。

$ sudo smartctl -a /dev/sda
(snip)
ATA Error Count: 13
...
Error: UNC at LBA = 5000000
Error: UNC at LBA = 5033941
Error: UNC at LBA = 5033941
Error: UNC at LBA = 5033941
Error: UNC at LBA = 8000000

 ダメな部分をさわらないようにSET MAXされていたのかもな...

 とりあえず、セルフテストを走らせる。

 134分後に処理が終わったら、もう一度状態を確認してみる。

$ sudo smartctl -t long /dev/sda
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.15.0-131-generic] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

 === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===

 Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".

 Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.

 Testing has begun.

 Please wait 134 minutes for test to complete.

 Test will complete after Tue Aug 18 08:01:07 2026 UTC

 Use smartctl -X to abort test.

 問題ありそうなところ以外は基本的に静かだな。

 終わった感じ。確認する。

 ううう、Extended SMART Self-test(ロングテスト)が読み取りエラーで途中終了している。10%くらいのところで死んでいるので、テストは早々に終わっていたようだ。うーん。

$ sudo smartctl -l selftest /dev/sda
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.15.0-131-generic] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

 === 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 Extended offline Completed: read failure 90% 1952 5370713

 ディスク先頭から約2.56 GiB付近に実際に読めない領域が存在する感じね。これは破棄ですねぇ。さようなら。

$ sudo smartctl -a /dev/sda
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.15.0-131-generic] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

 === START OF INFORMATION SECTION ===

 Model Family: Seagate Barracuda 7200.8

Device Model:     ST3400832AS
Serial Number:    5NF25GXB
Firmware Version: 4.61
User Capacity:    400,088,457,216 bytes [400 GB]
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA/ATAPI-7 (minor revision not indicated)
Local Time is:    Tue Aug 18 08:24:40 2026 UTC
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: (0x82) Offline data collection activity

 was completed without error.

 Auto Offline Data Collection: Enabled.

 Self-test execution status: ( 121) The previous self-test completed having

 the read element of the test failed.

 Total time to complete Offline

 data collection: ( 430) seconds.

 Offline data collection

 capabilities: (0x5b) SMART execute Offline immediate.

 Auto Offline data collection on/off support.

 Suspend Offline collection upon new

 command.

 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: ( 1) minutes.

 Extended self-test routine

 recommended polling time: ( 134) minutes.

 SMART Attributes Data Structure revision number: 10

 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 048 046 006 Pre-fail Always - 125983305

 3 Spin_Up_Time 0x0003 094 094 000 Pre-fail Always - 0

 4 Start_Stop_Count 0x0032 098 098 020 Old_age Always - 2639

 5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 0

 7 Seek_Error_Rate 0x000f 078 060 030 Pre-fail Always - 8732339973

 9 Power_On_Hours 0x0032 098 098 000 Old_age Always - 1955

 10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0

 12 Power_Cycle_Count 0x0032 099 099 020 Old_age Always - 1676

 194 Temperature_Celsius 0x0022 042 056 000 Old_age Always - 42 (0 17 0 0 0)

 195 Hardware_ECC_Recovered 0x001a 048 046 000 Old_age Always - 125983305

 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 200 000 Old_age Always - 0

 200 Multi_Zone_Error_Rate 0x0000 100 253 000 Old_age Offline - 0

 202 Data_Address_Mark_Errs 0x0032 100 253 000 Old_age Always - 0

 SMART Error Log Version: 1

 ATA Error Count: 13 (device log contains only the most recent five errors)

CR = Command Register [HEX]
FR = Features Register [HEX]
SC = Sector Count Register [HEX]
SN = Sector Number Register [HEX]
CL = Cylinder Low Register [HEX]
CH = Cylinder High Register [HEX]
DH = Device/Head Register [HEX]
DC = Device Command Register [HEX]
ER = Error register [HEX]
ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

 Error 13 occurred at disk power-on lifetime: 1658 hours (69 days + 2 hours)

 When the command that caused the error occurred, the device was active or idle.

 After command completion occurred, registers were:

 ER ST SC SN CL CH DH

 -- -- -- -- -- -- --

 40 51 01 40 4b 4c 40 Error: UNC at LBA = 0x004c4b40 = 5000000

 Commands leading to the command that caused the error were:

 CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

 -- -- -- -- -- -- -- -- ---------------- --------------------

 42 00 00 15 48 4c 40 00 00:13:33.709 READ VERIFY SECTOR(S) EXT

 42 00 00 15 28 4c 40 00 00:13:33.651 READ VERIFY SECTOR(S) EXT

 42 00 00 15 08 4c 40 00 00:13:33.593 READ VERIFY SECTOR(S) EXT

 42 00 00 15 e8 4b 40 00 00:13:33.534 READ VERIFY SECTOR(S) EXT

 42 00 00 15 c8 4b 40 00 00:13:33.475 READ VERIFY SECTOR(S) EXT

 Error 12 occurred at disk power-on lifetime: 1657 hours (69 days + 1 hours)

 When the command that caused the error occurred, the device was active or idle.

 After command completion occurred, registers were:

 ER ST SC SN CL CH DH

 -- -- -- -- -- -- --

 40 51 01 d5 cf 4c 40 Error: UNC at LBA = 0x004ccfd5 = 5033941

 Commands leading to the command that caused the error were:

 CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

 -- -- -- -- -- -- -- -- ---------------- --------------------

 42 00 00 15 c8 4c 40 00 04:42:28.073 READ VERIFY SECTOR(S) EXT

 42 00 00 15 a8 4c 40 00 04:42:28.920 READ VERIFY SECTOR(S) EXT

 42 00 00 15 88 4c 40 00 04:42:28.860 READ VERIFY SECTOR(S) EXT

 42 00 00 15 68 4c 40 00 04:42:28.800 READ VERIFY SECTOR(S) EXT

 42 00 00 15 48 4c 40 00 04:42:28.740 READ VERIFY SECTOR(S) EXT

 Error 11 occurred at disk power-on lifetime: 1654 hours (68 days + 22 hours)

 When the command that caused the error occurred, the device was active or idle.

 After command completion occurred, registers were:

 ER ST SC SN CL CH DH

 -- -- -- -- -- -- --

 40 51 01 d5 cf 4c 40 Error: UNC at LBA = 0x004ccfd5 = 5033941

 Commands leading to the command that caused the error were:

 CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

 -- -- -- -- -- -- -- -- ---------------- --------------------

 42 00 00 15 c8 4c 40 00 01:39:47.704 READ VERIFY SECTOR(S) EXT

 42 00 00 15 a8 4c 40 00 01:39:47.640 READ VERIFY SECTOR(S) EXT

 42 00 00 15 88 4c 40 00 01:39:47.581 READ VERIFY SECTOR(S) EXT

 42 00 00 15 68 4c 40 00 01:39:47.523 READ VERIFY SECTOR(S) EXT

 42 00 00 15 48 4c 40 00 01:39:47.464 READ VERIFY SECTOR(S) EXT

 Error 10 occurred at disk power-on lifetime: 1649 hours (68 days + 17 hours)

 When the command that caused the error occurred, the device was active or idle.

 After command completion occurred, registers were:

 ER ST SC SN CL CH DH

 -- -- -- -- -- -- --

 40 51 01 d5 cf 4c 40 Error: UNC at LBA = 0x004ccfd5 = 5033941

 Commands leading to the command that caused the error were:

 CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

 -- -- -- -- -- -- -- -- ---------------- --------------------

 42 00 00 15 c8 4c 40 00 00:11:50.769 READ VERIFY SECTOR(S) EXT

 42 00 00 15 a8 4c 40 00 00:11:50.710 READ VERIFY SECTOR(S) EXT

 42 00 00 15 88 4c 40 00 00:11:50.651 READ VERIFY SECTOR(S) EXT

 42 00 00 15 68 4c 40 00 00:11:50.593 READ VERIFY SECTOR(S) EXT

 42 00 00 15 48 4c 40 00 00:11:50.535 READ VERIFY SECTOR(S) EXT

 Error 9 occurred at disk power-on lifetime: 1609 hours (67 days + 1 hours)

 When the command that caused the error occurred, the device was active or idle.

 After command completion occurred, registers were:

 ER ST SC SN CL CH DH

 -- -- -- -- -- -- --

 40 51 01 00 12 7a 40 Error: UNC at LBA = 0x007a1200 = 8000000

 Commands leading to the command that caused the error were:

 CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

 -- -- -- -- -- -- -- -- ---------------- --------------------

 42 00 00 15 08 7a 40 00 01:39:26.566 READ VERIFY SECTOR(S) EXT

 42 00 00 15 e8 79 40 00 01:39:26.505 READ VERIFY SECTOR(S) EXT

 42 00 00 15 c8 79 40 00 01:39:26.446 READ VERIFY SECTOR(S) EXT

 42 00 00 15 a8 79 40 00 01:39:26.386 READ VERIFY SECTOR(S) EXT

 42 00 00 15 88 79 40 00 01:39:26.326 READ VERIFY SECTOR(S) EXT

 SMART Self-test log structure revision number 1

 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error

1 Extended offline Completed: read failure 90% 1952 5370713

 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

 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.


オリジナル投稿:
SET MAXされたドライブを戻す|kinneko|pixivFANBOX
https://kinneko.fanbox.cc/posts/12423907