ext4フォーマットしたパーティションで「Structure needs cleaning.」に対応した作業記録

監視カメラ用途で利用していたHDDで、OS起動時に該当パーティションがマウントできず起動できなくなっておりました。理由はマウント時に「mount: /mnt/camera: mount(2) system call failed: Structure needs cleaning.」エラーが発生し、そこから先に進まなくなっていた為でした。

当方はスマートカメラの監視データを/mnt/cameraに保存しており、かつ人体検知を並行して実行しております。該当HDDは常に読み書きが発生しており、常に読み書き両方とも20MByte/s以上発生しています。

状況確認

まずは状況を確認する為、該当HDDを確認します。力業ですが、fdisk -l /dev/sda~を繰り返し該当HDDを見つけます。

$ sudo fdisk -l /dev/sda・・・・・・・システムに利用されていたので割愛
$ sudo fdisk -l /dev/sdb・・・・・・・その他用途に利用されていたので割愛
$ sudo fdisk -l /dev/sdc・・・・・・・同上
$ sudo fdisk -l /dev/sdd・・・・・・・該当HDDを発見
Disk /dev/sdd: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: TOSHIBA MQ04ABD2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x55f9473c

Device     Boot     Start        End    Sectors   Size Id Type
/dev/sdd1            2048  585938943  585936896 279.4G 83 Linux
/dev/sdd2       585938944 3907029167 3321090224   1.5T 83 Linux

本当は/etc/fstabを見て見つければ良いのですが、/dev/sdd等ではなく、最近はUUIDで書くことが多い為、上記のように見つけています。

次に、smartctlでHDDが壊れていないかを確認します。一番最後のErrorsが出ていると壊れている兆候です(大抵の場合、もう利用するには危ない状況)。

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

=== START OF INFORMATION SECTION ===
Device Model:     TOSHIBA MQ04ABD200
Serial Number:    Z06ZT
LU WWN Device Id: 5 000039 a721025
Firmware Version: JT000A
User Capacity:    2,000,398,934,016 bytes [2.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Form Factor:      2.5 inches
Zoned Device:     Device managed zones
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.3, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Wed Nov 23 14:35:32 2022 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:                (  120) 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:        (   2) minutes.
Extended self-test routine
recommended polling time:        ( 334) 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: 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   050    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0005   100   100   050    Pre-fail  Offline      -       0
  3 Spin_Up_Time            0x0027   100   100   001    Pre-fail  Always       -       1646
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       37
  5 Reallocated_Sector_Ct   0x0033   100   100   050    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000b   100   100   050    Pre-fail  Always       -       0
  8 Seek_Time_Performance   0x0005   100   100   050    Pre-fail  Offline      -       0
  9 Power_On_Hours          0x0032   060   060   000    Old_age   Always       -       16024
 10 Spin_Retry_Count        0x0033   100   100   030    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       37
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       94
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       5
193 Load_Cycle_Count        0x0032   099   099   000    Old_age   Always       -       13990
194 Temperature_Celsius     0x0022   100   100   000    Old_age   Always       -       22 (Min/Max 8/60)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   253   000    Old_age   Always       -       0
220 Disk_Shift              0x0002   100   100   000    Old_age   Always       -       0
222 Loaded_Hours            0x0032   064   064   000    Old_age   Always       -       14404
223 Load_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0
224 Load_Friction           0x0022   100   100   000    Old_age   Always       -       0
226 Load-in_Time            0x0026   100   100   000    Old_age   Always       -       264
240 Head_Flying_Hours       0x0001   100   100   001    Pre-fail  Offline      -       0

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
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.

リカバリ

単純に/dev/sdd2のマウントに失敗するだけなのであれば、修復すればいい為、以下コマンドを実行しました。「Directories count wrong for group #8224」が1万回以上出ていたので、全部デフォルトのYesで回答する為、エンターキーを押しっぱなしにして回答すること10分程度、問題なく直りました。

$ sudo fsck.ext4 /dev/sdd2
e2fsck 1.46.5 (30-Dec-2021)
ext2fs_check_desc: Corrupt group descriptor: bad block for block bitmap
fsck.ext4: Group descriptors look bad... trying backup blocks...
/dev/sdd2 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create<y>? yes
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong for group #0 (23314, counted=22058).
Fix<y>? yes
Free blocks count wrong for group #1 (31545, counted=6530).
Fix<y>? yes
  ・
 割愛(同じメッセージが大量に・・・・・)
 ・
Directories count wrong for group #8224 (0, counted=1).
Fix<y>? yes
Free inodes count wrong for group #8512 (8192, counted=2358).
Fix<y>? yes
Directories count wrong for group #8512 (0, counted=1).
Fix<y>? yes
Free inodes count wrong for group #8704 (8192, counted=1447).
Fix<y>? yes
Directories count wrong for group #8704 (0, counted=1).
Fix<y>? yes
Free inodes count wrong for group #9568 (8192, counted=7585).
Fix<y>? yes
Directories count wrong for group #9568 (0, counted=1).
Fix<y>? yes
Free inodes count wrong for group #11328 (8192, counted=2332).
Fix<y>? yes
Directories count wrong for group #11328 (0, counted=1).
Fix<y>? yes
Free inodes count wrong (103784436, counted=103699526).
Fix<y>? yes
Padding at end of inode bitmap is not set. Fix<y>? yes

該当パーティションを再マウント

OS起動させるために、/etc/fstabから、壊れたパーティションをコメントアウトして起動していたので、そのコメントを外したのち、mount -a を実行し、マウントして欲しいパーティション全量をマウントさせます。


$ sudo mount -a
$ df
/dev/sdd2      1633356124 1069549496 480762992  69% /mnt/camera

無事に直り、HDDの中身も無事でした。

監視カメラ用途で利用している東芝HDDについて

当方の環境で間違いなく一番酷使しているHDD「MQ04ABD200」ですが、16台のカメラ画像を同時録画し、購入後2年間ずっと24/365で20M~45Byte/s読み書きしている状態で2年以上耐えてくれています。最近4TBの「MQ04ABB400」も購入できるようになりました。2TBではせいぜい2,3日しか保存できない為、4TBにリプレースしようかと考えています。

タグ . ブックマークする パーマリンク.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください