Since as btrfs doesn't track bad blocks, as a work-around this btrfs mailing list post suggested using an underlying mdadm RAID0 configuration for badblocks support.Could LVM be used instead of mdadm for this purpose?
Can LVM mark / avoid bad blocks?
lvm;btrfs;mdadm
In general, as has been mentioned in a comment here and in the mailing list thread you linked to, modern hard drives which are so far gone theyve got unreplaceable bad blocks should just be discarded. (Youve explained why youre interested in this, but its worth noting for other readers.)I dont think theres anything in LVM to avoid bad blocks as such; typically youd address that below LVM, at the device layer. One way of dealing with the problem is to use device mapper: create a table giving the sector mapping required to skip all bad blocks, and build a device using that. Such a table would look something like0 98 linear /dev/sda 098 98 linear /dev/sda 99etc. (this creates a 196-sector device, using /dev/sda but skipping sector 98). You give this to dmsetup:dmsetup create nobbsda --table mytableand then create a PV on the resulting /dev/nobbsda device (instead of /dev/sda).Using this method, with a little forward-planning you can even handle failing sectors in the future, in the same way as a drives firmware: leave some sectors at the end of the drive free (or even dotted around the drive, if you want to spread the risk), and then use them to fill holes left by failing sectors. Using the above example, if we consider sectors starting from say 200 to be spare sectors, and sector 57 becomes bad:0 57 linear /dev/sda 057 1 linear /dev/sda 20058 40 linear /dev/sda 5898 98 linear /dev/sda 99Creating a device-mapper table using a list of bad sectors as given by badblocks is left as an exercise for the reader.Another solution that would work with an existing LVM setup would be use pvmoves ability to move physical extents in order to move LVs out of bad areas. But that wouldnt prevent those areas from being re-used whenever a new LV is created or an existing LV resized or moved.