(LVM)将数据移动到同一逻辑卷内的不同物理卷

(LVM)将数据移动到同一逻辑卷内的不同物理卷

我有一个名为 的逻辑卷storage。它包含两个 ~1TB 的物理卷:/dev/sdc/dev/sddsmartctl -a /dev/sdd通知我它/dev/sdd失败了。我仍然可以从中读取数据,我刚刚备份了 LV 中的所有内容。

我的实际数据约为 200GB — 很少,以至于其中一个 PV 可以容纳所有数据。我想/dev/sdd从逻辑卷中删除它并将其所有数据传输到此/dev/sdcLV 上的其他 PV()。

pvmove由于所有范围都已分配,因此失败。

# pvmove /dev/sdd /dev/sdc
  WARNING: No free extents on physical volume "/dev/sdc".
  No specified PVs have space available.

问题:如何确保没有“真实”数据/dev/sdd并安全地删除它?

我从下面的输出中省略了与该问题无关的其他 LVM 组织。

# lvdisplay --maps
  --- Logical volume ---
  LV Path                /dev/spinny/storage
  LV Name                storage
  VG Name                spinny
  LV UUID                LeJEIR-0Zvf-YBLD-GrCT-Kvv0-mcvz-4a66Ib
  LV Write Access        read/write
  LV Creation host, time archiso, 2020-01-01 12:32:05 -0500
  LV Status              available
  # open                 0
  LV Size                <1.82 TiB
  Current LE             476934
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

  --- Segments ---
  Logical extents 0 to 238466:
    Type        linear
    Physical volume /dev/sdc
    Physical extents    0 to 238466

  Logical extents 238467 to 476933:
    Type        linear
    Physical volume /dev/sdd
    Physical extents    0 to 238466
# pvdisplay --maps
  --- Physical volume ---
  PV Name               /dev/sdc
  VG Name               spinny
  PV Size               931.51 GiB / not usable 1.71 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              238467
  Free PE               0
  Allocated PE          238467
  PV UUID               fMOJ38-TiZZ-DspR-hOy3-4aGn-lKXo-4mYSrU

  --- Physical Segments ---
  Physical extent 0 to 238466:
    Logical volume  /dev/spinny/storage
    Logical extents 0 to 238466

  --- Physical volume ---
  PV Name               /dev/sdd
  VG Name               spinny
  PV Size               931.51 GiB / not usable 1.71 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              238467
  Free PE               0
  Allocated PE          238467
  PV UUID               XJ2D5p-l3iP-VBlR-peXB-up1y-ZpNh-UDkcfB

  --- Physical Segments ---
  Physical extent 0 to 238466:
    Logical volume  /dev/spinny/storage
    Logical extents 238467 to 476933
# blkid
/dev/sdc: UUID="fMOJ38-TiZZ-DspR-hOy3-4aGn-lKXo-4mYSrU" TYPE="LVM2_member"
/dev/sdd: UUID="XJ2D5p-l3iP-VBlR-peXB-up1y-ZpNh-UDkcfB" TYPE="LVM2_member"
/dev/mapper/spinny-storage: UUID="108a53d4-dc5a-48b7-971f-b62c617fdb15" BLOCK_SIZE="4096" TYPE="ext4"
# smartctl -a /dev/sdd
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.6.11-arch1-1] (local build)
# ... clipped ...
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   001   001   051    Pre-fail  Always   FAILING_NOW 14946
  3 Spin_Up_Time            0x0027   170   169   021    Pre-fail  Always       -       2466
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       80
  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   095   095   000    Old_age   Always       -       3728
 10 Spin_Retry_Count        0x0032   100   253   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   253   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       80
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       19
193 Load_Cycle_Count        0x0032   200   200   000    Old_age   Always       -       66
194 Temperature_Celsius     0x0022   103   096   000    Old_age   Always       -       40
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   183   183   000    Old_age   Always       -       2919
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      -       0

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  Extended offline    Completed: unknown failure    90%      3680         -
# 2  Extended offline    Completed: read failure       90%      3663         2064

答案1

您的“存储”LV 大小为 2TB。您无法移除一半的物理空间,否则会损坏它。

您可以做的是缩小文件系统的大小,然后调整 LV 的大小,然后就可以安全地从卷组中删除 PV。

  1. 卸载“存储”:umount /dev/spinny/storage
  2. 缩小文件系统,使其可以单独放在 sdc 上。由于您只有 200G,因此出于安全考虑,您可以将其缩小到 900G。根据您的文件系统类型,您需要的工具会有所不同,如果您的文件系统不支持缩小,那么您就没那么幸运了。如果您使用的是 ext4,您可能会很幸运:fsck -C0 -f /dev/spinny/storage && resize2fs /dev/spinny/storage 800G
  3. 将逻辑卷缩小到不小于文件系统大小(如上所述),并且不大于 sdc 的大小:lvresize -L900G spinny/storage
  4. 由于 sdd 是第二个驱动器,因此现在您可能还无法对其进行扩展。pvs此时应该显示 sdd 上没有数据,您可以安全地将其取出vgreduce spinny /dev/sdd

如果愿意的话,您现在可以扩展 LV 和文件系统来填充 sdc:

  1. lvresize -l 100%PV spinny/storage
  2. resize2fs /dev/spinny/storage

相关内容