Linux – How to resize at the beginning/move a btrfs partition on the command line

btrfscommand linelinuxmove-partitionpartition

I have a Linux/Windows dual boot setup on my notebook, in which I used to keep most of the data on the Windows partition to be able to access it from both systems. Since I almost never use Windows I shrunk the NTFS partition and plan to move the data to the Linux partition which is formatted as btrfs. Beforehand the btrfs partition needs to be expanded at the beginning where the now free space is.

fdisk can move the beginning of a partition but leaves the filesystem untouched. parted cannot handle the filesystem, either, since version 3.0.

One solution to the problem would be to create a partition in the free space and add it as a backing device to the btrfs, then removing the original btrfs from btrfs (using btrfs device) and the partition table and after that expanding the remaining btrfs+partition to the end of the drive. The problems here are that the new free space must be big enough to hold all the files from the btrfs and that all the data has to be moved.

So my question is:
Is there some other, preferably more elegant and generally applicable, way to expand a btrfs at the beginning?

Edit: (Solution)

Even if GParted might be able to resize at the beginning by automatically moving the filesystem, I tried the way described above since I have the free space. As it took ages (perhaps because of many subvolumes), used many cpu and I/O resources and then aborted with an I/O error, I used btrfs replace instead which worked just fine: It took a few hours during which the computer was perfectly usable.

Best Answer

No, there isn't another way. In fact, I don't know of any filesystem which allows resizing at the beginning.

So either you can add the new partition to the pool and thus not have to move your data, or proceed as you described.

Related Question