I have recently been setting up a website for a friend. As part of this process I needed to sort out my mail server so that he could have a pretty email address.

For a long time I’ve been able to receive/access email to accounts on that server, but I’ve never configured it to allow sending via those accounts.

Setting this up took a few evenings of internet research. I found many old posts, most of them relating to old versions of sendmail. These seemed to need additional configuration, often involving SASL and/or cyrus.

My server is running CentOS 6, so sendmail is at version 8.12. It was in such a state that I started by uninstalling email services (sendmail and postfix) and reinstalling just sendmail (also sendmail-cf). It seems that SASL2 is already installed. Cyrus is unused.

The interesting lines from are as follows:

define(`confAUTH_OPTIONS', `A p')dnl
define(`confCACERT_PATH', `/etc/pki/tls/certs')dnl
define(`confCACERT', `/etc/pki/tls/certs/ca-bundle.crt')dnl
define(`confSERVER_CERT', `/etc/pki/tls/certs/server-cert.pem')dnl
define(`confSERVER_KEY', `/etc/pki/tls/certs/server-key.pem')dnl
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl

Of note are the authentication mechanisms. The default install lists many and it wasn’t until I reduced the list to the two shown that I was able to log in to send email. I masquerade all of the domains that users need to send from.

Don’t forget to enable ports through the firewall too.

Ubuntu Annoyances

I’ve always been a RedHat man myself. Since around RedHat 3 I’ve run with that, and then Fedora, on my laptop and RedHat/CentOS on my servers.

At work Ubuntu is the choice and so that’s what I’m using there. I have recently found a few annoyances though, that I’ve not come across with RedHat/Fedora.

/boot fills up

It seems that with the default installation of both 12.04 LTS and 14.04 LTS versions the boot partition fills up over time (less than twelve months). The system installs updated versions of the kernel and related files. This continues until the partition is out of space.

I had to Google to find the fix, as root on the command line:

  • determine which kernel version is running with uname -r
  • delete the unused files from /boot
  • prevent this from happening in future with apt-get autoremove
  • you’ll probably need to run apt-get -f install to clean things up

I’ll be checking back on the servers to make sure that I really have fixed the problem.

Upgrade requires interaction

Yesterday/last night I decided to take the plunge and update my desktop machine from Ubuntu 12 to 14. I set it going and it warns that it can take hours. I expect that. When I checked back after a while there was a dialog asking if a file should be replace. Such prompts popped up a few times during the process. This sucks!

With Fedora you set the process running, come back in the morning and it’s done.

VM HD Resize

vm-setupI had a small virtual machine (Ubuntu 12, Virtual Box) being hosted on a headless server. It had an 8Gb drive which I needed to resize.It’s done now, but took more googling than it should have done. Here’s a summary.

  1. Stop the virtual machine
  2. Copy the .vmdk to the workstation
  3. Copy the .vmdk to a .vdi
  4. Resize the .vdi
  5. Attach the .vdi (in place of the .vmdk)
  6. Boot to gparted
  7. Create a swap partition
  8. Extend sda2 to fill the unallocated space
  9. Extend sda5 to fill the partition
  10. Reboot
  11. Extend the logical volume
  12. Resize the filing system
  13. Move the swap partition
  14. Shutdown the machine (test)
  15. Copy the .vdi back to the host server
  16. Detach the existing drive
  17. Attach the new drive
  18. Restart the virtual machine

Steps 1 to 4

As the host server is headless I wanted to do as much of the work as possible on my workstation. I originally created the vm on my machine and copied it over to the host, so only needed to copy the disk image back over. You might need to copy the whole machine (folder) over to your workstation. To stop the vm ssh on to it and sudo shutdown -h now.

Once the .vmdk is copied back to the workstation you can use the graphical VM VirtualBox Manager to copy the drive image to a .vdi. I then resized it on the command line with

VBoxManage modifyhd vm-disk1.vdi --resize 51200

Then using the manager app I detached the .vmdk and attached the .vdi drive. I also set the optical drive to my gparted iso.

Steps 5 to 9

Now start the vm. It should boot to gparted. I went to the command line and then ran startx. I found that trying to boot to X didn’t work. Start the gparted app. Start be deactivating the active drives. I then added an 8Gb swap partition (sda3) at the end of the space before resizing the extended partition (sda2). (A dedicated swap partition is not necessary. Ubuntu seems to use a file on the drive. I’m used to CentOS and I’ve always seen swap on it’s own partition. For a vm I can’t see that it makes any difference.)

I applied the changes after the extended partition had been extended. Then deactivate the drives again and extend the LVM partition (sda5) to fill the now available space. Apply changes. Then shutdown the machine and unmount the gparted iso.

Steps 10 to 15

Now reboot the vm and working it’s command line first extend the logical volume

lvextend -l +100%FREE vm-vg/root

then the filing system

resize2fs /dev/vm-vg/root

If you have taken the opportunity to move the swap partition then turn off swap and mark the new partition as swap

swapoff -a
mkswap /dev/sda3

At this point edit (sudo) /etc/fstab and tell it that swap is now /dev/sda3. Then turn swap back on with

swapon /dev/sda3

Now shutdown the machine. At this point you might want to ensure that it starts okay. I suffered kernel panics a few times; not sure why, perhaps swap was misconfigured). Once you’re happy copy the .vdi drive image back over to the host server.

Steps 16 to 18

Now ssh on to the host server and detach/attach drives. (Not sure about the portcount switch; this worked but gave a slightly different configuration from the original.)

VBoxManage storagectl vm --name vm-disk1.vdmk --detach
VBoxManage storagectl vm --name SATA --add sata --controller IntelAhci --portcount 30 --bootable on
VBoxManage storageattach vm --storagectl SATA --medium vg-disk1a.vdi --port 1 --nonrotational on --type hdd

Finally restart the vm

VBoxManage startvm vm --type headless

Job done.