264
submitted 11 months ago by 0x4E4F@infosec.pub to c/linuxmemes@lemmy.world
top 48 comments
sorted by: hot top controversial new old
[-] hperrin@lemmy.world 41 points 11 months ago

Ok, I don’t get it. Can you explain it to me?

[-] 0x4E4F@infosec.pub 53 points 11 months ago

Timeshift works only with BTRFS subvolumes, thus, if you wanna have backups (snapshots), you have to have subvolumes and not install in the root of a BTRFS filesystem πŸ˜”.

[-] eager_eagle@lemmy.world 19 points 11 months ago

That's only to backup/rollback the root though, right? If one's looking to backup - say - their home dir, they can just recreate the home as a subvolume without reinstalling the system. Or am I mistaken?

[-] AnonStoleMyPants@sopuli.xyz 4 points 11 months ago

You can definitely do this with a few commands.

[-] raldone01@lemmy.world 4 points 11 months ago* (last edited 11 months ago)

https://github.com/raldone01/config_fish/blob/main/tdcff_functions/btrfs_folder_to_subvol.fish

Because I often forget to do it I wrote a little helper script.

This file can be run or sourced and only depends on btrfs-progs and fish.

[-] 0x4E4F@infosec.pub 3 points 11 months ago

Awww man, thanks ☺️.

Good thing I love fiish, it's my default shell πŸ˜‰.

[-] 0x4E4F@infosec.pub 2 points 11 months ago

Yes, you can just set it to mount a, let's say @home, subvolume to /home and that's that, done.

[-] Turun@feddit.de 7 points 11 months ago

If you want to you can just create a new subvolume, mount it temporarily and move all your files from root to there. Then you need to figure out how to make the new subvolume your root directory upon boot and you are done.

[-] 0x4E4F@infosec.pub 1 points 11 months ago* (last edited 11 months ago)

I know how to do that, you set the subvolume as the default one, thus, when mounting, if no options are passed, it always mounts that subvolume as root.

But, you have to disable that. Sure, I set it during install, cuz installers are stupid (if you tell it to install in /@, it will most probably moan), but disable it after first run (set the real root as the default subvol, i.e. mount point) and just add subvol mount options in fstab.

It's just extra steps I have to do now πŸ˜’, that's why the rant.

[-] PrecisePangolin@lemmy.ml 6 points 11 months ago

Thank you for sharing your knowledge.

[-] reflex@kbin.social 2 points 11 months ago* (last edited 11 months ago)

Timeshift

Oh okey so if I have Snapper already, nothing I need to worry about?

[-] valveman@lemmy.eco.br 2 points 11 months ago

Snapper also uses btrfs subvolumes to create snapshots, so if you did create them during your installation process, nothing to worry about.

I don't remember if there is a way to create them after the installation, neither if it's a tough process tho. I used to simply reinstall when I messed up with the subvolumes.

[-] backhdlp@lemmy.blahaj.zone 2 points 11 months ago

sudo btrfs subvolumes create /path/to/subvolume

If you don't configure anything, root will already be a subvolume.

If you wanna make a used directory a subvolume, you have to move the contents first, and move them back after creation.

The only thing that takes time here is the move

[-] 0x4E4F@infosec.pub 1 points 11 months ago* (last edited 11 months ago)

Yeah, but Timeshift uses the Ubuntu style subvolume naming, @ for root, @home for /home, so you have to create them that way, otherwise, it won't work. It can work if you tell it to ignore home, but checks for @ as root on start up.

[-] backhdlp@lemmy.blahaj.zone 2 points 11 months ago

Wasn't aware of that, using snapper for my snapshotting needs.

[-] 0x4E4F@infosec.pub 1 points 11 months ago* (last edited 11 months ago)

I haven't tried it. Does it have like daily, weekly, monthly snapshots setup?

[-] backhdlp@lemmy.blahaj.zone 2 points 11 months ago

You can have hourly, daily, weekly, monthly and yearly. I also use snap-pac to make snapshots before and after pacman transactions.

Check out https://wiki.archlinux.org/title/Snapper

[-] domi@lemmy.secnd.me 2 points 11 months ago* (last edited 11 months ago)

Check out Btrfs Assistant. It does what Timeshift does with a similar UI but works with any subvolume layout.

[-] 0x4E4F@infosec.pub 1 points 11 months ago

Hm, will check it out, thanks for the suggestion πŸ˜‰.

[-] rostby@lemmy.fmhy.net 2 points 11 months ago

Immutable distros rejoice 😎

[-] 0x4E4F@infosec.pub 1 points 11 months ago

Take way too much space... I dual boot on the same drive 🀷.

[-] Discover5164@lemm.ee 27 points 11 months ago

you can create them afterwards and move the stuff into the subvol. do it from a live usb and don't forget to update fstab. be sure to use rsync with the flag to keep permissions etc

[-] 0x4E4F@infosec.pub 7 points 11 months ago

Yeah, that should work, thanks πŸ‘.

[-] cashews_best_nut@lemmy.world -1 points 11 months ago

You're welcome

[-] AffineConnection@lemmy.world 1 points 11 months ago* (last edited 11 months ago)

That's simple, but it's a completely unnecessary waste of I/O. You could create a writable snapshot of the btrfs root as a subvolume, edit the fstab and any other relevant files within that new subvolume, reconfigure the bootloader to specify that subvolume as the root filesystem (as a Linux kernel command line argument) instead of the btrfs root, and then reboot. After rebooting, the original btrfs root can be mounted, and everything unwanted from the original root (other than the new subvolume and its ancestor directories, obviously) can be deleted. Do not delete anything that you didn't want to lose the changes to on the original root subvolume that you did after creating the snapshot, as the snapshot only remembers what you did before, as well as the changes made specific only to it (like the fstab).

If one wanted to create multiple subvolumes for different purposes, the above procedure can be modified. For instance, if one wanted a separate subvolume mounted at / vs /home, then one can create two writable snapshots, empty out the contents of home in new subvolume 1 (but not the /home directory itself because you want the directory to exist for something to mount onto it), empty out everything outside of home within new subvolume 2, move the contents of home therein up one directory and remove the /home directory itself. Now, one can edit the fstab in new subvolume 1 as appropriate (not forgetting to have new subvolume 2 mount at /home), edit any other relevant files, reconfigure the bootloader to tell the Linux to use new subvolume 1 as the root subvolume, then reboot. Finally, one can remove the unnecessary files from the original root.


Edit:

It is arguably better to manually specify the new root when booting in the Linux kernel command line, and not reconfigure the bootloader until you successfully boot. After success, (if the following is relevant to your system) use update-grub, and it should look at fstab to automatically reconfigure the bootloader accordingly to use the appropriate new subvolume as specified at fstab.

This is what I did years ago to one of my own systems, although I don't know anything about Timeshift and how it requires things to be set up (I have my own backup scripts that are run by cron). I could have just snapshotted the btrfs root directly for snapshots, but I wanted the snapshots to be cleanly separated from the subvolume used as the Linux VFS root (except when I explicitly mount them).

[-] Discover5164@lemm.ee 1 points 11 months ago

you're right, this is a solution efficiently using the btrfs features. thank you

[-] CarlosCheddar@lemmy.world 23 points 11 months ago

Me when I converted to btrfs from ext4. I went in blind and had no idea about sub volumes.

[-] 0x4E4F@infosec.pub 5 points 11 months ago

I need it because of Timeshift, it works with subvolumes only.

[-] shunir@lemmy.world 3 points 11 months ago
[-] bjoern_tantau@swg-empire.de 12 points 11 months ago

I thought the flexibility of BTRFS was that you could basically always add subvolumes. Shows what I know.

[-] Ooops@kbin.social 12 points 11 months ago

Yes, you can. But the usual setup is to have a file system root that is nothing but subvolumes, which you can then use and mount basically as if they were independent partitions. But when you don't create a root subvolume for your system root first, you install the system directly on the file system root alongside created subvolumes. This tends to get messy as strictly speaking the file system root is a subvolume, too. So now you have that with your system installed and all other subvolumes nested inside it.

[-] Chewy7324@discuss.tchncs.de 2 points 11 months ago

Yes. Usually the OS installer takes care of creating a root and home subvolume. Except Arch and similar barebones installer have instructions in the wiki.

[-] 0x4E4F@infosec.pub 5 points 11 months ago

Yes, you can, but now I have to move the entire install to a subvolume, risking borking the install πŸ˜’.

[-] zzzz@lemmy.world 4 points 11 months ago

Or, ya know, just reinstall right quick.

[-] 0x4E4F@infosec.pub 1 points 11 months ago

Yeah, I'm thinking between that and rsync-ing to a new subvolume... the install is just bare bones, almost nothing was set up.

[-] acockworkorange@mander.xyz 7 points 11 months ago

Mint automatically creates a @home sub volume if you install your root in a Btrfs partition. Just saying.

[-] 0x4E4F@infosec.pub 1 points 11 months ago

Yeah, Ubuntu does it as well. But other distros not based on Ubuntu, don't.

[-] Knusper@feddit.de 5 points 11 months ago

Well, openSUSE did it long before everyone else. So, Debian, Fedora, Arch?

I would kind of be surprised by Fedora, too, as I thought, they shipped out-of-the-box automatic snapshotting, but the comment from @bruhduh@lemmy.world sounds like that is still a problem...

[-] bruhduh@lemmy.world 3 points 11 months ago

Yeah i was surprised as well) thought automatic btrfs partitioning by fedora gui installer would suffice, but it's not, it did not had subvolumes set after installation, so timeshift btrfs didn't worked, after i set subvolumes timeshift started working, but after update from 38 to 39 everything broke and locked up my ssd

[-] acockworkorange@mander.xyz 2 points 11 months ago

OpenSUSE does this as default, which is laudable. Mint will only use Btrfs if you manually tell it to, it just handles it gracefully once you do choose to use it.

[-] 0x4E4F@infosec.pub 2 points 11 months ago

Arch, probably not, Void, most definitely not.

[-] cashews_best_nut@lemmy.world 3 points 11 months ago

I use btrfs. Is there a reason I'd want subvolumes? What are they for? Why not just use partitions?

[-] 0x4E4F@infosec.pub 9 points 11 months ago

Snapshot software works with subvolumes, not with partitions.

[-] mac@infosec.pub 2 points 10 months ago* (last edited 10 months ago)

My most recent version of this was symlinking SSL Certs before building Nix packages, a simple task I just kept forgetting to and was then greeted by errors.

[-] Johanno@feddit.de 2 points 11 months ago

Hold on a minute. I can do subvolumes without partitioning?

[-] 0x4E4F@infosec.pub 6 points 11 months ago

Yep, you just add/remove them with btrfs tools.

[-] Chewy7324@discuss.tchncs.de 6 points 11 months ago

A single btrfs partition on a drive with multiple subvolumes is the way to go.

[-] bruhduh@lemmy.world 2 points 11 months ago

Fedora be like) i broke my recent fedora installation because of that, installed fedora 38 two months ago, made sub volumes, updated to 39, and it broke, and locked up whole ssd with it, had to recover data

this post was submitted on 03 Dec 2023
264 points (97.8% liked)

linuxmemes

21281 readers
12 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack members of the community for any reason.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • These rules are somewhat loosened when the subject is a public figure. Still, do not attack their person or incite harrassment.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn. Even if you watch it on a Linux machine.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, and wants to interject for a moment. You can stop now.
  • Β 

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't fork-bomb your computer.

    founded 1 year ago
    MODERATORS