Auto partitioning multiple drives on an LVM using Ubuntu Preseed

My goal: format and partition two separate drives using LVM during an automated Ubuntu install.

The Debian preseed file isn’t, at first glance, as flexible as kickstart files but as with almost everything, once you dig a bit deeper you find out that they just do things differently. I couldn’t find a good reference on formatting multiple drives and I did find a few people saying it wasn’t possible so that was discouraging. In the end, it’s actually quite straightforward.

Generally you need to:

  1. Define your physical volumes and create volume groups
  2. Define your volumes and place them into volume groups
  3. Define sizing parameters to make sensible partition sizes for your expected usage

The working partman configuration is shown below, including some helpful comments. Probably the most confusing thing is what the three numbers do in the logical volume definition. In short, they are minimum size, priority and maximum size. A calculation is performed that assigns space based on an algorithm. I found Tim Bishop’s partman-auto/expert-recipe explanation to be the best explanation out there. Be warned – there is a lot of misinformation floating around about these values.

Here’s the working configuration:

d-i partman-auto/method string lvm

# These options remove any existing LVM and deploy a new system
# Without all of these set like this you can end up with errors
# when you try to reinstall a machine with existing volume groups
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

d-i partman-auto/expert_recipe string                         \
      pvs ::                                                  \
              20480 750000 750000 ext4                        \
                      $primary{ }                             \
                      method{ lvm }                           \
                      device{ /dev/sda }                      \
                      vg_name{ system }                       \
              .                                               \
              1000000 1000000000 1000000000 ext4              \
                      $primary{ }                             \
                      method{ lvm }                           \
                      device{ /dev/sdb }                      \
                      vg_name{ data }                         \
              .                                               \
      system ::                                               \
              20480 20498 5000000 ext4                        \
                      $lvmok{ }                               \
                      lv_name{ root }                         \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ / }                         \
                      in_vg{ system }                         \
              .                                               \
              2048 2050 8192 linux-swap                       \
                      $lvmok{ }                               \
                      lv_name{ swap }                         \
                      method{ swap } format{ }                \
                      in_vg{ system }                         \
              .                                               \
      data ::                                                 \
              1000000 1000009 -1  ext4                        \
                      $lvmok{ }                               \
                      lv_name{ var }                          \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /data }                     \
                      in_vg{ data }                           \
              .                                               \
              100000 100001 500000 ext4                       \
                      $lvmok{ }                               \
                      lv_name{ datasnapshots }                \
                      \$defaultignore                         \
                      in_vg{ data }                           \

The expected behaviour from my configuration is:

# '/' = Min size 20GB, max 5,000GB, percentage(18/20) 90%
# 1TB drive = everything apart from swap
20480 20498 5000000 ext4

# 'swap' = Min size 2GB, max 8GB, percentage(2/20) 10%
# 1TB drive = 8GB
2048 2050 8192 linux-swap

# '/data' - Min size 1TB, max unlimited, percentage(9/10) 90%
# 5TB drive = 4.5TB
1000000 1000009 -1 ext4

# '/data snapshots' - Min size 100GB, max 500GB, percentage(1/10) 10%
# 2TB drive = 500GB
100000 100001 500000 ext4


Adding all ssh keys automatically to MacOS High Sierra

Since upgrading to High Sierra, I’ve had to manually add keys after every reboot using ssh-add like this:

ssh-add -K

I don’t reboot often but for a while I was rebooting often enough to make it annoying. So I found that you can link ssh with MacOS keychain using your .ssh/config file, add all the keys to your agent, and everything works smoothly.

Host *
UseKeychain yes
AddKeysToAgent yes

Then add all your keys to the keychain using

ssh-add -KA

Change default VPN host in Cisco AnyConnect Mobility Client for OSX

I was constantly annoyed at changing the hostname in my Cisco VPN client. I found a few resources on how to change the default host to connect to on Windows but OSX proved harder. So hopefully, this will help somebody else. It’s actually pretty simple when you know where to look:

vi ~/.anyconnect # Then edit the XML entry for DefaultHostName

If you are a consultant who works with multiple companies and VPNs then you’ll probably find this useful one day too.

2010 13″ MacBook Air cannot create bootable USB stick

After hours of banging my head against the wall trying to create bootable USB sticks on my laptop, I stumbled across this useful titbit of information:

Please notice: While all of the info and above commands are executed properly on a MacBook Air 3,2 (that is the 2010 version 13″ version of the Air) the end result will not produce a bootable USB device, at least not with the image for Ubuntu 10.10 64-bit. When booting of the USB device the following message or something similar will appear: “Missing operating system” and the process is auto-magically halted.

May be useful to somebody. They have a series of steps on the How to install Ubuntu on MacBook using USB Stick page to workaround this but it’s much easier to just find and use another Mac.

Sublime Text / Package Control: error executing: /usr/bin/security dump-trust-settings -d

I received this error when starting Sublime Text after upgrading to El Capitan. The author of package control is aware of the issue ( and is working on it but if it annoys you enough to do a workaround, here it is.  Remove all of the certificates from your Keychain that are shown when you run the same command: `/usr/bin/security dump-trust-settings -d`

My output looked something like this:

Number of trusted certs = 5
Cert 0:
Number of trust settings : 1
Trust Setting 0:
Policy OID : Apple X509 Basic
Result Type : kSecTrustSettingsResultTrustRoot
Cert 1: GTE CyberTrust Global Root
SecTrustSettingsCopyTrustSettings: The specified item could not be found in the keychain.
Cert 2: Class 3 Public Primary Certification Authority
SecTrustSettingsCopyTrustSettings: The specified item could not be found in the keychain.
  1. Open Keychain
  2. click on your login keychain
  3. Go to the search box
  4. Type in the name shown in the Cert <n>: field (in this case
  5. Select the Certificate entry that is shown in the results
  6. Right-click -> Delete “…”
  7. Enter your password (twice for me)

Continue until you run the dump-trust-settings command and get

SecTrustSettingsCopyCertificates: No Trust Settings were found.

Could a basic income for everyone work?

Occasionally an idea comes along that leaves me scratching my head because I simultaneously think that it will never work and that it’s so obviously the answer.  Finland’s basic income is one of those ideas.

Finland is considering a basic income for everyone. I invite you take a step out of your normal biases, whatever they may be, for just a moment and really think about the pros and cons.  Here are my non-exhaustive lists.


  1. Smaller government since administration is reduced and eligibility interviews, regular checkups and investigations are no longer needed
  2. Maternity and paternity leave become more about resourcing than a combination of resourcing and money
  3. Retraining for a new career becomes easier
  4. Starting a business is less risky so entrepreneurship should increase
  5. Taking a break when you’re burnt out is easier
  6. Very little opportunity for anybody to cheat the system
  7. If the basic income was large enough, social housing could be essentially eliminated
  8. You could get rid of minimum wage


  1. Potential for a large reduction in the available workforce since some people could self-select out
  2. Nationwide inflation could be an issue during the initial stages
  3. Slackers would slack
  4. Many poor people could come quickly into larger amounts of money than they are used to having and may not manage the transition well. I know I blow money when I get a windfall.
  5. Just having money doesn’t make you suddenly become less disadvantaged in any way other than financially. There will still be social issues to address.
  6. How much is enough?

Could it actually cost the taxpayer less money to do this than the current systems that are in place? Consider the NHS in England: Every once in a while an effort to clamp down on cheats (foreigners getting free healthcare mostly) rears its head and it always turns out that putting the tracking and payment-like systems in place to reduce those losses would cost more than just living with them so we don’t change the system and live with it.

A little more research shows that Canada did an experiment, called MINCOME, similar to this in the 70s and while working hours for the participants dropped slightly, one other noticed change was that “students in these families showed higher test scores and lower dropout rates.” Is the goal of society to push everyone into work or is it to try to move the society forward in general?

When my daughter Sarah was born, the UK government gave me and my wife a monthly child benefit payment. It wasn’t means tested and it wasn’t that much, I want to say around £80/month, but we got it and it was nice. We bought essentials like nappies and formula and although I didn’t need the money, it made me feel like a citizen. I felt like part of the country. That benefit is, of course, means tested now so we didn’t get it for Leo. I always wonder if the means-testing saved money overall after the tax codes, accounting and investigations that followed were added up?

I’m still unsure and will be watching with interest as these basic income experiments get underway.

Adding Groovy Support to Eclipse Mars 4.5

The short answer:

  1. Open Eclipse
  2. Select the menu: Help->Install new software…
  3. Click the Add… button
  4. Enter for the name and URL
  5. Select groovy packages and install

The longer answer is that that since Pivotal Software has dropped funding for Groovy there is a bit of a transition period and things aren’t as easy to find as they used to be. I also no longer find using STS as beneficial since a quick install to get running was the goal and if I have to install Groovy support separately moving forward with STS too then why not use the standard Eclipse app?

Finding adb on OSX with Android Studio

I had a software update on my phone and referred to my earlier post on a
Tethering Fix for Xperia Z2 on Lollipop 5.0 when I realised I didn’t have adb in my path anymore. For those who have moved up to Android Studio and not updated your path, you’ll need to add something like this to your .bashrc or .bash_profile


Tethering Fix for Xperia Z2 on Lollipop 5.0

After upgrading my phone to Android Lollipop, mobile tethering stopped working. I rang my operator and they said my account allowed it so it should work fine. They then ran me through a bunch of steps and it still didn’t work.

I found a long discussion on XDA developer that I was going to review eventually and then my colleague sent me through this fix to type into an adb shell:

settings put global tether_dun_required 0

And now it works. Hopefully it will help you too.

Thank you to silvrback and you can see his more in-depth explanation here:

Hide PostgreSQL user in OSX Yosemite

If you install Postgres from then you’ll have a PostgreSQL user created that shows up in your login screen. It’s not the end of the world but is mildly irritating so here’s how to hide the account from the GUI:

sudo dscl . create /Users/postgres IsHidden 1

Note that /Users/postgres is not the home folder of the user but simply the path /Users/ followed by the user’s shortname. I tried pointing the tool to the users home folder with no luck.

Thanks to Apple Support for this answer.