Ubuntu Server 18.04.2 中未显示硬盘分区

Ubuntu Server 18.04.2 中未显示硬盘分区

我添加了 2 个旧的 2TB HDD。

我使用这个脚本为我的团队创建了分区:

#!/bin/bash
diskGB="$3"
sliceGB=1000
partsize=$(($sliceGB*1000*1000*1000/1024/1024 - 1))

for ((i=1; i <= $(($diskGB/$sliceGB)); i++))
do
    sudo parted -a optimal -- "$1" mkpart md"$i"-"$2" $(($i+($i-1)*$partsize))MiB $(($i+$i*$partsize))MiB
done
sudo parted "$1" print free

但即使重启后,其中一个硬盘的分区也没有显示出来。没有 /dev/sdb1 或 /dev/sdb2。

sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Command (? for help): p
Disk /dev/sdb: 3907029168 sectors, 1.8 TiB
Model: WDC WD20EARX-00P
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 967CBFE5-86B1-4F44-8F23-8925A09A30E8
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 2048, last usable sector is 3907029134
Partitions will be aligned on 2048-sector boundaries
Total free space is 782479 sectors (382.1 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048      1953124351   931.3 GiB   8300  md1-3
   2      1953126400      3906248703   931.3 GiB   8300  md2-3


sudo mdadm /dev/md1 --add /dev/sd sda   sda2  sda4  sdc   sdc2  sdc4  sdd1  sdd3  sde   sde2   sda1  sda3  sdb   sdc1  sdc3  sdd   sdd2  sdd4  sde1

有时使用 gdisk 写入后分区会出现,但随后分区很忙

sudo mdadm /dev/md1 --add /dev/sd
sda   sda2  sda4  sdb1  sdc   sdc2  sdc4  sdd1  sdd3  sde   sde2  
sda1  sda3  sdb   sdb2  sdc1  sdc3  sdd   sdd2  sdd4  sde1  
sudo mdadm /dev/md1 --add /dev/sdb1
mdadm: Cannot open /dev/sdb1: Device or resource busy
jokergermany@nas:~$ sudo mdadm /dev/md1 --add /dev/sdb2
mdadm: Cannot open /dev/sdb2: Device or resource busy

有什么建议吗?

sudo smartctl -a /dev/sdb
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.15.0-46-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Green
Device Model:     WDC WD20EARX-00PASB0
Serial Number:    
LU WWN Device Id: 5 0014ee 25c303777
Firmware Version: 51.0AB51
User Capacity:    2.000.398.934.016 bytes [2,00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS (minor revision not indicated)
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Fri Mar 29 12:31:15 2019 CET
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:      (   0) The previous self-test routine completed
                    without error or no self-test has ever 
                    been run.
Total time to complete Offline 
data collection:        (41460) seconds.
Offline data collection
capabilities:            (0x7b) SMART execute Offline immediate.
                    Auto Offline data collection on/off support.
                    Suspend Offline collection upon new
                    command.
                    Offline surface scan supported.
                    Self-test supported.
                    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:    ( 399) minutes.
Conveyance self-test routine
recommended polling time:    (   5) minutes.
SCT capabilities:          (0x3035) SCT Status 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     0x002f   200   200   051    Pre-fail  Always       -       1
  3 Spin_Up_Time            0x0027   166   157   021    Pre-fail  Always       -       6700
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       511
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   058   058   000    Old_age   Always       -       30905
 10 Spin_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       372
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       78
193 Load_Cycle_Count        0x0032   001   001   000    Old_age   Always       -       1158275
194 Temperature_Celsius     0x0022   118   098   000    Old_age   Always       -       32
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   200   200   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   200   200   000    Old_age   Offline      -       3

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.

grep sdb /var/log/syslog
Mar 29 06:41:42 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 07:11:42 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 07:41:43 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 08:11:42 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 08:41:42 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 09:11:42 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 09:41:42 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 10:11:42 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 10:41:43 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 11:11:42 nas smartd[1534]: Device: /dev/sdb [SAT], open() failed: No such device
Mar 29 11:21:29 nas kernel: [    2.706955] sd 2:0:0:0: [sdb] 3907029168 512-byte logical blocks: (2.00 TB/1.82 TiB)
Mar 29 11:21:29 nas kernel: [    2.706960] sd 2:0:0:0: [sdb] 4096-byte physical blocks
Mar 29 11:21:29 nas kernel: [    2.706974] sd 2:0:0:0: [sdb] Write Protect is off
Mar 29 11:21:29 nas kernel: [    2.706975] sd 2:0:0:0: [sdb] Mode Sense: 00 3a 00 00
Mar 29 11:21:29 nas kernel: [    2.706991] sd 2:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Mar 29 11:21:29 nas kernel: [    3.201454]  sdb: sdb1 sdb2
Mar 29 11:21:29 nas kernel: [    3.201790] sd 2:0:0:0: [sdb] Attached SCSI disk
Mar 29 11:21:30 nas smartd[1603]: Device: /dev/sdb, type changed from 'scsi' to 'sat'
Mar 29 11:21:30 nas smartd[1603]: Device: /dev/sdb [SAT], opened
Mar 29 11:21:30 nas smartd[1603]: Device: /dev/sdb [SAT], WDC WD20EARX-00PASB0, S/N:WD-WMAZA8492756, WWN:5-0014ee-25c303777, FW:51.0AB51, 2.00 TB
Mar 29 11:21:30 nas smartd[1603]: Device: /dev/sdb [SAT], found in smartd database: Western Digital Green
Mar 29 11:21:33 nas smartd[1603]: Device: /dev/sdb [SAT], is SMART capable. Adding to "monitor" list.
Mar 29 11:21:33 nas smartd[1603]: Device: /dev/sdb [SAT], state read from /var/lib/smartmontools/smartd.WDC_WD20EARX_00PASB0-WD_WMAZA8492756.ata.state
Mar 29 11:21:33 nas smartd[1603]: Device: /dev/sdb [SAT], open device worked again, warning condition reset after 1 email
Mar 29 11:21:34 nas smartd[1603]: Device: /dev/sdb [SAT], SMART Prefailure Attribute: 3 Spin_Up_Time changed from 164 to 166
Mar 29 11:21:34 nas smartd[1603]: Device: /dev/sdb [SAT], SMART Usage Attribute: 194 Temperature_Celsius changed from 116 to 118
Mar 29 11:21:34 nas smartd[1603]: Device: /dev/sdb [SAT], state written to /var/lib/smartmontools/smartd.WDC_WD20EARX_00PASB0-WD_WMAZA8492756.ata.state
Mar 29 11:35:54 nas kernel: [  904.673644]  sdb: sdb1 sdb2
Mar 29 11:51:35 nas smartd[1603]: Device: /dev/sdb [SAT], SMART Usage Attribute: 194 Temperature_Celsius changed from 118 to 117
Mar 29 12:21:36 nas smartd[1603]: Device: /dev/sdb [SAT], SMART Usage Attribute: 194 Temperature_Celsius changed from 117 to 118

答案1

mdadm 发现了一个旧的 raid 签名并使用了 sdb...

cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid1] [raid10] 
md3 : active raid5 sde1[3] sda3[0] sdd3[2]
      1952858112 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
      bitmap: 0/8 pages [0KB], 65536KB chunk

md2 : active raid5 sda2[0] sdd2[2]
      976429056 blocks super 1.2 level 5, 512k chunk, algorithm 2 [2/2] [UU]
      bitmap: 0/8 pages [0KB], 65536KB chunk

md1 : active raid5 sda1[0] sdd1[1]
      976429056 blocks super 1.2 level 5, 512k chunk, algorithm 2 [2/2] [UU]
      bitmap: 0/8 pages [0KB], 65536KB chunk

md4 : active raid5 sde2[3] sda4[0] sdd4[2]
      1952858112 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
      bitmap: 0/8 pages [0KB], 65536KB chunk

md127 : inactive sdb[1](S)
      1953514496 blocks

unused devices: <none>

解决方案:

sudo mdadm --stop /dev/md127 
sudo mdadm --zero-superblock /dev/sdb

相关内容