You are not logged in.
Pages: 1
hey guys, excuse me if this was already told somewhere, I found a similar post while i was ddg-ing for guides on how to do btrfs, and i'v spent the last 16 hours not being able to find the thread to find my answer, and it's driving me crazy ... so .. recently i switched to btrfs as I bought a SSD and wanted to see what the fuss is about... so first time I did a
btrfs su cr _active
btrfs su cr _active/root
btrfs su cr _active/home
btrfs su cr _active
btrfs su cr _active/var
btrfs su cr _active/tmp
btrfs su cr _snapshots
btrfs su cr _snapshots/root.s
btrfs su cr _snapshots/home.s
chattr +C _active/var
chattr +C _active/tmp
then mounted the partitions, installed everything, and then realized that nodatacow doesn't work if on same partition, as it mounts with the root subvolume's mount options (i think) ... then I came across this idea somewhere on the internet and wanted to replicate it, but couldn't find the post anymore, and decided to freestyle it out and drastically failed, so here is what I did
I reduced /dev/sda6 (btrfs main partition) by 35G, created a new partition, and did the following
mkfs.fat -F32 /dev/sda5
mkfs.btrfs -f /dev/sda6
mkfs.btrfs -f /dev/sda7
cd /mnt
mkdir cow
mkdir nocow
mount /dev/sda6 /mnt/cow
mount /dev/sda7 /mnt/nocow
cd cow
btrfs su cr _active
btrfs su cr _active/root
btrfs su cr _active/home
btrfs su cr _snapshots
btrfs su cr _snapshots/root.s
btrfs su cr _snapshots/home.s
cd ..
cd nocow
btrfs su cr _active
btrfs su cr _active/var
btrfs su cr _active/tmp
chattr +C _active/var
chattr +C _active/tmp
cd ..
umount /mnt
mount -o compress=lzo,subvol=_active/root /dev/sda6 /mnt
mkdir -p /mnt/{.snapshots,boot,home/.snapshots,var,tmp,mnt/{btrfs/{cow,nocow},data,windows,ms-data}}
mount -o compress=lzo,subvol=_active/home /dev/sda6 /mnt/home
mount -o compress=lzo,subvol=_snapshots/root.s /dev/sda6 /mnt/.snapshots
mount -o compress=lzo,subvol=_snapshots/home.s /dev/sda6 /mnt/home/.snapshots
mount -o compress=lzo,subvolid=5 /dev/sda6 /mnt/mnt/btrfs/cow
mount -o nodatacow,subvol=_active/var /dev/sda7 /mnt/var
mount -o nodatacow,subvol=_active/tmp /dev/sda7 /mnt/tmp
mount -o nodatacow,subvolid=5 /dev/sda7 /mnt/mnt/btrfs/nocow
mount /dev/sda5 /mnt/boot
mount /dev/sdb2 /mnt/mnt/data
mount /dev/sda3 /mnt/mnt/windows
mount /dev/sdb1 /mnt/mnt/ms-data
pacstrap /mnt base base-devel linux-ck-ivybridge linux-ck-ivybridge-headers linux-firmware intel-ucode btrfs-progs dosfstools exfat-utils ntfs-3g grub grub-btrfs efibootmgr os-prober man-db man-pages texinfo snapper networkmanager reflector git neovim
genfstab -U /mnt >> /mnt/etc/fstab
archroot /mnt
and the rest of the install process
for some reason, when I boot in my system, nothing is mounted, but the fstab looks okay ...
then after investigating I realize that the mount -o nodatacow,subvolid=5 /dev/sda7 /mnt/mnt/btrfs/nocow has the same subvolid as the mount -o compress=lzo,subvolid=5 /dev/sda6 /mnt/mnt/btrfs/cow and that that's probably causing the problem, i comment it out, boot in, and everything is mounted ...
now problem with this that I have is, when i btrfs subvolume list / in my root directory, it doesn't display the var / tmp subvolumes aka, i have no control over them, so how do i mount the root subvolume of /dev/sda7 to /mnt/btrfs/nocow ?
second question I have is about /tmp and tmpfs ...
is there a way to mount /tmp as a tmpfs under a btrfs subvolume? and if not, and if i don't create a subvolume of tmp, will snapshoots of root make snapshots of the tmpfs?
I have tried masking tmp.mount systemd unit, and adding the needed configuration to /etc/tmpfiles.d/tmp.conf to dump the files after every reboot, but for some reason the tmp subvolume is not mounted at all ...
also on the arch wiki it recommends a few paths in /var to create subvolumes for, i'm wondering if that's really necessary or is it enough just to create a /var subvolume?
Last edited by kronikpillow (2020-12-02 21:34:48)
Offline
You can have "nodatacow" on the same filesystem if you use "chattr +C" on an empty directory or subvolume. When you then later create files and sub-directories in that location, those will inherit the "+C" no-CoW attribute. You can check the "+C" attribute with the "lsattr" command.
Do you realize that "nodatacow" disables checksums?
"compress=lzo" is perhaps a bad choice now that "zstd" was introduced. You can choose the zstd compression level like this: "compress=zstd:1". The default level is "3". When run at level 1, zstd will be the same compression speed as lzo but it will reduce file sizes a lot better.
I've seen people recommend to use "compress-force=zstd" instead of "compress=zstd". The idea is that zstd has detection for uncompressable data built-in, and that detection works better and faster than the btrfs decision-making for what should be compressed or not.
I don't understand your "/tmp" problem. You want the normal tmpfs setup for /tmp, right? If that's the case, you don't really have to do anything. You have an empty directory named /tmp on your root filesystem and the tmpfs filesystem will then get mounted in that place and overlay the location. This works the same as with ext4.
The "btrfs subvolume list /" command doesn't show "/var" because your "/var" location is on another filesystem. You have to do "btrfs subvolume list /var".
About the subvolumes inside /var, the subvolume help if you want to do snapshots. When you snapshot a location, the subvolumes under it won't be snapshotted. You for example probably don't want "/var/cache/pacman" in your snapshots because the archive files in there will take up a lot of space.
About "genfstab"... make sure you take a look at the /etc/fstab result and fix it if something looks wrong to you. It always put too much stuff in there for me.
Offline
yes but if /tmp is tmpfs, will btrfs make snapshots of /tmp? cuz i dont want it to make snapshots of /tmp ...
regarding /var ... if /var is a subvolume, do i really need /var/cache/pacman? is there anything in /var that is not in /var/cache/pacman that should be snapshotet?
Offline
Yes, you need /var inside your system's snapshots. You can't recreate a working system with /var missing in your backups.
About concrete examples of this, there is pacman's database inside there somewhere: pacman will lose its knowledge about your installed packages if /var is missing. I assume there's also other software that works the same way and would break without its /var data.
About /tmp, after the tmpfs mount overlays over /tmp location, your software that writes into /tmp will write into the tmpfs filesystem. The /tmp that's on your btrfs will not be visible to the software, so that /tmp on the btrfs filesystem will not change and your snapshots won't use space for it.
Offline
Yes, you need /var inside your system's snapshots. You can't recreate a working system with /var missing in your backups.
About concrete examples of this, there is pacman's database inside there somewhere: pacman will lose its knowledge about your installed packages if /var is missing. I assume there's also other software that works the same way and would break without its /var data.
About /tmp, after the tmpfs mount overlays over /tmp location, your software that writes into /tmp will write into the tmpfs filesystem. The /tmp that's on your btrfs will not be visible to the software, so that /tmp on the btrfs filesystem will not change and your snapshots won't use space for it.
nice, thank you for the reply mate
regarding /var .. but if /var is mounted as a subvolume the database of pacman will be in it right? ... em ... yeah, now that i think about it, it probably will, but it will be from the "broken install" for example? this is strange, I can link at least 15 Arch linux with BTRFS and Snapper or timeshift that simply create /var as a subvolume and thats it ... Ok, i'll go with your advice
so ...
the arch wiki recommends:
/var/log
and to prevent slowdowns
/var/cache/pacman/pkg
/var/abs
/var/tmp
/srv
any other recommendations?
probably the locations for the virtual machines in /var althou I don't use virtual machines, I learn things the hard way, break my system and start over ![]()
probably /opt and /usr/local/bin or just /usr/local?
Last edited by kronikpillow (2020-12-03 18:04:03)
Offline
Pages: 1