De Wiki Seb35
Aller à la navigation Aller à la recherche

I tried to have a root filesystem into btrfs for a Gandi server, unsuccessfully for now. Here are my steps if it can be useful to others.

WARNING: this is EXPERIMENTAL and could cause DATA LOSS.

Create the server

On, create a new server [1] with e.g. 1 proc, 256 Mio RAM, 1 system disk, Ubuntu 18.04 LTS.

Update the packages:

apt update && apt upgrade -y

On, stop the server, open the page about the system disk, clone the system disk with another name, and attach this cloned disk to the server, start the server.

Convert to btrfs

Mostly from [2]

The package btrfs-progs currently does not contain btrfs-convert (this Debian bug) because the risk of data loss is too great. Then we need to compile btrfs-progs.

Install dependencies:

apt install gcc g++ libblkid-dev liblzo2-dev zlib1g-dev libzstd-dev asciidoc xmlto libattr1-dev libext2fs-dev pkg-config python3-dev python3-setuptools

Download and compile btrfs-progs (changelog, releases):

tar xfz btrfs-progs-v4.20.1.tar.gz
cd btrfs-progs-v4.20.1
./configure --with-convert=ext2
make install
cd ..
rm -rf btrfs-progs-v4.20.1 btrfs-progs-v4.20.1.tar.gz

Display the active root filesystem, and you will be able to deduce what is the cloned filesystem:

ls /dev/xvd*
mount|grep xvd
blkid -o value -s TYPE /dev/xvda1 # and the same for others

Let’s say /dev/xvdb1 is the clone filesystem, we convert it to btrfs:

fsck.ext4 -f /dev/xvdb1
btrfs-convert -p /dev/xvdb1

Here, I obtained the following error:

root@test:~# btrfs-convert -p /dev/xvda1
create btrfs filesystem:
	blocksize: 4096
	nodesize:  16384
	features:  extref, skinny-metadata (default)
creating ext2 image file
creating btrfs metadata
Unable to find block group for 0 27081]
Unable to find block group for 0
Unable to find block group for 0
ctree.c:2245: split_leaf: BUG_ON `1` triggered, value 1

According to [3], it can be worked around:

btrfs-convert -d -p /dev/xvdb1

Then, mount the filesystem and delete the old ext4 snapshot:

mount /dev/xvdb1 /mnt
btrfs subvolume delete /mnt/ext2_saved

Promote as root filesystem

Not successful after a first try with [4] and I abandonned here, see also [5].