How to save $HOME when reinstalling OpenBSD

Everything has gone wrong and you have to reinstall from scratch. It shouldn’t happen but it may if you do something silly – I once acccidentally deleted /etc! But you have all sorts of stuff in $HOME that you don’t want to lose. Can you preserve it?

Well, of course, you should have a backup. I save one nightly on Tarsnap. But it may take a long time to restore from backup and it would be better if you didn’t have to.

Fortunately you can save your $HOME quite easily. Here’s how.

  1. When the Install process asks you to use disklabel, choose either OpenBSD or Whole Disk.

2. See which partition contains /home. Suppose it is ‘k’. Type ‘m -k’ (without the quotes). Choose ‘No mount point’.

Complete the Install process. When the system restarts,¬† edit /etc/fstab to mount the ‘k’ partition as /home.

It should work – it has worked for me. But if at all possible make a backup first, just in case it doesn’t.

 

 

Qsf – a small fast accurate spam filter

There are plenty of spam filters available for OpenBSD and other BSD systems such as bogofilter or spambayes, but these tend to be overkill for a single user system like mine. Another possibility is bmf, which is described as aiming to be faster, smaller and more versatile than similar Bayesian filters. However, it doesn’t seem to have been updated since 2002 and I didn’t like it too much when I tried it out..

I prefer Quick Spam Filter (QSF), which I have used for a good many years – in fact, since before I changed from Linux to OpenBSD four years ago. Its last update was in 2015. I find that after training it is reliable, with only occasional false positives or negatives. It hasn’t been ported to OpenBSD but it compiles easily. It is available from its author.

The qsf documentation describes how to integrate it with procmail. I have a separate post with details of doing this with fdm – see the OpenBSD category or use the Search facility.

How to replace procmail with fdm

 

 

 

Procmail is still widely used although it is no longer maintained. Its former maintainer, on OpenBSD, Philip Gunther, has said that it should be removed from the ports list because of security vulnerability, although it is still there. A suggested alternative is fdm, which both fetches the mail from a POP3 server and filters it, thus cutting out the need for fetchmail.

I’d been using procmail with fetchmail for a long time but I thought perhaps I should switch to fdm. The main difficulty was that the documentation I found was less complete than what is available for procmail. Getting my mail filtering program to work was a particular problem.

My fdm.conf

I thought it might be worth posting my fdm.conf here for anyone who is seeking to make the same switch.

I use qsf as my spam filter but it should be easy to adapt the script to work with a different filter. It writes “SPAM” in the subject line of suspect emails. I’ve posted more details about qsf in a separate entry (see under OpenBSD in the Categories¬† list or use the Search facility).


# fdm.conf -see the fdm manual for explanations of the code.

# Set the maximum size of mail.
set maximum-size 128M

# connection settings for my ISP’s mail server
account “<my POP3 account>” pop3 server “<my POP3 server>” user “<my email address>” pass “<my password>”

# filtering rules (adapted from my .procmailrc
match “^(To|Cc):.*lyx-users@lists.lyx.org” action mbox “%h/Mail/lyx-users”
match “^(To|cc|Cc|Sender): .*misc@openbsd.org” action mbox “%h/Mail/openbsd”
match “^Subject:.*Sucuri Alert” action mbox “%h/Mail/sucuri” action pipe “cat > /dev/null”

# forward some mail to a different account
match “^From:.*Facebook” action pipe “%h/.forward”

# Spam filter rules
action “spamfilter” rewrite “/home/ac/bin/qsf -s”
match all action “spamfilter” continue
match “^Subject:.*SPAM” action mbox “%h/Mail/spam”

# Set spoolfile for incoming mail
action “inbox” mbox “/var/mail/ac”
match all action “inbox”


My .forward file:

smtp user@example.com