meta data for this page
  •  

Thin LVM and badblock

Kernel reports problems with

[5528686.859719] blk_update_request: I/O error, dev sda, sector 85981696 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0

Filter out sector numbers from journal:

journalctl | grep 'dev sda, sector' | cut -d ' ' -f 12 | sort | uniq
 
82053408
85981440
85981536
85981544
85981552
85981560
85981568
85981696
85981704
85981712
85981720
85981728
85981736
85981744
85981752
85984832
85984840
85984848
85984856
85984864
85984872
85984880
85984888
85984896
85984904
85984928
smartctl -a /dev/sda | grep UNC
  40 51 08 b8 06 20 e5  Error: UNC 8 sectors at LBA = 0x052006b8 = 85984952
  40 51 08 b0 06 20 e5  Error: UNC 8 sectors at LBA = 0x052006b0 = 85984944
  40 51 08 a8 06 20 e5  Error: UNC 8 sectors at LBA = 0x052006a8 = 85984936
  40 51 08 a0 06 20 e5  Error: UNC 8 sectors at LBA = 0x052006a0 = 85984928
  40 51 80 80 06 20 e5  Error: UNC 128 sectors at LBA = 0x05200680 = 85984896
Disk /dev/sda: 111,79 GiB, 120034123776 bytes, 234441648 sectors
Disk model: KINGSTON SA400S3
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 711FEF16-FBD0-45BB-BA56-52B93B733D8E
 
Device       Start       End   Sectors   Size Type
/dev/sda1       34      2047      2014  1007K BIOS boot
/dev/sda2     2048   1050623   1048576   512M EFI System
/dev/sda3  1050624 234441614 233390991 111,3G Linux LVM

Calculate LVM position for bad sector 85984896 by substract Start section 85984896 - 1050624 = 84934272

Get PE size

pvdisplay /dev/sda3

, it is 4M, so 4096.

LBA block (secotr) size is 512, so each PE takes 8192 sectors.

The same information you can found in:

# cat /etc/lvm/backup/pve | grep extent_size
	extent_size = 8192		# 4 Megabytes
# cat /etc/lvm/backup/pve | grep pe_start
			pe_start = 2048
echo 84934272 / 8192 | bc
10367

Region is used by thin provisioning:

pvdisplay -v -m

Physical extent 8128 to 24425:
  Logical volume	/dev/pve/data_tdata
  Logical extents	0 to 16297

!!! DONT KNOW HOW TO REMAP LVM SECTORS

lvcreate -l1 pve -n bb85984896 /dev/sda3:10367

Zeroing sectors

Confirm that sector read fails:

dd if=/dev/sda of=/tmp/dump.raw bs=512 count=1 skip=85981696
hdparm --read-sector 85981696 /dev/sda
hdparm --write-sector 85981696 --yes-i-know-what-i-am-doing  /dev/sda
40 51 08 b8 06 20 e5  Error: UNC 8 sectors at LBA = 0x052006b8 = 85984952..85984959
40 51 08 b0 06 20 e5  Error: UNC 8 sectors at LBA = 0x052006b0 = 85984944..85984951
40 51 08 a8 06 20 e5  Error: UNC 8 sectors at LBA = 0x052006a8 = 85984936..85984943
40 51 08 a0 06 20 e5  Error: UNC 8 sectors at LBA = 0x052006a0 = 85984928..85984935
40 51 80 80 06 20 e5  Error: UNC 128 sectors at LBA = 0x05200680 = 85984896  to 85985023
for i in {85984896..85985023}; do echo $i; hdparm --write-sector $i --yes-i-know-what-i-am-doing  /dev/sda; don