this post was submitted on 26 Oct 2023
57 points (95.2% liked)

Linux

48092 readers
891 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Hello, I've been a long time Linux user but I had a 5 years break and I am coming back to it now.

I've been trying several Linux distributions in the past week, installing the packages and configuring them as I need with several different orders of success.

My last case was an Ubuntu installation that I was very happy with and pretty close to call it setup and done, until I installed virtualbox and restarted the system only to find it bricked.

Obviously I could try to drop into one of the terminals on ctrl + alt + Fx and fix it, but I wonder if I could be smarter about it and be more prepared for this kind of situation.

One of the starting points I think would be having a separate home partition from the rest of the system. I used to have it in the past and it was great.

But then what's next? What are the best FS I could pick for each type of partition? A performant one to keep the code and package manager cache, a journaling/snapshop based one for system, another type for game data, etc etc.

What if I would like to have a snapshot of working version of my system backed up somewhere ready to restore as simple as simple as possible?

How do you configure your systems in order to quickly recover from an unexpected bricking without growing some more white hairs, and squeezing as much performance vs feature for each of your use case?

top 37 comments
sorted by: hot top controversial new old
[–] stuck_in_the_shell@programming.dev 11 points 1 year ago (2 children)

Well having a dedicated /home partition is the very minimum and pretty much default.

If you are interested in having a backup/restore solution for your system you are looking for BTRFS which uses sub volumes instead of primary partitions and is compatible with snapshot tools, those tools being Timeshift and Snapper.

I do think Snapper is the superior solution however it's also more complex to set up and requires significantly more prep work. Imo totally worth it.

I currently use it on my main machine Debian with BTRFS and Snapper and couldn't be happier.

[–] Frederic@beehaw.org 4 points 1 year ago* (last edited 1 year ago) (1 children)

I installed (well, compiled) Btrfs Assistant, it integrates with snapper and btrfs maintenance, I had to create cron jobs for monthly/daily by hand, but the GUI is pretty nice.

[–] Crozekiel@lemmy.zip 1 points 1 year ago

This came pre installed and setup on my Garuda Linux install and it's great. By default it takes a snapshot before and after every update or installation through the package manager so if something goes wonky I can just select the previous snapshot in grub and be back up and running in seconds.

Also just recently installed bazzite on a laptop and it appears to automatically do something similar, but I haven't spent as much time with it to know the ins and outs yet.

[–] pathief@lemmy.world 1 points 1 year ago (1 children)

What's the appropriate size for a home partition, though?

That's not the question that needs to be answered, first you must allocate enough space for you system partition, and whatever other system related partitions that you want to use, var, temp, swap, you get the gist, then whatever space you have left is your home partition. This scenario being a default personal use desktop ofc.

If this is going to be a BTRFS system then it also doesn't matter since sub volumes share the total space available dynamically.

Also if this is a modern hardware consider not having a swap partition and instead use ZRAM.

[–] vettnerk@lemmy.ml 8 points 1 year ago* (last edited 1 year ago) (1 children)

On servers I like to have /var on its own partition. Partially as a habit from the olden days of using FreeBSD in the 90's, but also because that means that / will mostly be left with things that don't really change. I've had to clean out clogged up / too many times. So in effect, my partion schema for a typical production server looks like this:

/ ext4
/local xfs
/global usually beegfs or nfs, but sometimes a local xfs.
/var ext4
/home ext4

[–] iHUNTcriminals@lemm.ee 1 points 1 year ago* (last edited 1 year ago) (2 children)

Eli5 what's in /var and /local?

/Global is just personal storage like /home?

I never manually make fs but I really want to have a good set up like on was asking.

Also do you know what's up with /swap? Is it beneficial aside from getting the ability to hibernate?

Also... What happens when I reinstall an OS and my home is separate? If I had Kodi installed as a flat pack and then reinstalled a like-distro, would Kodi still be set up and available with all my settings? Or would I have to reinstall again?

...obviously I don't know much about the fs

[–] vettnerk@lemmy.ml 5 points 1 year ago

/var was originally for files of varying sizes, but today it's more of a general purpose storage for the system, such as log files. It used to make sense to have this as its own partition as read and write operations were generally expected to be small but many, as opposed to few and large for the rest of the storage areas. With its own partition it's easier to adjust the filesystem to accomodate the I/O. Today it's mostly used for logs.

/local used to be similar to /usr/local on some systems, but that's not really the case anymore. It's a directory we use at work for local stuff, as opposed to /global which is shared with the entire server cluster.

You can have any directory as its own partition, just make sure the mountpont reflects it. /home is a very common example of this - using this as a mountpoint instead of just a normal directory named /home prevents regular uaers from filling up the root filesystem and borking normal operation.

Swap is what your PC uses when it runs out of RAM. It can be a partition, or it can be individual (large) files. As an example, I have a rather huge and demanding factorio save which takes up more memory than I have on my laptop, so when I want to play it I have to add additional swap space. It's similar to what windowa refers to as the pagefile. It's slow compared to RAM, but it enables the PC to operate relatively normal despite being bogged down with loads of allocated memory.

[–] EuroNutellaMan@lemmy.world 2 points 1 year ago

I don't know the answers to the other questions but yes swap is important, without it as soon as your system exceeds the RAM available to it it will freeze entirely.

[–] Yoddel_Hickory@lemmy.ca 8 points 1 year ago

Btrfs snapshots are great! All my filesystem is Btrfs, with subvolumes for root, home and var.

I'm using the Fedora immutable distros on many computers, it's great to be able to boot into a previous version of the system if issues arise. Not that issues arise, since most packages are installed as Flatpaks, in a toolbox or in a container. Makes the systems nearly unbrickable.

[–] Liz_thestrange@lemmy.ml 6 points 1 year ago (1 children)

Nothing, I just corupted my hard drive with all my college work for tomorrow and im trying to save them, im feeling so stupid rn, im nothing but a failure at this point

[–] disheveledWallaby@lemmy.ml 3 points 1 year ago* (last edited 1 year ago)

I hope that this link can help save your data. You might need an external HD to recover the data to as well as a live USB you can install testdisk to.

https://www.howtogeek.com/700310/how-to-recover-deleted-files-on-linux-with-testdisk/

Here is a video and there are plenty more on YouTube.

https://www.youtube.com/watch?v=3jbWfGePrqo&t=0

Maybe you can get an extetion from your professorto buy yourself a bit more time to recover your data? Best of luck.

[–] brunofin@lemm.ee 6 points 1 year ago

Thanks for all your comments, a lot of interesting things here.

I went with BtrFS with Timeshift. Seems to have improved in terms of performance a lot that I barely noticed any difference compared to the previous installation with Ext4, if any at all.

Unfortunately the current Ubuntu 23.10 installer doesn't properly set btrfs subvolumes correctly for @ and @home and instead instead just throws the entire OS at the root of the FS, making it incompatible with Timeshift and causing FS snapshots to live in the Linux directories, which in turn would cause future snapshots to contain snapshots, not great...

Fortunately migrating to a subvolume layout is possible although it was quite painful following this outdated and a bit not well written post https://www.reddit.com/r/btrfs/s/qWi84tGJam

After successfully installing the system and setting up btrfs layouts and Timeshift, I created the first system snapshot and I feel extremely confident about this solid system.

Thanks again for sharing your experience!

[–] beta_tester@lemmy.ml 6 points 1 year ago (1 children)

Besides btrfs, there are immutable distros like fedora silverblue. The system doesn't update when something goes wrong during the update and you can roll back if it updated.

It is a bit more difficult to handle and understand, imo, for a new linux user if the user wants to tinker with the system.

[–] Klaymore@sh.itjust.works 2 points 1 year ago (1 children)

I've been using NixOS and I've never had to worry about my system, because even if I did break it I can just wipe it and reinstall from my config files and it'll be almost exactly the same as before.

[–] iHUNTcriminals@lemm.ee 1 points 1 year ago* (last edited 1 year ago)

MX Linux is good for this too with their iso maker .

I started using MX and just use their image tool to make installable live USB. But tbh I have tried installing with it yet.

The only thing I've used for back up is clonezilla and have actually recovered with it... just a regular full disk image.

Such a cool distro surprised I just started using it. Fedora was my go to for years before.

I image the whole system to a recovery image using Veeam. Partitions and file systems make no difference.

[–] BeatTakeshi@lemmy.world 5 points 1 year ago

The new fad is immutable distros as I see more and more. Each major distro seems to have a flavor that is immutable. You are not specific about your needs/use case though

[–] Jamie@jamie.moe 5 points 1 year ago

I just have a different partition for /home. For snapshots, you could set a partition up as btrfs and use btrfs snapshots

[–] possiblylinux127@lemmy.zip 4 points 1 year ago

Wing everything without backups

[–] disheveledWallaby@lemmy.ml 3 points 1 year ago

Right now I'm using Garuda Linux, it takes a snapshot during major updates. Easily restored if something breaks.

Time shift saved my but a time or two in the past.

[–] Dran_Arcana@lemmy.world 3 points 1 year ago* (last edited 1 year ago)

My strategy has always been to separate what should be persistent from what shouldn't be.

On every system I deploy for home or work, I have a tree similar to below

/storage/[local/remote]/[where it is, enclosure, backplane,etc]/[what it is]

E.g

/storage/local/e1/raid/r6a/[this is my mount point] /storage/remote/nfs4/oldserver/[this is my mount point]

I then build all of my workflows off of the assumptions that things go there. Docker containers have a subdirectory in r6a for persistent volumes, etc

Even my containers themselves have a /storage/remote/persistent that I symlink anything to that I care about.

On the desktop side, I tend to physically just mount a second drive or a second partition as a subdirectory of /storage. That way my assumption can always be safe in that if it's a subdirectory of a mount, my data is safe. If it's not, it isn't. It's also nonstandard, so I can be relatively certain I won't have conflicts between different distributions.

The main issue I have with submounting system directories like /home is that applications tend to put junk there, and old junk might not be compatible with a newer version of, or different distro. It can make for more effort than it's worth

[–] wmassingham@lemmy.world 2 points 1 year ago

Partitioning doesn't affect backups. Any modern system supports both full images and file-level backups, so even if you take a whole disk image, you can just restore /home if that's what you want.

I would just use whatever filesystem is the default for your distro. For the root partition, usually that's ext4. That's a perfectly good default.

[–] Frederic@beehaw.org 2 points 1 year ago (1 children)

For years I used ext4 and backuped on an external HD/SSD using rsync.

For a couple of months now I redid a test setup with btrfs (and luks), I have a root, home, var, swap subvolumes. I'm using Timeshift for backup, I think I need to format a new external SSD as btrfs too to backup the snapshot.

[–] nickwitha_k@lemmy.sdf.org 1 points 1 year ago (1 children)

I'm getting a new, actually modern computer in 6 months or so and have been thinking BTRFS similar to your use. I'm mainly used to server hardware and my last system was SSD for root and HDD for everything else (a bit out of date for PCs).

I'm thinking of a similar setup, with 2x NVME drives as a BTRFS in RAID1 w/ subvolumes and external backups. How's your setup working for you?

[–] Frederic@beehaw.org 2 points 1 year ago (1 children)

I dual boot windows/Linux on the nvme, another SSD is NTFS because there's doc, pictures, mp3, etc that I can access from both OS. All NTFS are using bitlocker.

Btrfs works pretty well, it is mature, I'll test an external SSD using luks/btrfs to backup my system.

[–] nickwitha_k@lemmy.sdf.org 1 points 1 year ago

Very nice. The dual-boot is not something that I'll have to worry about. Fortunately, nothing that I worry about has dependency on Windows. Any gaming is on a steam deck or console, so, I'll be using it purely for nerdy fun.

[–] Frederic@beehaw.org 2 points 1 year ago

IIRC in MX Linux, you can create USB bootable snapshot of your system, so a full setup copy of your system, in case of hard crash.

[–] lvxferre@lemmy.ml 2 points 1 year ago* (last edited 1 year ago)

I only have three partitions, all ext4:

  • /dev/sda1 mounted as / - if necessary I wipe it out, reinstall my junk and call it a day. The only non-default things there are a few /etc files but I got a manual backup of the ones that matter. It's in the SSD to access is really fast.
  • /dev/sdb1 mounted as /home - that's my precious, for files that are personal and/or impossible to replace. Kept as small as possible so I can mirror it into a USB stick. It's in the HDD, right at the start so access is fast.
  • /dev/sdb2 mounted as /storage - originally I created this partition to bulk store my anime series, music, etc. so I could broadcast them through SMB across my house. If I lose those files I'll probably be pissed, but they can be recovered with some sweat, blood, and torrents. Access speed is not that big of a concern for those files.

I'm actually considering to create a fourth partition. See, the /storage partition has 1.6 TB, so I created a /storage/binarios subdir in it so I can install a few programs (mostly games)... that's just /opt reinvented poorly, might as well promote it to its own partition.

[–] TCB13@lemmy.world 1 points 1 year ago* (last edited 1 year ago)

BTRFS snapshots for sure. Avoid Ext4 at all costs, unreliable and very susceptible to power losses. But frankly I don't even care, all my data is synced with Syncthing so if things go wrong I'll simply install a clean OS and sync the data back.

[–] AnonStoleMyPants@sopuli.xyz 1 points 1 year ago

Never had a backup system, but then again I haven't used Linux that much. Though considering installing Debian again. Last time I looked at btrfs which seemed dope but there was something weird about it which made me ditch it. Maybe it was that I don't know that much about Linux and configuring automatic backups seemed difficult.

[–] Eufalconimorph@discuss.tchncs.de 1 points 1 year ago* (last edited 1 year ago)

I use NixOS & Home Manager. My config is in git, and I use an ephemeral setup with ZFS & tmpfs:

Mount layout:

/		 tmpfs  
├─/boot /dev/sda1  FAT32 EFI system partition
├─/nix	 rpool/local/nix ZFS partition
├─/home/persist rpool/safe/home ZFS partition
└─/persist	 rpool/safe/persist ZFS partition

ZFS partitions under rpool/safe/ get backed up, the rest don't need to be. Everything else can be rebuilt (and most of it gets re-created at boot anyway, since / and /home are tmpfs).

What I do nowadays is to have Timeshift daily backups in case something breaks the system and the Ubuntu backup application doing daily backups of my home to my NAS. I don't have a separate home partition although this is often recommended.

This setup saved me once, but I haven't needed it for almost 2 years now.

[–] yum13241@lemm.ee 1 points 1 year ago* (last edited 1 year ago)
500 MiB ESP mounted at /efi
Swap equal to my RAM at /home/swapfile
Root equal to 25% of my disk, formatted with btrfs with auto snapshots.
Home takes the rest of my disk, formatted with btrfs WITHOUT AUTO SNAPSHOTS, so swap works.
[–] oscardejarjayes@hexbear.net 1 points 1 year ago

I have my EFI boot partition with 512M on /boot, zram instead of swap, then a whole lot of btrfs subvolumes, with RAID across several disks. I do a lot of snapshotting, and auto-snapshotting, but thats mostly for local rollback. I only btrfs-send to a machine on the LAN. For my real backups I use Restic, sending that data to a number of places.

[–] dontblink@feddit.it 1 points 1 year ago

I simply backup the /home folder, where the important files are with duplicity on my home server with ftp once a week, keeping records of the last 6 months. But as that only restores the home folder i also take a snapshot (which takes way more disk space) every month with timeshift too, which stays on the pc. Would be great if i could take complete snapshots via ftp just like with duplicity, but timeshift doesn't do that.

[–] Pantherina@feddit.de 1 points 1 year ago

Use Virtmanager, its native on the Kernel (KVM) and doesnt need weird Kernel modifications.

So Ubuntu is really old regarding this. The solution you are looking for is BTRFS, standard on Fedora and Opensuse. It allows snapshots (that both systems automatically create afaik), and this is a specific capability of that filesystem, as these snapshots can be created while using it.

Its really powerful and somewhat magic, as you see no performance lack.

Isolating your home, maybe. Isolating /var could also be nice if you use Flatpaks.

Or just get an immutable System, if you need weird packages use Distrobox/Toolbox, if you want system mods try Ublue.it or layer/remove a few packages, and be happy with Flatpaks for the rest.

To answer your question, Opensuse and Fedora do the snapshots automatically. Just enable offline updates to use this feature more reliably (afaik).

I personally broke Linux Mint, Kubuntu, KDE Neon and Fedora KDE, so I switched to Kinoite.