LVM:VG 中用作 PV 的一個或多個設備已變更大小

LVM:VG 中用作 PV 的一個或多個設備已變更大小

我最近在實體工作站上執行的 Ubuntu 18.04 上安裝了 LVM,然後建立了我的第一個 LV。第一次重新啟動後,我發現了一個問題,因為我無法再啟動它。

我注意到這個錯誤:

root@lvrome:/var/log# pvdisplay -v
    Wiping internal VG cache
    Wiping cache of LVM-capable devices
  WARNING: Device /dev/sdb has size of 312573551 sectors which is smaller than corresponding PV size of 312581808 sectors. Was device resized?
  One or more devices used as PVs in VG backup_vg have changed sizes.
  --- Physical volume ---
  PV Name               /dev/sdb
  VG Name               backup_vg
  PV Size               149,05 GiB / not usable <3,84 MiB
  Allocatable           yes (but full)
  PE Size               4,00 MiB
  Total PE              38156
  Free PE               0
  Allocated PE          38156
  PV UUID               LHDgmj-QGCd-xJnF-QhqH-B61a-iYnd-BpN2ZI

  --- Physical volume ---
  PV Name               /dev/sdd
  VG Name               backup_vg
  PV Size               149,05 GiB / not usable <3,84 MiB
  Allocatable           yes (but full)
  PE Size               4,00 MiB
  Total PE              38156
  Free PE               0
  Allocated PE          38156
  PV UUID               lXbczN-5bXe-C2lB-2Wq1-khbE-19SO-O3aHdI

這裡有一些VG和PV的顯示指令:

root@lvrome:/media# vgdisplay 
  WARNING: Device /dev/sdb has size of 312573551 sectors which is smaller than corresponding PV size of 312581808 sectors. Was device resized?
  One or more devices used as PVs in VG backup_vg have changed sizes.
  --- Volume group ---
  VG Name               backup_vg
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               298,09 GiB
  PE Size               4,00 MiB
  Total PE              76312
  Alloc PE / Size       76312 / 298,09 GiB
  Free  PE / Size       0 / 0   
  VG UUID               lDCvsV-fOvb-qFWM-hjqF-9xbo-TClo-e0Vzca

root@lvrome:/var/log# lvdisplay 
  WARNING: Device /dev/sdb has size of 312573551 sectors which is smaller than corresponding PV size of 312581808 sectors. Was device resized?
  One or more devices used as PVs in VG backup_vg have changed sizes.
  --- Logical volume ---
  LV Path                /dev/backup_vg/backup
  LV Name                backup
  VG Name                backup_vg
  LV UUID                lu8Jqs-7AD3-KNTH-2NP2-MQfP-zoxr-Ax2rPF
  LV Write Access        read/write
  LV Creation host, time lvrome, 2018-08-29 20:34:43 +0200
  LV Status              suspended
  # open                 0
  LV Size                298,09 GiB
  Current LE             76312
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

我嘗試強制激活 VG,然後強制激活 LV,但我無法繼續:

root@lvrome:/media# vgchange -ay
  WARNING: Device /dev/sdb has size of 312573551 sectors which is smaller than corresponding PV size of 312581808 sectors. Was device resized?
  One or more devices used as PVs in VG backup_vg have changed sizes.
  device-mapper: resume ioctl on  (253:0) failed: Argomento non valido
  Unable to resume backup_vg-backup (253:0)
  1 logical volume(s) in volume group "backup_vg" now active
root@lvrome:/media# lvchange -ay backup_vg
  WARNING: Device /dev/sdb has size of 312573551 sectors which is smaller than corresponding PV size of 312581808 sectors. Was device resized?
  One or more devices used as PVs in VG backup_vg have changed sizes.
  device-mapper: resume ioctl on  (253:0) failed: Argomento non valido
  Unable to resume backup_vg-backup (253:0)

我確信安裝後我沒有調整 PV 的大小。順便說一下,我是透過pvcreate /dev/sdb /dev/sdd, vgcreate backup_vg /dev/sdb /dev/sdd,來創造它們的lvcreate --type striped -i 2 -l 100%FREE -n backup backup_vg

這是以下的輸出lsblk

root@lvrome:~# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223,6G  0 disk 
├─sda1   8:1    0    50G  0 part 
├─sda3   8:3    0    40G  0 part /
├─sda4   8:4    0     1K  0 part 
├─sda5   8:5    0     4G  0 part [SWAP]
├─sda6   8:6    0    50G  0 part /home
└─sda7   8:7    0  79,3G  0 part /media/Documenti
sdb      8:16   0   149G  0 disk 
sdc      8:32   0 465,8G  0 disk 
└─sdc1   8:33   0 465,8G  0 part /media/Dati
sdd      8:48   0 149,1G  0 disk 
sde      8:64   0 465,7G  0 disk 
└─sde1   8:65   0 465,7G  0 part 
sr0     11:0    1  1024M  0 rom  
sr1     11:1    1  1024M  0 rom  
sr2     11:2    1    30M  0 rom  

磁碟的 SMART 狀態:

/dev/sdb

root@lvrome:~# smartctl -a /dev/sdb
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.15.0-33-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Barracuda 7200.11
Device Model:     ST3160813AS
Serial Number:    
LU WWN Device Id: 5 000c50 015125925
Firmware Version: CC2H
User Capacity:    160.037.658.112 bytes [160 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    7200 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 2.6, 3.0 Gb/s
Local Time is:    Fri Sep  7 20:46:40 2018 CEST
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:        (  609) 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:    (   1) minutes.
Extended self-test routine
recommended polling time:    (  33) minutes.
Conveyance self-test routine
recommended polling time:    (   2) minutes.
SCT capabilities:          (0x103f) SCT Status supported.
                    SCT Error Recovery Control supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

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   111   099   006    Pre-fail  Always       -       30102839
  3 Spin_Up_Time            0x0003   099   098   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   099   099   020    Old_age   Always       -       1698
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   071   060   030    Pre-fail  Always       -       12973048
  9 Power_On_Hours          0x0032   097   097   000    Old_age   Always       -       3276
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   098   098   020    Old_age   Always       -       2892
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
188 Command_Timeout         0x0032   100   100   000    Old_age   Always       -       4295032833
189 High_Fly_Writes         0x003a   083   083   000    Old_age   Always       -       17
190 Airflow_Temperature_Cel 0x0022   072   053   045    Old_age   Always       -       28 (Min/Max 27/28)
194 Temperature_Celsius     0x0022   028   047   000    Old_age   Always       -       28 (0 13 0 0 0)
195 Hardware_ECC_Recovered  0x001a   056   033   000    Old_age   Always       -       30102839
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
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       2567 (25 218 0)
241 Total_LBAs_Written      0x0000   100   253   000    Old_age   Offline      -       3366329622
242 Total_LBAs_Read         0x0000   100   253   000    Old_age   Offline      -       2642615780

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/sdd

root@lvrome:~# smartctl -a /dev/sdd
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.15.0-33-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Barracuda 7200.11
Device Model:     ST3160813AS
Serial Number:    
LU WWN Device Id: 5 000c50 01507abcc
Firmware Version: CC2H
User Capacity:    160.041.885.696 bytes [160 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    7200 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 2.6, 3.0 Gb/s
Local Time is:    Fri Sep  7 20:46:57 2018 CEST
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:        (  625) 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:    (   1) minutes.
Extended self-test routine
recommended polling time:    (  38) minutes.
Conveyance self-test routine
recommended polling time:    (   2) minutes.
SCT capabilities:          (0x103f) SCT Status supported.
                    SCT Error Recovery Control supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

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   118   099   006    Pre-fail  Always       -       178155821
  3 Spin_Up_Time            0x0003   100   097   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   091   091   020    Old_age   Always       -       9355
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   069   060   030    Pre-fail  Always       -       8117463
  9 Power_On_Hours          0x0032   086   086   000    Old_age   Always       -       12544
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       1
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       88
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
188 Command_Timeout         0x0032   100   100   000    Old_age   Always       -       0
189 High_Fly_Writes         0x003a   079   079   000    Old_age   Always       -       21
190 Airflow_Temperature_Cel 0x0022   072   055   045    Old_age   Always       -       28 (Min/Max 27/28)
194 Temperature_Celsius     0x0022   028   045   000    Old_age   Always       -       28 (0 17 0 0 0)
195 Hardware_ECC_Recovered  0x001a   054   043   000    Old_age   Always       -       178155821
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
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       10017 (102 148 0)
241 Total_LBAs_Written      0x0000   100   253   000    Old_age   Offline      -       617191373
242 Total_LBAs_Read         0x0000   100   253   000    Old_age   Offline      -       1792434767

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%      5833         -

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.

這是我的 LVM 版本:

root@lvrome:/var/log# lvm version
  LVM version:     2.02.176(2) (2017-11-03)
  Library version: 1.02.145 (2017-11-03)
  Driver version:  4.37.0
  Configuration:   ./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir=${prefix}/lib/x86_64-linux-gnu --libexecdir=${prefix}/lib/x86_64-linux-gnu --runstatedir=/run --disable-maintainer-mode --disable-dependency-tracking --exec-prefix= --bindir=/bin --libdir=/lib/x86_64-linux-gnu --sbindir=/sbin --with-usrlibdir=/usr/lib/x86_64-linux-gnu --with-optimisation=-O2 --with-cache=internal --with-clvmd=corosync --with-cluster=internal --with-device-uid=0 --with-device-gid=6 --with-device-mode=0660 --with-default-pid-dir=/run --with-default-run-dir=/run/lvm --with-default-locking-dir=/run/lock/lvm --with-thin=internal --with-thin-check=/usr/sbin/thin_check --with-thin-dump=/usr/sbin/thin_dump --with-thin-repair=/usr/sbin/thin_repair --enable-applib --enable-blkid_wiping --enable-cmdlib --enable-cmirrord --enable-dmeventd --enable-dbus-service --enable-lvmetad --enable-lvmlockd-dlm --enable-lvmlockd-sanlock --enable-lvmpolld --enable-notify-dbus --enable-pkgconfig --enable-readline --enable-udev_rules --enable-udev_sync

你能幫我找到解決方案嗎?

答案1

枚舉磁碟的順序在重新啟動之間不會保持不變。因此,每次重新啟動系統時,/dev/sdb和都可以逆轉。/dev/sdd或用/dev/sda或切換/dev/sdc。或是其他東西。

如果您所做的事情依賴於每次系統啟動時引用相同的物理磁碟,那麼最好使用符號鏈接,/dev/disk/by-id因為 Linux 可以確保它們始終指向相同的物理磁碟,即使它們的/dev/sd*特殊磁碟發生變化​​。

例如:

pvcreate /dev/disk/by-id/ata-SEAGATE-ST3160813AS_*whatever # you hid the serial number

從技術上來說這個不應該對於 LVM 來說這是必要的,因為它在內部使用自己的 UUID 來處理所有事情,至少在創建 PV 之後是這樣,但這是一個值得養成的好習慣。

相關內容