Btrfs Assistant 1.0 is coming, testers needed

That is horrible. :exploding_head:

1 Like

Question: I have two identical SSDs (Firecuda 530) in my System, one is filled with 300MB full of Virtual Machines, the other One holds my EOS installation. Can I extend my 1 BtrFS filesystem with the other one? And if I copy the VMs to the drive with EOS on it do I have to make sonmething beside just copying? I know in ZFS there is something to do, how it is with BtrFS?
And if all of this is possible, how is it done?

You can add a second device to your btrfs filesystem. However, that will destroy the data on the new device being added(but not the first one).

However, I am not sure if there is a way to combine two filesystems into a single filesystem.

Well, the plan would be the following:
Create some space (another subvol??? just a directory?) on the current BtrFS drive, copy VMs onto this space, cleanup drive two and then add it to create the mirror.
The questions that arise:

  • How should the “space” be created? Anything special for VMs?
  • How do I format the to be added rive and how to add it?

Sorry for asking dumb questions…

I would put them in a separate subvol. That way you have the flexibility to do something different later.

Depending on the VM solution you use, you may want to mark them as nocow.

To be clear, what are you trying to do?

Do you want to create a mirror with the two devices or your want a single btrfs filesystem that contains both devices?

So this:

btrfs subvolume create /virtual @virtual

followed by this in fstab:

UUID={UUID of /} /virtual              btrfs   subvol=/@virtual,defaults,nocow,noatime,compress=zstd 0 0

And I am good?

I am using virtual box

I want to have a mirror.

One thing confuses me: Snapper shows 2 additional subvols:


which are not mentioned in the fstab at all. The Directories are in my Filesystem, permissions are set to root:root. What is this for, do I need it in snapper, can I get rid of it?

Just a quick disclaimer that all the below commands are from my memory. I didn’t test them all one at a time.

If you want a flat layout managed via fstab, I would do:

sudo mkdir /virtual
sudo mount /dev/mypartition /mnt -o subvolid=5
sudo btrfs subvolume create /mnt/@virtual

If you want a nested subvolume, you can do this instead of all the above steps:

sudo btrfs subvolume create /virtual

I believe it is nodatacow. However, you shouldn’t use the mount option for limiting COW as it would apply to all subvolumes. More accurately, it would do nothing since the root subvolume would be mounted first and it would not have nodatacow applied.

You also don’t need defaults.

Those are created automatically. I believe by systemd.

sudo btrfs device add /dev/myotherpartition /
sudo btrfs balance start -dconvert=raid1 -mconvert=raid1 /

Replace /dev/mypartition and /dev/myotherpartition with the actual device names for those devices.

Of course, always make sure you have your data backed up before making any of these changes.

This gives me quite some headache. Currently my nvme lloks like this:

/dev/zram0                                                                                    [SWAP]
/dev/nvme0n1                                                                                  
├─/dev/nvme0n1p1 vfat   FAT32             BDEB-C54C                             997,5M     0% /boot/efi
└─/dev/nvme0n1p2 btrfs        endeavouros 178ba18b-3faa-4b38-b7e5-5b0f5d2f285c    1,7T     7% /var/log
                                                                                              /var/cache
                                                                                              /home
                                                                                              /
/dev/nvme1n1                                                                                  
└─/dev/nvme1n1p4 ext4   1.0   Virtual     6a10a4f9-8767-4383-8ee2-6181ac255908                            

The second nvme will be erased, so ignore it for the time being. I asume for the flat scenario I have to resize my endervouros partition? And then create a new one, BtrFS as well?

I still can’t get my head around nested subvols, flat hierachy and when to chose what. With your experience, what would you do?

So it would be:

sudo mount /dev/nvme0n1p2 /mnt -o subvolid=5

I don’t think so. Why would it need to be resized?

You mean on the second disk?

Unless you have a specific need for one setup vs the other, it doesn’t really matter.

The existing subvols that ship with EOS are flat. If you want it to be the same as those, use flat.

Ont he other hand, nested is simpler. You just make the subvolume and there is nothing else to do. You don’t need to use the mount command above. Nothing needs to be added to /etc/fstab.

So, what I want to achieve: My VMs should be all stored under a “place” which is mounted on /virtual (like in my current setup, but not anymore on the second NVMe (I need this one for the setup of the mirror). Instead it should be on the first drive. I think I should just go with the nested one, but how to format it regarding no cow?

You don’t format it that way. You set the directory to nocow before copying any files. Like this: chattr +C /path/to/dir

So it comes down to this:

sudo mkdir /virtual
sudo mount /dev/nvme0n1p2 /virtual -o subvolid=5
sudo btrfs subvolume create /virtual/@virtual
sudo chattr +C /virtual

And then care for the mirror?
This is still confusing for me…
I am almost at the point where I say “Screw it, imma going ext4…”

I first need to know if you are doing nested or flat.

Sorry, my bad - flat. Feels more “oldfashioned” to me (and eos is doing it)…

OK, it should be more like this:

First create the subvolume

sudo mount /dev/nvme0n1p2 /mnt -o subvolid=5
sudo btrfs subvolume create /mnt/@virtual
sudo umount /mnt

Next, edit /etc/fstab and add the entry for this subvol copying the others

Now mount the subvol for the first time:

sudo mkdir /virtual
sudo mount /virtual
sudo chattr +C /virtual

Then copy the files in.

Tyvm, will try it later on - first the backup :wink:
Just one question left: Why the subvolid=5? Is this random or must it be the 5?

subvolid=5 is the root of the filesystem.

Keep in mind, / isn’t mounted on the root of the filesystem it is mounted on a subvolume, @. So if you want to write to the true root, you need to mount it temporarily.

So far so good.
First of all, this:

was enlightening, tyvm! Everything worked as expected, but there is always an issue with me being silly. I did as mentioned above, everything was working, copied my files, everything looks good, started my scripts (cloud init stuff) and nothing was working. The reason was quite obvious: My old partition was mounted on /Virtual, not /virtual…
My solution would be the following, from what I have learned from you:

sudo unmount /virtual
sudo rmdir /virtual
sudo mount /dev/nvme0n1p2 /mnt -o subvolid=5
sudo btrfs subvolume delete /mnt/@virtual
sudo umount /mnt

And then repeat everything what I have done with an upper case “V”?

No, it is much simpler than that:

sudo umount /virtual

Change /etc/fstab

sudo mount /Virtual

You don’t need to change the subvolume at all. You are only changing the mountpoint.

Well, definately easier. Just out of curiosity: Would my way have worked as well?