I'm reinstalling Arch Linux and starting again from scratch. What things do you wish you would have done on your current install while it was clean? (i.e. Package auditing system/general hardening)
About this post
- Posted
- Archived
- Score
- 133 · 100% up
- Kind
- Text
- ID
- 4pybws
134 comments
My arch Linux systems are immutable, so I have to reinstall if I want to change anything. You want to think things trough in such a setup:-) Need new packages? Reinstall. Add user? Reinstall. Disable some service? Reinstall.
On the plus side: My machines are (almost) impossible to mess up now. They will e.g. boot after running a recursive rm on / as root. They will even notice during boot that the user data is gone and will try to restore that from backup.
I find the price I have to pay for that more than acceptable: The reinstallation is off course fully automated running on a server. The new image is pushed to the target machines and does not interfere with the currently running state (also fully automated). Then the new image is registered with the bootloader (automated). If there is some change I want I just reboot and I am done. If the upgrade is faulty (e.g kernel crashes during boot, some piece of software no longer works or I just misconfigured something) I just reboot into one of the known good states I still have on my drive.
Could you describe more how you're doing? It sounds really cool!
This needs a guide. I would tip.
M'immutability
Are you kidding me? That sounds ridiculously cool.
Nope. I "accidentally" ran "rm -rf / tmp/demo" (note the extra space) during a presentation at systemd conference last year. The reaction of audience was fun:-) I did finish my presentation on that machine.
It's up on YouTube but this reddit client won't let me paste the URL, sorry. You will have to search for "hunger systemd" if you care.
Al la NixOS
Just with well managed security updates :'(
Yes, nixOS goes in a very similar direction. I tested that, but could not make myself like it. I prefer having the different states in separate "directories" next to each other instead of everything mixed into one tree.
No, sorry, nixos is conceptually cool, but I find it's implementation impossible to use. Your mileage may vary.
What type of server?
I run this on my laptop, my desktop, two servers hosting containers and for all containers running on those. It is just my machines at home.
I do this with Ansible, makes life easy.
I do not want ansible, puppet and whatnot on my machines. It seems a waste if resources to run a service to make sure my systems are in a state I want them to be in. I prefer making sure the state is set up once and can not change.
I hate puppet changing state behind my back, maybe even causing intermittent failures (e.g because it is updating a package while something tries to run a binary from that package).
Why not just btrfs or something?
What would btrfs do out of curiosity?
I use btrfs to house the images. They go into read-only snapshots on a btrfs.
The trick it's filling the btrfs filesystem:+)
I would love to hear more about how you're doing this. I've always liked the setup they use on Chromebooks, where the file system is basically WX.
See above: https://www.youtube.com/watch?v=U6HD_rQQbIM
wow you basically built your own makeshift NixOS.
Yes, I did.
But mine avoids the symlink hell nixos needs, does not force me to provide lots of flags when building, works with arch packages (which tend to be newer than the packages in nixOS and cover more ground, too, so I usually do not even need to bother with build flags at all) and does not make me use a strange language which I can not wrap my head around:-)
It also puts each image into a nice directory one next to each other, so that I can manage my images with rm instead of having to use a set of nix commands that stuff everything into one tree.
You cold do this in a more practical way... Like using OverlayFS/AuFS on your root with an initramfs script and always discarding the top layer, and having to choose whether to boot like that or normally with an option on your bootloader. You could even make it so that you may choose to upload changes to your server so it gets stored on your image.
How is that mite practical than having /usr read-only and / on a tmpfs as I do now?
I want the history of all states I noted on my machine. Your approach sends to discard all the history of I understood it correctly.
If you think you might want to encrypt just do it now. Not that you can't do it later but when it has to go through and encrypt all your data it takes FOREVER. Where doing it upfront on an install takes seconds.
I recently went through this. It required changes to /etc/mkinitcpio.conf, /etc/crypttab, and /etc/fstab, rsyncing my old install into the luks container, and of course chrooting in and fighting with grub and uefi. If you are thinking encryption might ever be a possibility, just do it now and save yourself the trouble later. Use AES xts plain 64 with 512bit (effectively equals AES 256bit encryption due to how xts plain 64 works). This is especially the case if you have a processor with AES NI capability- you wont even be able to tell the difference in most usage.
I'll definitely do this, thanks for the advice.
How feasible is full disk encryption even if you don't have a processor with AES NI?
I'm thinking about fully encrypting, do you have any good guides or tips or anything?
Similarly, even if you are only going to have a fairly simple disk setup (like one disk with everything on one root partition except /boot and swap) you might want to investigate doing it on top of LVM now, so you can easily throw in an extra drive and add space to an existing logical volume instead of (1) having to copy everything off and re-add LVM later to get a larger root volume or (2) having to mount newly added storage somewhere in /mnt and having to manually balance which files go to which disk.
Depending on what you need encryption for it may make more sense to use build in encryption on most mid and high tier SSD drivers, encrypting Linux systems properly is a bit of a hassle in general and can affect performance quite a bit (I would not even think about encryption without AES-NI instruction set).
Or... if you have that capability why not use both? Hardware encryption when the UEFI/bios and SSD support it is a fantastic way to prevent evil maid attacks, encrypt windows (if you arent using truecrypt or bitlocker), and add a layer of trouble for someone trying to get your data. In the case of SED SSDs, there is NO performance penalty since everything is encrypted anyways- setting the hard drive password simply encrypts the encryption key with your password.
Further, Ive noticed no difference at all in terms of performance, but I do have AES-NI and am using AES encryption via luks. I think he should try it out for himself and see if he can live with it. Data theft is not only more prevalent than ever before, but the AMOUNT of data stored on our devices is greatly increasing over time. Any means of preventing others from getting access to that data is at least worth the testing, if not any performance concessions one might have to make to have to have encryption.
Just remember that encryption is only part of protecting data. It will stop someone who stole your drive, but three letter agencies or corporate spies can easily evil maid, usb keylog, camera record your passphrase for luks, etc. Then there is all the ransomware (mostly not affecting linux), security flaws in browsers and flash and whatever, etc. Hardening key packages, running some kind of MAC implementation (RBAC, AppArmor, SELinux [good luck on Arch...], etc), grsecurity patched kernel, PAX, firejail, etc can all make your install more resilient to giving up personal bits. And even all that isnt invincible...
I dont mean to ramble- but events that have happened in the world show that computer privacy and security needs to be taken seriously. You cant ever be 100% secure or 100% private (or even close), but its worth getting as close as possible..
Depends on your use case. My file server has a 6 disk btrfs volume on luks. The CPU does not have AES-NI. The main bottleneck is disk IO (I rarely see over 40% CPU utilization).
I imagine the situation would be quite different for an SSD.
full disk encryption
As long as you've got a spare hard drive to hold your stuff and time on your hands, of all the things listed here so far, this is the easiest to remediate.
I would probably entirely avoid GTK. Sick and tired of it constantly breaking on every update, and if you try to stay on an older version you eventually end up in dependency hell. Qt is the way to go apparently.
Obviously depends a lot on how you have your desktop set up or if you rely on some GTK-only software.
Probably also just generally better keep track of dependencies so that it just doesn't get so bloated.
Problem is, inevitably there is going to be 3 or 4 applications whose only suitable option is written in gtk... which means youre going to deal with the gtk theme breaking crap anyway. Im not disagreeing with you- Im on my third GTK2/3 theme now. Its worse for those of us who like dark themes. Adwaita and a few other light ones seem to stay on pace with GTK3 changes.
Breeze-dark has a git version that works with 3.20. And as far as I'm aware, they will push it with plasma 5.7, I think.
Awaita has a dark variation also.
Vertex generally stays up to date with GTK and looks nice
https://github.com/horst3180/vertex-theme
Yep, I generally avoid GTK like the plague but unfortunately some applications use only it :/
I wish I could avoid it with firefox.
Nothing that I could not do AFTER installation
Nothing. In my opinion Arch isn't a distribution you reinstall randomly. My install is 4 years old and still going.
You can cleanup easily if you think you messed up something.
Oh, I'm sure someone could clean up the mess I've made, just not me. Additionally, I've found that with each install my system becomes cleaner because of the experience I've gained since the last install.
This. Contrary to what some would have you believe, we're not born with best practices memorized. You may forget a dependency from 2 years ago that later plays havoc with newer software and sends you on several wild-goose-chases. Maybe something from the AUR did the nasty with a module that you forgot you needed. Sometimes, since the install process is so well-documented, the time invested in looking for a solution is more than just popping in the USB drive and paying a little more attention to that-one-thing-that-you-didn't-know-that-much-about-before-but-understand-better-now.
Cool. What are the main differences between your first installations and your newest one?
I'm on the other end of the spectrum. I probably reinstall my laptop every 3-4 months. I find that it had the side effect of making me keep solid backups. In fact, my machines really are just workstations, my data lives elsewhere.
LVM is something I do every time I (re)install. Hope that helps.
Serious question, what are the benefits of using LVM?
It's a great choice for managing virtual hard drive partitions. It has saved my butt quite a few times in the past.
From the docs:
Having etckeeper installed right from the beginning.
I read a bit on this tool, but never got to use it. Do I need to configure it somehow? If so, would you mind sharing your knowledge? Cheers!
It turns your /etc directory in a local repository of your favourite version control system (git, mercurial, bazaar, darcs), tracks via pacman hooks changes in /etc during updates and commits them to the repo. Manual changes you would commit by hand, having those changes committed with a nice changelog message.
A basic knowledge of version control would be quite helpful, but day-to-day commits are quite easy. You need to configure the version control system used, initialize the repo, configure some basics (e.g. I have pacman interupted, if there are uncommitted changes in /etc before updates, you could push your commits automatically to a remote repository, etc.). But after that, there's usually not much to do.
Of course, exploiting the full power you have with version control, especially doing rollbacks or investigating when a certain change happened, requires the necessary knowledge of the version control system chosen.
I've heard, though not confirmed for myself, that ext4 has serious code quality issues, compared to XFS, or at least that the dev process is inferior.
Source: some guy at L3GO who apparently encountered ext4 data corruption bugs that caused him to look at the code and pull his hair out.
Or since its Arch, BTRFS. BTRFS has gotten really stable with the later kernels, and having preupgrade snapshots is like cheating when Arch breaks on a system upgrade, especially when you have your bootloader setup to allow booting your "backup" snapshots.
How is BTRFS when dealing with limited hard drive space? I'm dual booting on a laptop with 512GB of storage so I only have 300ish GB available for Arch. How large are snapshots? Is there any way to read BTRFS partitions in Windows like you can with ext filesystems?
Had to do it this week, since I broke my system due to low disk space during and update. Took me a total of about 5 minutes to get back and running.
So... your answer is no?
I'm just implying that one might want to use xfs instead of ext4 if one wants that kind of plain old filesystem.
I'm noncommittal on any other aspect.
I'll look into this further, thank you!
ZFS
Any elaboration why do you prefer it over ext4 or btrfs?
Comparing ZFS and ext4 is comparing pears and apples (just look at the feature set). By now ZFS and Btrfs are mostly at feature parity if you ask me. I prefer ZFS because of interoperability with FreeBSD but in general it doesn't have the same first class support Btrfs has on linux, which is a bit sad.
Well, I'm using Arch for almost two years now and I did three installs on my main laptop - first was a mess, obviously, second was almost perfect and third happened because I fucked up, but had backups for config files, so not a big deal.
Aside from full disk encryption there is nothing you can't change, fix, adjust post install on Arch.
used F2FS or ZFS instead of btrfs.
How come? Btrfs is much more stable these days than it was in the past.
system slows down to a halt when dealing with thousands of small file changes. ie. using pacman -Syu
I wouldn't use btrfs on laptops. I've had issues with random hard locks, driver crashes, and some data corruption. This probably happens due to sata power savings. I ended up reinstalling my laptop with ext4.
Two BTRFS partitions already died in the last year after I updated the system and then shut it down :| (Proper shutdown, no pull-the-plug) Didn't happen yet with EXT4 for me
Keeping track of installed packages and noting why I installed them so that I can remove them once I figured out that I don't need the thing I installed them for anymore (especially if you just try out some stuff and then suddenly have packages you don't know, if you can remove them) I have currently 1600 packages and I'm sure there are at least 50 that I could easily remove but it just takes a lot of time to figure out which those are
pacgraph might help.
using wayland instead of X11
switching to wayland doesn't require a re-install, and you can't really install wayland without x, as the xwayland pieces are generally still dependenciesl it still installs x in order to allow non-wayland compatible apps to run.
Some things I did on my most recent install (still a work in progress as it isn't my main machine and Im often testing stuff in Windows on it).
/bootis a bind mount of/esp/EFI/ArchlinuxLVM. With or without encryption it's up to you but I really wish I had done that.
$HOME encryption. make sure it works before trying to encrypt your entire home dir.
also, I don't bother with full disk encryption, because I can't encrypt the kernel.
Check all of your hardware. I installed arch way too many times because for some reason my ssd wasn't detected as a bootable drive, and I had a uefi bios
Replace systemd with openrc ;)