hi there, how is it going.
i read this thread https://wiki.gentoo.org/wiki/Filesystem/Security
so i thought of doing similar filesystem structure but with btrfs subvolumes instead of ext4 partitions.
i succeeded in mounting almost all the folders the way i wanted(as i guess), however i'm still facing a problem which is the apps no longer find their data that they were configured on.
please someone helps me figure out a way to move the data from the old directories to the new btrfs subvolumes. any needed information will be provided once requested.
the directories that i wasn't able to mount are
yes i forgot to mention that i want to mount them in fstab.
here is how they are:
#/dev/sda4 /var btrfs nodev,compress=lzo,subvolid=348 0 3 (commented them to be able to start the apps)
/dev/sda4 /usr/local btrfs nodev,compress=lzo,subvolid=349 0 3
/dev/sda4 /srv btrfs nodev,compress=lzo,subvolid=350 0 3
/dev/sda4 /root btrfs nodev,compress=lzo,subvolid=351 0 3
/dev/sda4 /opt btrfs nodev,compress=lzo,subvolid=355 0 3
#/dev/sda4 /nix btrfs nodev,compress=lzo.subvolid=356 0 3
#/dev/sda4 /var/log btrfs nodev,compress=lzo,subvolid=357 0 3
#/dev/sda4 /var/tmp btrfs nodev,compress=lzo,subvolid=358 0 3
#/dev/sda4 /var/cache/distfiles btrfs nodev,compress=lzo,subvolid=359 0 3
#/dev/sda4 /var/cache/binpkgs btrfs nodev,compress=lzo,subvolid=360 0 3
you answered something i was wondering about which is using the partition flags with btrfs subvolumes, thank you for that.
my problem is the subvolumes are empty so the installed apps cannot find the old configurations since they are in the old directories so they crash
i searched about the case, i found that there are 2 types of copying, first by moving the files themselves, and the second is like a virtual method. it appears like @subvolume (saw it in opensuse fstab)
how can i do that.
i would like to thank everyone that contributed to the gentoo project in any means
A tip.
Next time you want to play with btrfs use an Arch live iso.
Create a btrfs partition, mount it on /mnt, create btrfs subvolumes on /mnt bootstrap a system on /mnt then use
mount -t btrfs -o subvol=distfiles UUID=<uuid of btrfs partition> /var/cache/distfiles
etc
what is the command i need to execute before i put it in the fstab the way you did, and does it really matter?
i just followed the wiki above and executed
Its ok you do it the way you like.
I just mentioned that in complicated fses like btrfs the Archlinux genfstab util can simplify things a bit.
Ah ah ok perfect!
I didn't know genfstab is available in Gentoo also.
Foolish me..
sudo btrfs subvolume create /mnt/btrfs/vol1
If your btrfs partition is mounted on /mnt/btrfs then yes i think its the correct command.
More like
what is the difference between mounting with "subvolid" and the one you mentioned "subvol"
does subvol make the files appear on the new subvolume or they both do the same? i guess it does not though (the thread below proves that)
no problem my friend, technology is always evolving and changing.
there is this thread and it tells how to make the new subvolumes with moving the data but it is not detailed enough https://askubuntu.com/questions/100187/ ... subvolumes
please help me with it
thank you for the efforts you are doing with me
i would like to thank everyone that contributed to the gentoo project in any means
i'm sorry for my late reply.
i'm sorry also to say that i deleted the subvolumes and referred back to the previous configurations.
however this is my fstab:
i did not change "3" because i went back to the previous configs.
i guess all i have to do is to make snapshots and for every folder i add @ in front of the original name, mount it on the root folder and add it with subvol="@(folder) in fstab.
i will try it and tell if it worked.
i would like to thank everyone that contributed to the gentoo project in any means
i'm wrong, there is no way to make a snapshot for a folder
this thread explains it https://unix.stackexchange.com/question ... -directory
i got the same error when i tried.
the only remaining possible way is to copy or move the files.
i would like to thank everyone that contributed to the gentoo project in any means
abdus wrote:i'm wrong, there is no way to make a snapshot for a folder
Yes and no.
You can just btrfs sub create dir and then you can snapshot 'dir'. This assumes 'dir' didn't exist beforehand.
You can create nested subvolumes. Those subvolumes will automatically be mounted when you mount their parent.
I do this with every btrfs installation to avoid polluting my fstab.
alamahant wrote:You got me confused.Do you have a btrfs filesystem that contains a Gentoo installation or not?
Does your fstab reflect this filesystem?
i'm sorry for getting you confused.
i do have a system with gentoo on a btrfs filesystem. it is not a fresh install
my exact problem is finding a way to mount the system folders like /usr /var /opt etc, you know what i mean, on btrfs subvolumes like in opensuse fstab
not only that, mounting them with not having data loss as much as possible and keeping the system configs exactly the same.
i would like to thank everyone that contributed to the gentoo project in any means
btrfs sub create /mnt/btrfs-root/usr
btrfs sub create /mnt/btrfs-root/var
mkdir /mnt/btrfs-root/var/cache
btrfs sub create /mnt/btrfs-root/var/cache/distfiles
btrfs sub create /mnt/btrfs-root/var/cache/binpkgs
btrfs sub create /mnt/btrfs-root/opt
... There you can see you can treat subvolumes like a special directory inside btrfs. ;)
Copy files from your old root to the newly created btrfs root.
Adjust your system to your new btrfs.
You only need to add the root btrfs line into your fstab (along with maybe /boot and EFI partition)
If you don't plan to use btrfs on your root partition, then you need to add lines for each btrfs subvolume into your fstab.
thank you for your answers and help guys.
i am sorry for my late reply.
after trying multiple times i was eventually able to put the system folders in btrfs subvolumes
i did not need to use live cd except for /usr folder.
mostly all i had to do was renaming the folder by executing
sudo mv /opt /opt1 for example for all the folders, afterwards execute
sudo btrfs subvolume create /opt
sudo cp -a --reflink=always /opt1/*
checking the integrity of files in the subvolume
it's optional to put it in the fstab file
then deleting the /opt1 folder using
sudo rm -fR /opt1 i did that with all the other folders without live cd for the live cd i did it with usr folder i had to mount the partition in /mnt
execute the same commands but with adding /mnt to the paths.
i will try doing the same thing with the folders under /var later.
thank you guys.
i did not succeed from the first time there was a problem with programs starting and working then i repeated again and had kernel panic
if i do not succeed i simply rename the renamed folder to the original name or remove the line of the subvolume from fstab if it is not with the same name as the folder itself and reboot
i would like to thank everyone that contributed to the gentoo project in any means