Skip to content

Instantly share code, notes, and snippets.

@JohnRTitor
Last active June 1, 2025 20:58
Mount a LVM partition on an ISO and convert it to Bcachefs

Mount an existing LVM virtual partition/volume in an ISO

# Load the appropriate LVM modules
sudo modprobe dm-mod

# Scan the disk for LVM pools
sudo vgscan

# Found one! Now make it active
sudo vgchange -ay lvm-pool

# List the volumes/partitions in that pool
sudo lvs

# Mount the LVM volume like any other
sudo mkdir /mnt
sudo mount /dev/lvm-pool/root /mnt

# Do some work, you can use it normally like any other partition now
ls /mnt

# Finally unmount
sudo umount /dev/lvm-pool/root

Migrate an ext4 filesystem to Bcachefs

:::{:note} This works the same for every partitions, LVM or not. :::

# run ext4 fsck so that the partition is error free
sudo fsck.ext4 -f /dev/lvm-pool/root

# start migration, it'll take some time but DO NOT cancel it, it will corrupt you data!
sudo bcachefs migrate -f /mnt

# migration almost done at this point
# now mount the migrated partition, superblock offset might be different for you
sudo mount -t bcachefs -o sb=302514176 /dev/lvm-pool/root /mnt/bcachefs
ls /mnt/bcachefs

# you are happy with the result
# you must remove the old migrated filesystem if you want to proceed further
sudo rm -f /mnt/bcachefs/old_migrated_filesystem

# migrate the superblock to proper position
sudo umount /mnt/bcachefs
sudo bcachefs migrate-superblock -d /dev/lvm-pool/root -o 302514176

# migration fully done and completed! Mount like normal
sudo mount /dev/lvm-pool/root /mnt
ls /mnt
# you can however unmount this partition to run `bcachefs fsck` if you wish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment