Hard-Drive
外部驅動器從 /dev/sda 切換到 /dev/sdb
我們有一個帶有外部驅動器的小盒子,用於備份配置集。我發現問題只是在重新啟動或驅動器從任何未知事件切換
/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 被烘焙到文件系統的目錄中,除非您將其格式化干淨,否則它永遠不會改變。