Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have decided to start the transition to btrfs this weekend. I have a desktop with one md raid1 which is used for boot, and one large md raid5 for everything else. On top of the md raid5, I have LVM with vg-root, vg-swap and vg-home.

My idea is that I keep the raid1 with ext4 as boot and I won't convert the LVM at once. Instead, I'll create a new btrfs root on the raid5, create a fresh home directory, move over configs and bare necessities, and then move things over as I need them. That way, the size of the potential restore will increase as the likelihood of bugs decrease. Now the question is; how do I actually do that? :)

I'm hoping for some expert advise here.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

FYI, you don't need a separate /boot partition on a raid1; grub2 can boot directly from lvm on raid5.

If your raid5 is partitioned and currently LVM is using /dev/md1p1 as the PV, then you can shrink the PV, shrink the partition, and create a new partition using the free space to use for btrfs.

You will need to use parted to shrink the lvm partition after using pvresize to have LVM release part of it. You will need to have parted use sectors for the units and delete the LVM partition, and recreate it with the same start sector, but a shorter length. This will require either that the partition not be in use ( do it from a livecd ), or will complain that it could not update the kernel, and you will have to reboot for it to take affect.

After that, you can use gparted to create a new btrfs partition using the free space, then add it to /etc/fstab, mount it, and transfer some files. To move more space, you will need to repeat the pvresize and parted shrink step, then use gparted to move the btrfs partition to the left, and expand. This will take a long time because it has to copy all of the existing data in the btrfs partition.

It would be much easier, safer, and faster to simply create a new LV using whatever space is currently free in the VG, and format it with btrfs, then transfer some files, shrink an existing LV with resize2fs ( assuming it's ext4, and it will need to be unmounted to do this ) and lvresize, then add the space to the btrfs lv with lvresize, and tell btrfs to use the new space with btrfs filesystem resize max /path/to/btrfs-mount.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.