Skip to content

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)

133 points134 comments
Open on Reddit
About this post
Posted
Archived
Score
133 · 100% up
Kind
Text
ID
4pybws

Author

3
posts
19
comments
0
media
View profile

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.

76 points

Are you kidding me? That sounds ridiculously cool.

10 points

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.

16 points

Al la NixOS

7 points

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.

2 points

What type of server?

6 points

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.

3 points

I do this with Ansible, makes life easy.

5 points

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).

6 points

wow you basically built your own makeshift NixOS.

3 points

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.

5 points

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.

2 points

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.

2 points

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.

64 points

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.

15 points

I'll definitely do this, thanks for the advice.

5 points

This is especially the case if you have a processor with AES NI capability

How feasible is full disk encryption even if you don't have a processor with AES NI?

3 points

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.

6 points

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).

-2 points

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..

3 points

can affect performance quite a bit (I would not even think about encryption without AES-NI instruction set).

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.

2 points

full disk encryption

23 points

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.

6 points

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.

19 points

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.

13 points

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.

5 points

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.

16 points

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.

45 points

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.

28 points

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.

2 points

LVM is something I do every time I (re)install. Hope that helps.

14 points

Serious question, what are the benefits of using LVM?

4 points

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:

LVM gives you more flexibility than just using normal hard drive partitions:

  • Use any number of disks as one big disk.
  • Have logical volumes (LVs) stretched over several disks.
  • Create small logical volumes and resize them "dynamically" as they get filled up.
  • Resize logical volumes regardless of their order on disk. It does not depend on the position of the LV within the Virtual Group (VG), there is no need to ensure surrounding available space.
  • Resize/create/delete logical and physical volumes online. File systems on them still need to be resized, but some (such as ext4) support online resizing.
  • Online/live migration of LV being used by services to different disks without having to restart services.
  • Snapshots allow you to backup a frozen copy of the file system, while keeping service downtime to a minimum.
  • Support for various device-mapper targets, including transparent filesystem encryption and caching of frequently used data.
6 points

Having etckeeper installed right from the beginning.

9 points

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!

1 points

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.

1 points

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.

7 points

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.

10 points

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?

3 points

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.

2 points
unknown author1 hidden

So... your answer is no?

3 points

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.

2 points

ZFS

6 points

Any elaboration why do you prefer it over ext4 or btrfs?

7 points

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.

6 points

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.

5 points

used F2FS or ZFS instead of btrfs.

2 points

How come? Btrfs is much more stable these days than it was in the past.

1 points

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.

1 points

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

1 points

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

2 points

using wayland instead of X11

2 points

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.

2 points

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).

  1. F2FS over ext4
  2. /boot is a bind mount of /esp/EFI/Archlinux
2 points

LVM. With or without encryption it's up to you but I really wish I had done that.

2 points

$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.

2 points

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

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.