btrfs raid1 nvme for data

ecotechie

Member
Nov 11, 2023
42
1
8
Hi,

I'm testing out btrfs on a new installation. I limited knowledge of btrfs and have done some reading. However, I seem to be missing a very simple concept. How to setup/mount the volumes.

I created the raid1:
Code:
mkfs.btrfs -m raid1 -d raid1 -L btr-vault /dev/nvme3n1 /dev/nvme2n1

Then the mount point and mounted:
Code:
mkdir /mnt/btr-vault
mount /dev/nvme2n1 /mnt/btr-vault/

But I should be creating volumes, right?
I ran:
Code:
btrfs subvolume create /mnt/btr-vault/volume
pvesm add btrfs btr-vault --path /mnt/btr-vault/volume/

But now ls /mnt/btr-vault/ returns:
Code:
dump  images  private  volume

Something tells me there is a correct way to do this and this isn't it.

I did read the wiki on btrfs, but it just wasn't clear to me how I would use/mount the volume instead of the disk? I think that's what I did... Not sure. I'm used to older file systems :)
 
I can't say the method you used vs the one I did is right or wrong but here is how I made mine & it works fine.
I put three disks into a raid0 but the principle is the same.
Aside from how I mount mine a little differently I will say that since my raid0 is for media storage (not critical if it dies) I also disabled COW on the specific folders where mostly media is stored. Nothing critical is kept on this raid array.
Code:
lsblk
Then created the btrfs raid0
Code:
sudo mkfs.btrfs -d raid0 -m raid0 -L btrfs /dev/nvme0n1 /dev/nvme1n1 /dev/nvme2n1 -f
Find the UUID for the raid
Code:
sudo btrfs filesystem show
create the mount point against the UUID (not the device name as that can change)
Code:
sudo nano /etc/fstab
syntax
Code:
# btrfs raid-0 by UUID mnt/pool
 UUID=95e9e8a7-1406-4541-bcbb-fd2dc5a2289c /mnt/pool btrfs defaults,noatime,lazytime 0 0
At this point you can mount or reboot and I choose the latter.
After a reboot I check the mount is in place as I expect.

Code:
btrfs filesystem df /mnt/pool
btrfs filesystem show
Next I create the root folders within the raid that I will end up sharing out via nfs/samba (I mentioned this is for media streaming/plex/jellyfin)
Code:
sudo mkdir -p /mnt/pool/media
sudo mkdir -p /mnt/pool/downloads
Now that the unimportant folders are created I disable COW on them and their sub-folders/files. Files/folders created before disabling COW will have COW still enabled so best to do this upon creation.
Code:
sudo chattr +C /mnt/pool/media
sudo chattr +C /mnt/pool/downloads
Then I confirm COW has been disabled on them. I expect to see a 'C' for the folders with COW disabled.
Code:
sudo lsattr /mnt/pool
Then I move onto making the other folders I do want COW to protect along with one more view of the folders COW is disabled on.
Code:
sudo mkdir -p /mnt/pool/media/tv
sudo mkdir -p /mnt/pool/media/movies
sudo mkdir -p /mnt/pool/media/music
sudo mkdir -p /mnt/pool/applications
sudo mkdir -p /mnt/pool/files/public
sudo mkdir -p /mnt/pool/files/private
sudo mkdir -p /mnt/pool/files/applications
sudo lsattr /mnt/pool
One last side note, I add the -p switch when creating directories as a matter of habit. When I create subs where the top level is also not there, it creates them all in one go.
Cheers!