Thursday, August 11, 2016

After having a bit of trouble installing my own certificate on Ubiquiti's Unifi software on Linux, I though I would let you know the process I went through.

First up, in my case I had my CA Certificate + User Certificate + User Key in .p12 format.

If you have already installed the Unifi software then please, please, please make a config backup.

Install the Unifi software on your server and make sure you can get to the Management page where it will be using an untrusted certificate from ubnt.com



Download Keystore Explorer for your OS from http://www.keystore-explorer.org/ which is a GUI for some java command line tools to deal with keystores.

Create a new keystore of type JKS

Import key pair, and select your .p12 certificate.



give it password 'aircontrolenterprise' (This is the ubiquity set password on the existing keystore that we are going to replace)

When requested to give it an alias, give it an alias 'unifi'



Save it.

SSH back to the server running your Unifi.

Stop the unifi service by running the command 'sudo service unifi stop'

move the existing keystore that we are going to replace by running 'sudo mv /var/lib/unifi/keystore /var/lib/unifi/keystore.original'

Use FTP or another method to copy the keystore you created with Keystore Explorer into the same location /var/lib/unifi/keystore

restart the service by running 'sudo service unifi start'

Back on your client machine, browse to the Unifi Management to test.
You should now have your own trusted certificate and can start restoring your saved config or starting with your fresh Unifi install.


Tuesday, February 23, 2016

Resize Linux Partition

I had the case of wanting to resize a linux partition for my Raspberry pi without access to the usual raspi-config tool so had to do it manually.
The raspi-config tool doesn't require a reboot, so there are probably other ways to achieve it as well, but this way works for me.

First I had a full disk. Which you can see by running the df command with -h for human readable output.


I want to expand the space for the / mount point that is at 100%
You can see that there is a partition at /dev/mmcblk0p1 , the p1 refers to partition 1 so that is device /dev/mmcblk0 but what partition is the / mount point?

You can check the partitions on the device with the fdisk -l command which lists them. 

So you can see that we want to expand the partition /dev/mmblk0p2 on device /dev/mmblk0

You also use fdisk on the device to delete and recreate the partition, then write the results back. This is done on partition 2 even though partition 2 is the linux partition on the running system.


It says the partition was altered, but the device is busy. It also says the device is busy for the next commands so the next step was to reboot.

After the reboot, run resize2fs on the partition that changed size.


If it ran successfully, you can df -h again to see the new space that is now available.
  

The space is now available for you to use.