0

I want to erase a disk then info linux to update the /dev/mapper. Here is the operation example. Create a test pv and vg on /dev/vdc1 then create test lv, use dd to erase the first 8K data of /dev/vdc1 (destory the lvm metadata).

# pvcreate /dev/vdc1
# vgcreate testvg /dev/vdc1
# lvcreate -L10G -n testlv testvg
# lsblk /dev/vdc
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vdc               252:32   0  120G  0 disk 
└─vdc1            252:33   0  108G  0 part 
  └─testvg-testlv 253:2    0   10G  0 lvm 

# dd if=/dev/zero of=/dev/vdc1 bs=8K count=1 oflag=direct

Now the question is how to info linux to update /dev/mapper without reboot? Or is there any more convenient way to wipe out lvm on with reboot?

Jaden Liang
  • 27
  • 1
  • 3
  • I know there's some `ioctl` for something related, maybe look at the tools that are normally used to update them? Or possibly you could trigger `udev` directly ... – o11c Apr 12 '16 at 04:54
  • It looks like that use `dmsetup remove` can update the device mapper infomation, but I am not sure it is the correct method. – Jaden Liang Apr 12 '16 at 05:25

1 Answers1

1

Well, no response? I do some research about lsblk. It is implemented by reading /dev or /sysfs to show the block information. So I figure it can be resolve by dmsetup remove command to remove any lv under destroied vg. Like this:

# pvcreate /dev/vdc1
# vgcreate testvg /dev/vdc1
# lvcreate -L10G -n testlv testvg
# dd if=/dev/zero of=/dev/vdc1 bs=8K count=1 oflag=direct
# dmsetup remove /dev/testvg/*

Then nothing left in lsblk any more. However, I am still wondering the way is not the best way. Can someone append more methods?

Jaden Liang
  • 27
  • 1
  • 3