Archive for the ‘linux’ Category
Gentoo Ought to be About Choice
“Gentoo is about choice.” We’ve said it so often that it seems like we just don’t bother to say it any more. However, with some of the recent conflicts on the lists (which I’ve contributed to) and indeed across the FOSS community at large, I think this is a message that is worth repeating… Read the rest of this entry »
Running cron jobs as units automatically
I just added sys-process/systemd-cron to the Gentoo repository. Until now I’ve been running it from my overlay and getting it into the tree was overdue. I’ve found it to be an incredibly useful tool.
All it does is install a set of unit files and a crontab generator. The unit files (best used by starting/enabling cron.target) will run jobs from /etc/cron.* at the appropriate times. The generator can parse /etc/crontab and create timer units for every line dynamically.
Note that the default Gentoo install runs the /etc/cron.* jobs from /etc/crontab, so if you aren’t careful you might end up running them twice. The simplest solutions this are to either remove those lines from /etc/crontab, or install systemd-cron using USE=etc-crontab-systemd which will have the generator ignore /etc/crontab and instead look for /etc/crontab-systemd where you can install jobs you’d like to run using systemd.
The generator works like you’d expect it to – if you edit the crontab file the units will automatically be created/destroyed dynamically.
One warning about timer units compared to cron jobs is that the jobs are run as services, which means that when the main process dies all its children will be killed. If you have anything in /etc/cron.* which forks you’ll need to have the main script wait at the end.
On the topic of race conditions, each cron.* directory and each /etc/crontab line will create a separate unit. Those units will all run in parallel (to the extent that one is still running when the next starts), but within a cron.* directory the scripts will run in series. That may be a bit different from some cron implementations which may limit the number of simultaneous jobs globally.
All the usual timer unit logic applies. stdout goes to the journal, systemctl list-timers shows what is scheduled, etc.
Quick systemd-nspawn guide
I switched to using systemd-nspawn in place of chroot and wanted to give a quick guide to using it. The short version is that I’d strongly recommend that anybody running systemd that uses chroot switch over – there really are no downsides as long as your kernel is properly configured.
Quick EC2 Backups with Duplicity
I’ve been doing online EC2 backups on my Gentoo box for a while, but switched to Duplicity a few months ago and have been very happy with the results. Setting this up took some trial and error, so I figured I’d share my config in case others find it useful. But first, here’s why I switched… Read the rest of this entry »
btrfs and snapper with portage on Gentoo
This is just a quick share-a-recipe post to introduce snapper to anybody who hasn’t heard of it, and explain how to use it.
Snapper is a utility that manages btrfs snapshots. One of the nice features of btrfs is that snapshots are cheap (virtually instant, and consume space only as changes accumulate), and easy to access. Snapper allows you to automatically create and manage them based on time, events, manual action, etc.
Once snapper is set up you can display a list of snapshots. I have 10 hourly snapshots, 10 daily snapshots, and snapshots from before/after each emerge. I can diff them, browse them, etc. Btrfs snapshots can be browsed right from the filesystem, so if I nuke /etc/passwd I can always do a cp /.snapshots/1875/snapshot/etc/passwd /etc/passwd to restore one from a few hours before (though I do also have /etc in a git repo).
Snapper is currently available in the sunrise overlay – I won’t spend time on how to set that up/etc. Also, I’ve had time-based snapshots running for a while now and my memory is hazy as to whether I had to do anything to get those working – it just requires sticking some scripts in /etc/cron.*/ and creating a config file containing your policies.
What I did want to post is a recipe for getting pre/post-emerge snapshots working. All you need to do is add some lines to /etc/portage/bashrc:
case "${EBUILD_PHASE}" in preinst) DESC="${CATEGORY}/${PF}" NUMBER=`snapper create -t pre -p -d "${DESC}"` ;; postinst) snapper create -t post --pre-number $NUMBER -d "${DESC}" ;; esac
One of these days I might clean this up a bit and move it to portage.
The Balance of Power in Gentoo
The recent concerns with the request to re-populate QA have re-opened a debate that is a few years old now. I’ve already made some specific recommendations on the lists, but I wanted to step back and explain why I feel the way I do.
Gentoo’s system of governance has some internal ironies – ones which occasionally even lead to calls to establish a benevolent dictator position. I think the mistake that Gentoo makes is that the problem is perceived as being democracy, when in reality the problem is with competing governance bodies with differing constituencies…
Gentoo EC2 Tutorial / Bootstrapping
I want to accomplish a few things with this post.
First, I’d like to give more attention to the work recently done by edowd on Bootstrapping Gentoo in EC2.
Second, I’d like to introduce a few enhancements I’ve made on these (some being merged upstream already).
Third, I’d like to turn this into a bit of a tutorial into getting started with EC2 as well since these scripts make it brain-dead simple.
A Quick Dracut Module
Since the general trend on many linux distros is towards requiring /usr to be mounted at boot time, I figured I’d see what it would take to get it working using dracut.
I’ve been messing with dracut for a while, and for some reason it stubbornly refuses to detect my raid devices. The kernel autodetection works fine, but this is disabled when booting from an initramfs. Dracut would timeout and drop me to a dash shell, and if I just typed mdadm -As followed by exit it would boot just fine.
Dracut is using udev to set up raid devices, and obviously that is not working.
Beyond this, I’d like to get my /usr mounted pre-boot, and there is a module called usrmount that purports to do just this. However, it isn’t working in my case because /usr is a bind mount to a subdir on an lvm volume, and it just isn’t figuring that out (it doesn’t even run lvm in the first place despite having the module installed, let alone figuring out what to mount in what order – I suspect the lvm module only works if root is on lvm).
My solution to both problems is to build my own simple dracut module. If you want to try it out:
- cd /usr/lib/dracut/modules.d/
- mkdir 91local
- cat > 91local/module-setup.sh
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=shcheck() {
return 0
}depends() {
return 0
}install() {
inst_hook pre-trigger 91 "$moddir/mount-local.sh"
}
- cat > 91local/mount-local.sh
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=shmount_local()
{
mdadm -As
lvm pvscan
lvm vgscan
lvm lvscan
lvm vgchange -ay
}mount_local
Then run dracut to build your initramfs, and it should let mdadm and lvm auto-detect everything before it gets to mounting stuff. You can then use the fstab-sys to mount whatever you need to mount user. However, in your fstab.sys if you’re configuring a bindmount be sure to prepend /sysroot/ before the source directory.
Example fstab.sys:
/dev/vg1/data /data ext4 noatime,user_xattr,barrier=1 0 0
/sysroot/data/usr /usr none bind 0 0
/sysroot/data/var /var none bind 0 0
Hopefully this helps somebody out – the dracut documentation is pretty sparse. In fact, if somebody connected to dracut stumbles upon this I’d be open to a better way of hooking my script – pre-trigger just doesn’t seem right – I’d rather let udev try to do everything first. However, I couldn’t find any way to hook after udev runs but before it bombs out not finding my root device. Suggestions welcome.
Another MythTV Update
Agreeing with some advice on gentoo-dev, I’m going to post this as a blog entry instead of a Gentoo news item. The quick version of this update is expect to see 0.24.1 in portage in a few days. The long version follows…
Read the rest of this entry »
KDump on Gentoo
I’ve been trying to learn a little more about kernel debugging (part of my quest to learn a little more about btrfs), and I figured I’d post a quick howto on getting kernel crash dumps captured on Gentoo.
Read the rest of this entry »