this post was submitted on 08 Dec 2023
38 points (100.0% liked)

Linux

48141 readers
502 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
 

Well I've joined the "accidentally trashing your system with rm -rf" club! Luckily I didn't delete my home directory with all the things I care about, but I did delete /boot and /usr, and maybe /var (long story, boils down to me trying to delete non-system directories named those but reflexively adding the slash in front when I should not have). I have backups of those as well, so what are my prospects of recovering from this by just copying them back in using a live USB? Only issue is they're stored in my server as belonging to the server user (I assume everything in those directories should belong to root and I can just use chown?) But I also don't know if they retain the same permissions when backed up.

Has anyone had any luck recovering a system in this way? I'm hoping not to have to reinstall everything because I had gotten pretty cozy with the current installation.

UPDATE: I finally had the time to sit down and try it, and, I was at least hoping to document some glitchy or unstable behaviour but it just didn't work at all. No matter what I tried I couldn't even get the UEFI to recognize the old system as bootable, so I cut my losses and just reinstalled. Gonna make sure I have btrfs snapshotting enabled this time, which I'm realizing I probably should have done in the first place.

you are viewing a single comment's thread
view the rest of the comments
[–] virr@lemmy.world 5 points 11 months ago

Depends on specific machine setup and how good the backup is.

Backup requirements for /usr there are sticky bits set on some binaries. That needs to be preserved. In all cases soft links likely need to be preserved for things to work correctly on future package installs. Hard links can be problematic, but if you have a large enough drive or not that many it wont matter. Running package verification can be help after restore to make sure everything looks right. If running a Linux system with SELinux in enforcing mode (RHEL on many derivatives), then the security context will also need to be preserved BUT running a relabel will probably work if the security context was not included in backups. Sometimes running the relabel process wont work if there are files that needs a specific security context but are not listed in the security context database. Can't provide more details because most of my experience with that is on systems we just replace (LSPP custom labeling resulted in systems that if you booted into permissive would then be unbootable, so they were just reinstalled once any debugging was done).

For /boot things can get tricky depending on the distribution, what boot manager is used, and /boot was a separate partition or not. Basically the boot manager (probably grub) needs to know how to find the files in boot so it can load the kernel. In most cases if you restore /boot and rerun the tools to update the boot manger everything will be fine. BUT some distributions, hardware setups, or dual boot configurations are more complicated, so extra work might be needed.

You didn't mention /dev, which is all special files. These don't need to be restored, just make sure the right processes recreate them. There are tools to do this, hopefully the packages are installed. Or boot from a rescue disk and fix it. Look up instruction for your specific distro.