Lvm
pvmove –abort 後無法移動範圍
我想將範圍從一個磁碟移動到另一個磁碟,兩者的大小相同:
# pvmove /dev/sdd1 /dev/sdc1
不幸的是,pvmove 在 99.99% 上掛了幾個小時,我決定發布一個
pvmove --abort
. 移動已停止,LV 仍可執行,但無法重新執行pvmove
:# pvmove /dev/sdd1 /dev/sdc1 Insufficient free space: 727303 extents needed, but only 0 available Unable to allocate mirror extents for kujira/pvmove0. Failed to convert pvmove LV to mirrored.
但是,目標設備正好有 727303 個空閒區。我什至可以在 PV 上創建新的 LV,但
pvmove
不喜歡移動範圍。問題是,我試圖移動的 LV 被調整過一次,並被分成兩部分:# lvs --all -o lv_name,devices LV Devices srv srv_rimage_0(0),srv_rimage_1(0),srv_rimage_2(0) [srv_rimage_0] /dev/sda1(0) [srv_rimage_0] /dev/sda1(703489) [srv_rimage_1] /dev/sdc1(0) [srv_rimage_1] /dev/sdd1(703489) [srv_rimage_2] /dev/sdb1(0) [srv_rimage_2] /dev/sdb1(703489) [srv_rmeta_0] /dev/sda1(703488) [srv_rmeta_1] /dev/sdd1(703488) [srv_rmeta_2] /dev/sdb1(703488)
srv_rimage_1
現在駐留在sdc1
和sdd1
:# pvdisplay --maps /dev/sdd1 /dev/sdc1 --- Physical volume --- PV Name /dev/sdd1 VG Name kujira PV Size <5,46 TiB / not usable <1,57 MiB Allocatable yes PE Size 4,00 MiB Total PE 1430791 Free PE 703488 Allocated PE 727303 PV UUID boRXi6-6fjo-Ga8Y-iVzJ-qdb4-g3Q7-TASCwx --- Physical Segments --- Physical extent 0 to 703487: FREE Physical extent 703488 to 703488: Logical volume /dev/kujira/srv_rmeta_1 Logical extents 0 to 0 Physical extent 703489 to 1430790: Logical volume /dev/kujira/srv_rimage_1 Logical extents 703488 to 1430789 --- Physical volume --- PV Name /dev/sdc1 VG Name kujira PV Size <5,46 TiB / not usable <1,57 MiB Allocatable yes PE Size 4,00 MiB Total PE 1430791 Free PE 727303 Allocated PE 703488 PV UUID ZikJzc-Au3G-O327-Rsw5-2AoY-Wwu3-NzBfBf --- Physical Segments --- Physical extent 0 to 703487: Logical volume /dev/kujira/srv_rimage_1 Logical extents 0 to 703487 Physical extent 703488 to 1430790: FREE
我還能以某種方式將所有內容從 移動
sdd1
到sdc1
嗎?LVM version: 2.03.02(2) (2018-12-18) Library version: 1.02.155 (2018-12-18) Driver version: 4.35.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-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-dmeventd --enable-dbus-service --enable-lvmlockd-dlm --enable-lvmlockd-sanlock --enable-lvmpolld --enable-notify-dbus --enable-pkgconfig --enable-readline --enable-udev_rules --enable-udev_sync
問題在於 LVM 的分配策略。我發現這篇博文解釋了這個問題:https ://tim.mattison.org/db01b8858c1748a7aed1649d57aefaa3
查看 pvmove 的聯機幫助頁:
--alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit Determines the allocation policy when a command needs to allocate Physical Extents (PEs) from the VG. Each VG and LV has an allocation policy which can be changed with vgchange/lvchange, or overriden on the command line. normal applies common sense rules such as not placing parallel stripes on the same PV. inherit applies the VG policy to an LV. contiguous requires new PEs be placed adjacent to existing PEs. cling places new PEs on the same PV as existing PEs in the same stripe of the LV. If there are sufficient PEs for an allocation, but normal does not use them, anywhere will use them even if it reduces performance, e.g. by placing two stripes on the same PV. Optional positional PV args on the command line can also be used to limit which PVs the command will use for allocation. See lvm(8) for more information about allocation.
我最好的猜測是問題出在 PV 上的拆分 LV 上,這裡是在一個未移動的磁碟上:
--- Physical Segments --- Physical extent 0 to 703487: Logical volume /dev/kujira/srv_rimage_2 Logical extents 0 to 703487 Physical extent 703488 to 703488: Logical volume /dev/kujira/srv_rmeta_2 Logical extents 0 to 0 Physical extent 703489 to 1430790: Logical volume /dev/kujira/srv_rimage_2 Logical extents 703488 to 1430789
第二個擴展來自 lvresize 程序。如果第一次詢問 pvmove 似乎會正確移動所有三個,但當其中一個
rimage
已經在另一個 PV 上時拒絕移動它們。正如博文中所寫,
pvmove --alloc anywhere [...]
有效。據了解
man 8 lvm
,使用時應該看配置調試程式碼-vvvv
。