Emails: the way I like it

Posted: August 31st, 2012 | Author: | Filed under: fun, productivity | Tags: , , , , , | No Comments »

Sharing my setup of text-based mail client for “efficient” emailing.

It consists of following 3 pieces

fetchmail – fetches incoming messages from SMTP/POP server
procmail – filters messages
msmtp – sends messages
mutt – mail client to view messages

~/fetchmailrc :

set logfile /tmp/fetchmail.log
poll protocol IMAP timeout 60
user "username"
pass "********"
fetchall ssl nokeep norewrite sslcertck sslcertpath /etc/ssl/certs
mda "/usr/local/bin/procmail -f %F -d %T";

~/procmailrc :

#Set on when debugging

#The directory where your mail folders will be stored.

# The log of procmail actions

#filtering rules
# any email sent to [email protected] will be stored in ~/mail/.hiren/ dir.

# similarly, you can have multiple rule...

# Catch-all rule for all unmatched email

For some weird reason procmail wanted me to name the dirs under ~/mail/ starting with a dot i.e. “.”

You can have your mail stored in mbox or maildir format. I like mailbox format as its more flexible. I am not going into details about that.
Please ask “the Internet” for the difference and detailed understanding.

I am using msmtp for sending emails.


logfile ~/.msmtp.log

account yourmail
from [email protected]
#auth on
user [email protected]
password *********

account default : yourmail

mutt related settings:

mutt is a very very powerful and customizable tool. I am listing only a few very basic setup settings for muttrc below:

set mbox_type=Maildir
set spoolfile="~/mail/"
set folder="~/mail/"
set mask="!^\\.[^.]"
set postponed="+.Drafts"
set imap_user=username

# The capcability settings
set mailcap_path=~/.mutt/mailcap

# Settings
source ~/.mutt/settings

# Mailbox definitions
source ~/.mutt/mailboxes-local

~/.mutt/settings is another very important file for basic settings:

set hostname=""
set tmpdir="~/.tmp"
set sort=threads
set sort_aux=last-date-received # showing threads with youngest message last
set sort_browser="reverse-date" # showing mbox list default to newest first
set reverse_alias # If there is an alias ... show that.
set quote_regexp="^([ \t]*[|>:%}#])+" # This is default.
set editor = "vim -u ~/.mutt/vimrc"
set abort_nosubject=yes # cancel messages w/o subject: line
set envelope_from=yes
mime_lookup application/octet-stream
alternative_order text/plain text/enriched text/html

set sendmail="/usr/local/bin/msmtp"
set hidden_host # mutt will skip the host name part of $hostname
set bounce_delivered # Postfix users may wish to unset this variable.
set abort_nosubject=no # don't abort compos. when no subj. is set
set quit=yes # just quit please, kthx
set postpone=ask-no
set delete=yes # delete messages marked for deletion w/o confirmation
set mark_old=no # don't change status of new messages to old
set move=no # don't move read messages

# IMAP settings
unset imap_passive
set imap_keepalive=300

# folder format
set folder_format="%2C %t %N %d %f"

~/.mutt/mailbox-local lists your dirs/folders setup for message filtering:

set folder="~/mail/"
set record="~/mail/.hiren"
mailboxes \
= \
=.hiren \
=.kernel \
=.freebsd \
=.random # note: the last line does not end with backslash

Disclaimer: I’ve just shown basic settings here. Let me know if you are looking for any specific info.

memory disk: basic commands

Posted: August 26th, 2012 | Author: | Filed under: FreeBSD | Tags: , , , , | No Comments »

Create a 1G sized file

$ truncate +1G boot.disk

Create memory disk out of the file

$ mdconfig -f boot.disk

$ ls -l /dev/md0
crw-r----- 1 root operator 0, 132 Aug 23 14:57 /dev/md0

Create a partitioning scheme (i.e. gpt below)

$ sudo gpart create -s gpt md0
md0 created

$ sudo gpart show md0
=> 34 2097085 md0 GPT (1.0G)
34 2097085 - free - (1G)

Add a new partition

$ sudo gpart add -t freebsd-ufs md0
md0p1 added
$ sudo gpart show md0
=> 34 2097085 md0 GPT (1.0G)
34 2097085 1 freebsd-ufs (1G)

Create a ufs filesystem

$ sudo newfs /dev/md0p1
/dev/md0p1: 1024.0MB (2097080 sectors) block size 32768, fragment size 4096
using 4 cylinder groups of 256.00MB, 8192 blks, 32768 inodes.
super-block backups (for fsck_ffs -b #) at:
192, 524480, 1048768, 1573056

Mount the filesystem

$ sudo mount /dev/md0p1 /mnt/
$ df -k
/dev/md0p1 1015416 8 934176 0% /mnt

$ sudo mdconfig -l

undo the experiment

unmount /mnt
$ sudo umount /mnt/

detach the disk
$ sudo mdconfig -d -u 0

Freebsd on Freebsd using QEMU

Posted: August 7th, 2012 | Author: | Filed under: FreeBSD, virtualization | Tags: , , | Comments Off on Freebsd on Freebsd using QEMU

My system looks like this:

$ uname -a
FreeBSD 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64

1) Install qemu from /usr/ports/emulators/qemu

2) Load following 2 modules:

$ sudo kldload aio
$ sudo kldload kqemu

3) Get iso of the guest OS, in my case its FreeBSD so I got one from:

4) Create qemu image: (‘man 1 qemu-img’ for more information)

$ qemu-img create -f qcow2 ~/qemu/fbsd9_1beta.img 8G

$ ls -l ~/qemu/
total 652448
-rw-r--r-- 1 hpanchasara hpanchasara 667693056 Aug 7 12:43
-rw-r--r-- 1 hpanchasara hpanchasara 262144 Aug 7 12:44 fbsd9_1beta.img

Then I tried to launch it with: (‘man 1 qemu’ for more information)

$ qemu -boot d -hda ~/qemu/fbsd9_1beta.img -m 512M -cdrom ~/qemu/FreeBSD-9.1-BETA1-amd64-disc1.iso -localtime

But got following errors:

Listing a few to help the web-crawler which intern helps some lost soul like me:
“CPU doesn’t support long mode”
“Can’t work out which disk we are booting from…”
“panic: free: guard1 fail @ …”

Asking “the Internet” helped me narrow down the root causes to following:

1) 32 bit host cannot have 64 bit guest – which was not the case for me.
2) Machine should be virtualization capable – it is.
from /var/run/dmesg.boot, it should have VMX or SVM under “Features”.

FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012
[email protected]:/usr/obj/usr/src/sys/GENERIC amd64
CPU: Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz (3392.37-MHz K8-class CPU)
Origin = "GenuineIntel" Id = 0x206a7 Family = 6 Model = 2a Stepping = 7
AMD Features=0x28100800
AMD Features2=0x1
TSC: P-state invariant, performance statistics

3) Virtualization support should be enabled in bios – it was enabled.

$ sudo dmidecode | grep VME
VME (Virtual mode extension)

4) Use of incorrect qemu binary – that was the culprit.

“qemu” has different binary versions depending on the platform/systems:

$ qemu
qemu qemu-system-mips qemu-system-ppcemb
qemu-img qemu-system-mips64 qemu-system-sh4
qemu-system-arm qemu-system-mips64el qemu-system-sh4eb
qemu-system-cris qemu-system-mipsel qemu-system-sparc
qemu-system-m68k qemu-system-ppc qemu-system-sparc64
qemu-system-microblaze qemu-system-ppc64 qemu-system-x86_64

Using following I could successfully launch the guest FreeBSD instance:

$ qemu-system-x86_64 -boot d -hda ~/qemu/fbsd9_1beta.img -m 512 -cdrom ~/qemu/FreeBSD-9.1-BETA1-amd64-disc1.iso -localtime

On this first launch, it does FreeBSD install from the specified iso to the .img file. This is a typical FreeBSD installation process.

One the installation is done, you I could launch the VM via:

$ qemu-system-x86_64 -boot c -hda ~/qemu/fbsd9_1beta.img