prepare
1 | apt install nvme-cli |
install
system service
step1: config nvmeof info
vim /etc/nvme/discovery.conf1
-t tcp -a 10.220.32.14 -s 4420 -n nqn.2025-11.io.spdk:cnode-test-volume
step2: create systemd unit
vim /etc/systemd/system/nvmeof-connect.service1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20[Unit]
Description=NVMe-oF TCP Auto Connect
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/nvme connect \
-t tcp \
-a 10.220.32.14 \
-s 4420 \
-n nqn.2025-11.io.spdk:cnode-test-volume \
--keep-alive-tmo=30
ExecStop=/usr/sbin/nvme disconnect \
-n nqn.2025-11.io.spdk:cnode-test-volume
TimeoutSec=60
[Install]
WantedBy=multi-user.target
step3: enable service
1
2
3systemctl daemon-reload
systemctl enable nvmeof-connect.service
systemctl start nvmeof-connect.service
command
pv
1 | flush cache |
tags
1 | Show LV name + tags for all LVs in VG , add --noheadings if you don’t want the header line). |
active
1 | activate specific multiple LVs explicitly |
- Inactive LV → no device-mapper node → no /dev/mapper/* file
expand
1 | device |
troubleshooting
节点lv mapper没有清理干净
虽然 lvscan 不再显示lv,但是lsblk -f 还是有显示 lv的信息
原因是 deletelv pod 是随机调度到任意一个节点上的,虽然内有 dmsetup remove 的逻辑,但也仅限于作用于当前被调度到的节点
1 | 现象 |
1 | 错误操作 (wrong operate) |
lsblk -f 无法显示新的设备
Force Client to See the New Volume
Find the NVMe Device Name:
Runls /dev/nvme*. You are looking for the controller character device, likely/dev/nvme0or/dev/nvme1(not ending inn1).Rescan:
1
2Replace with your actual controller device
nvme ns-rescan /dev/nvmexCheck Again:
Now runlsblk. The device (e.g.,nvmex) should appear.
lvs Checksum error
由于nvmeof 只能同时只有一个节点可以操作数据,如果多个节点同时操作数据,则会造成冲突
issue
1 | /dev/nvme4n4: Checksum error at offset 372224 |
solution
step1: Dump the Metadata to a File
1
2Since the system cannot read the VG, use the low-level `pvck` tool to extract the configuration text stored on the drive.
pvck --dump metadata_search /dev/nvme4n4 > /tmp/csi-lvm_search.vgcsi-lvm_search.vg as below
1
2
3
4
5
6Searching for metadata at offset 4096 size 1044480
metadata at 17408 length 31448 crc 9fb93ed6 vg csi-lvm seqno 31081 id UShLSg-JLRf-Agkb-YRQK-asNV-GSFn-IRqbDH
......
metadata at 339456 length 32289 crc 4cc1a315 vg csi-lvm seqno 31091 id UShLSg-JLRf-Agkb-YRQK-asNV-GSFn-IRqbDH
🚨metadata at 372224 length 32281 crc 3ab9a3d8 vg csi-lvm seqno 31092 id UShLSg-JLRf-Agkb-YRQK-asNV-GSFn-IRqbDH
......Key finding:
- The corrupted one is at
372224. - A newer valid one (higher seqno
31093) exists at404992. - We must extract
404992.
- The corrupted one is at
step2: Stop all I/O to this NVMe-oF LUN
Make sure no pod/host is using the LV/VG, and this NVMe namespace is not attached read-write from two nodes at the same time.
step3: Extract the Raw Metadata Text
1
2Run this command to copy exactly 31,840 bytes from offset 404992:
dd if=/dev/nvme4n4 bs=1 skip=404992 count=31840 of=/tmp/csi-lvm_fixed.vgcsi-lvm_fixed.vg as below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27csi-lvm {
id = "UShLSg-JLRf-Agkb-YRQK-asNV-GSFn-IRqbDH"
seqno = 31093
format = "lvm2"
status = ["RESIZEABLE", "READ", "WRITE"]
...
physical_volumes {
pv0 {
id = "0y2OB6-itmv-7xau-OycV-UpvA-iAar-PLUI6o"
device = "/dev/nvme4n4"
...
}
}
logical_volumes {
pvc-a75bd3c3-b2f8-4ae1-904b-af95c5ed1ad6 {
id = "RwMGsf-R7GE-GiyI-jw3V-J4To-S8aX-wrrFTr"
status = ["READ", "WRITE", "VISIBLE"]
...
pvc-6cee2171-b630-4756-8f05-2727f2f53d09 {
id = "jg1OEJ-eLzj-FS41-3Z2L-3kyT-IJtV-Ur7x59"
status = ["READ", "WRITE", "VISIBLE"]
...step4: Wipe the Corrupted Signature
We will wipe the first 1MB of the disk to remove the broken LVM label and metadata. Do not worry, this only removes the LVM headers (which are already broken); your data is safely located further down (at PE start 2048 sectors = 1MB).
1
dd if=/dev/zero of=/dev/nvme4n4 bs=1M count=1
step5: Re-create the PV Header
This fixes the “No metadata areas” error by creating a new, valid metadata area.
This rewrites the header (label) and creates a fresh metadata area without touching your data.1
2pvcreate --uuid "<YOUR-UUID>" --restorefile /tmp/csi-lvm_fixed.vg /dev/nvme4n4
actual: pvcreate --uuid "0y2OB6-itmv-7xau-OycV-UpvA-iAar-PLUI6o" --restorefile /tmp/csi-lvm_fixed.vg /dev/nvme4n4step6: Restore the VG Configuration
1
vgcfgrestore -f /tmp/csi-lvm_fixed.vg csi-lvm
step7: Verify
1
lvs
best practices
discard the space after removing the LV
method1: Automatic (after execute lvremove /dev/vg_name/lv_name)
Edit the config file
/etc/lvm/lvm.confChange the value, set
issue_discards = 1(The default is usually 0).
method2: Manual
1 | manually sends the trim command while the volume still exists, then removes it. This achieves the same result without changing lvm.conf |
wipefs vs desetup vs lvremove
- wipefs : Just removes labels. Data remains. Space is not freed on server.
- blkdiscard : Wipes data. Sends TRIM. Space is freed on server (if supported).
1 | ┌─────────────────────────────────────────────────────────────┐ |