Amazing...Learn something new everyday

Questions about other topics and general discussion about LMDE
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Nuts2u
Level 3
Level 3
Posts: 127
Joined: Sun Nov 27, 2011 8:44 pm

Amazing...Learn something new everyday

Post by Nuts2u »

Wanted to share my having an epiphany while using LMDE5 and BTRFS. I have been using LMDE since LMDE3 . It is a solid stable OS and I do not think I will ever change to another distro. I format and use btrfs on my system, the lmde5 installer sets up the @ and @home subvol's during installation if you check the use btrfs in the latest installer. This in turn enables utilizing btrfs snapshots using Timeshift, the snapshots are created instantly and rolling back only requires a reboot after using Timeshft restore function which is also instant. Very clean, very quick.

Anyway moving on, I created a separate partition, formatted it to btrfs, and used it for my VirtualBox VM's, one of the vm's is Win10 and the others are various Linux distro's for testing and observation. I use the VirtualBox snapshoting feature so I have no need for btrfs snapshots of that partition. But I like the bitrot checking feature of btrfs so that is why the vm's are stored there. The vm's total around 150 Gig depending on how many os's I'm testing. I used the "move machine" feature in VirtualBox to move the vm's periodically from the partition they are located on to a Temp folder in my Home dir. I do this because btrfs is a COW system and I had read that vm's tend to become fragmented file-system wise, numerous file extents that btrfs needs to keep track of. Everything is stored on a 1 TB Samsung 970 EVO Plus nvme drive so I am not concerned with "data fragmentation". Moving the vm's to and from my home dir temp folder occasionally allows btrfs to do its internal extent housekeeping so the extents are basically "defragmented" in the internal btrfs file system.

So one day I come across a Reditt thread and the original poster was moving from ext4 to btrfs and wanted to store his vm's in a folder in his home dir, but didn't want to include them in a Timeshft btrfs snapshot. I'm thinking "that is why I have a separate partition and btrfs subvol!!!"

Well lo and behold this poster says" that's easy, no problem... here is how you do it" Now I'm really interested. Here is the quote...

"If you never turned a folder into a subvolume, you first rename your folder to folder.old or something, then do btrfs su c folder-name to create the new subvolume (without sudo), then do cp -a --reflink folder.old/. folder/. and you are done. You remove the old folder after you checked that everything still works."

So I do this to create a new subvol in my home dir and it works!!! I did not do the cp -a --reflink cause I used the Virtual box "move" function to move the files from the old partition to the new subvol I created in my home dir. Fired up VirtualBox, checked all the vm's and all works correctly. Next I go into Timeshift, create a snapshot, then browse the contents of the snapshot, I see the new folder/subvol I had created and populated with my vm's and the snapshot shows the folder, but it is empty, the data was excluded from the snapshot. PERFECT!!! I delete the separate partition. Now when I do my weekly backups I only have one partition instead of two to backup.....Life is good!!

So one day I decide to move the vm's for reasons stated above "file extents" cleanup. I open VirtualBox and first move my Win10 vm which is about 50 Gig in size and it appears nothing happens??? confused???? When I did it with two partitons it took about 10 seconds to do the move, and there was a progress bar showing the progress. Now nothing. So I open the temp folder I moved the vm to and there it is!!!! All 50 gig. I open the source folder/subvol and there are the rest of my vm's. So I use VirtualBox "move" feature and move all the rest of the vms...same thing as the Win10 move....No progress bar...Nothing. When I open the temp folder there are all my vm's...150 gig worth, and the source folder/subvol is completely empty. Start VirtualBox and test all the cm's in the new location, they all work just fine.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Silence is golden. Duct tape is silver. Welcome to Hell. Here's your copy of Windows.
Nuts2u
Level 3
Level 3
Posts: 127
Joined: Sun Nov 27, 2011 8:44 pm

Re: Amazing...Learn something new everyday

Post by Nuts2u »

Just a followup to my post.....The idea I posted about is sound, but has a Fatal flaw. Since the btrfs subvol is created under my home dir and is excluded from my Timesync btrfs snapshot, If I restore from a previous Timeshift snapshot, the subvol is not restored and is gone. This is the Fatal flaw in my opinion. What I ended up doing is creating another subvol (@vbox) at the root level and mounting it via fstab. This allows Timeshift to create the @ and @home subvol snapshots, excluding the @vobx subvol I created at the root level. Now I can restore a previous Timeshift snapshot and my @vbox subvol is untouched.

I now have only 1 partition instead of the 2 I had previously. I started using the 2 partition setup way back in 2014, when btrfs still had stability issues and I did not want to lose and have to restore from a backup the @vbox subvol. Creating a second btrfs partition and placing the @vbox subvol in it solved that problem then, and I just left it alone. What id did not like about this setup was moving 150 GIG worth of VM's caused alot of writing on my SSD. I mentioned the reson for doing this in my previous post. Now that it all resides on one large partition, when I do the move, it really is a move, pointers are just involved not the coping of all the data. Happens now in literally a blink of and eye.

I really do love btrfs as my file-system, it is fully aware of a ssd, I use the Zstd compression mount option, and the discard=async which performs the trim command to deleted files automatically. The btrfs compression enables about 10 percent size savings on my @vbox VM's (15.5 GIG). Otherwise my @vbox would be 165G instead of 150G Because of this I like to run the latest Linux kernel for keeping btrfs at the latest stable version. I'm running the Xanmod 5.18 kernel now....very stable very reliable.....they also have an edge version of the kernel for people who have the latest and greatest hardware, I do not so I run the stable kernel. If you are interest in the kernel here is the link https://xanmod.org/
Silence is golden. Duct tape is silver. Welcome to Hell. Here's your copy of Windows.
Locked

Return to “Other Topics & Open Discussion”