1

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.

  • What about moving the partition to the beginning with fdisk (you said that would work), then extending the partition. And then you could grow the file-system with btrfs filesystem resize max /your/fs as in btrfs.wiki.kernel.org/index.php/… – Pierre-Alain TORET Oct 31 '17 at 10:25
  • 1
    Is it a problem to have btrfs cover two partitions? – Hauke Laging Oct 31 '17 at 15:24
  • @daftaupe: If I moved the beginning of the partition usung fdisk the fs would stay untouched. The fs would start in the middle of the partition and, hence, not be found. btrfs filesystem resize only expands the fs at the end. – jorsn Oct 31 '17 at 17:17
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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