我们有一个带有外部驱动器的小盒子,用于备份配置集。我发现问题只是在重新启动或驱动器从任何未知事件切换/dev/sda1
到/dev/sdb1
.
如何规避此问题或配置 fstab 以尝试这两个位置?
/dev/sda1 /stor ext4 defaults,noatime,noexec 0 0
你可以看到我做了很多调试:
root@nsa:~# mount /stor
mount: special device /dev/sda1 does not exist
正如您在下面看到的,我在编写问题时做了一些调试。
系统日志:
Jul 16 09:48:48 nsa kernel: [167416.395274] EXT4-fs warning (device sda1):
__ext4_read_dirblock:908: error reading directory block (ino 2, block 0)
#df -h
之前umount
:
/dev/sda1 1.4T 185G 1.1T 15% /stor
#dmesg
:
[ 170.431715] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
[119366.019470] usb 1-1.2: USB disconnect, device number 4
[119366.297601] usb 1-1.2: new high-speed USB device number 6 using dwc_otg
[119366.398979] usb 1-1.2: New USB device found, idVendor=1058, idProduct=1021
[119366.399013] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[119366.399029] usb 1-1.2: Product: Ext HDD 1021
[119366.399047] usb 1-1.2: Manufacturer: Western Digital
[119366.399063] usb 1-1.2: SerialNumber: 5743415A4132343133343334
[119366.400719] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[119366.403826] scsi1 : usb-storage 1-1.2:1.0
[119367.398875] scsi 1:0:0:0: Direct-Access WD Ext HDD 1021 2002 PQ: 0 ANSI: 4
[119367.401608] sd 1:0:0:0: Attached scsi generic sg0 type 0
[119367.402505] sd 1:0:0:0: [sdb] 2930272256 512-byte logical blocks: (1.50 TB/1.36 TiB)
[119367.403524] sd 1:0:0:0: [sdb] Test WP failed, assume Write Enabled
[119367.404593] sd 1:0:0:0: [sdb] Asking for cache data failed
[119367.404623] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[119367.407157] sd 1:0:0:0: [sdb] Test WP failed, assume Write Enabled
[119367.410142] sd 1:0:0:0: [sdb] Asking for cache data failed
[119367.410185] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[119374.143786] sdb: sdb1
[119374.146995] sd 1:0:0:0: [sdb] Test WP failed, assume Write Enabled
[119374.149166] sd 1:0:0:0: [sdb] Asking for cache data failed
[119374.149203] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[119374.149231] sd 1:0:0:0: [sdb] Attached SCSI disk
[153689.349544] EXT4-fs error (device sda1): ext4_find_entry:1309: inode #2: comm rsync: reading directory lblock 0
#lsusb
:
Bus 001 Device 006: ID 1058:1021 Western Digital Technologies, Inc. Elements 2TB
正如评论中提到的,获取磁盘的 UUID 并将其粘贴到您的 fstab 中;
UUID=66a7ba58-b1e2-4d91-9b5e-085064a954ab /stor ext4 defaults 0 0
(将 UUID 值替换为您自己的值)。很简单
ls -la /dev/disk/by-uuid
(这只是一个名为 UUID 的符号链接的集合,它们指向真实设备的标识符(sda、sdb 等)。在我的例子中;lrwxrwxrwx 1 root root 9 Jul 7 08:45 66a7ba58-b1e2-4d91-9b5e-085064a954ab -> ../../sdf
具有该 UUID 的磁盘是 /dev/sdf,但我不必知道。设备的位置可能、将会而且确实会改变。它的 UUID 被烘焙到文件系统的目录中,除非您将其格式化干净,否则它永远不会改变。