vrandom yet another random IT blog

Photon OS Custom Build


In this article we will demonstrate how you can build Photon OS, and perform some simple customizations.


Why do this? Well I had a particular environment within which I needed to deploy from OVF and configure using only VMware Guest Operations. The default configuration of Photon OS does not allow this, as the root account is not enabled until you’ve interactively configured it, and PAM was broken for vmtoolsd .


In preparation for this task I created a vanilla Ubuntu 16.04 VM to build the image and installed some prerequisites.

apt-get -y dist-upgrade
apt-get -y install bison gawk g++ createrepo python-aptdaemon genisoimage texinfo python-requests libfuse-dev libssl-dev uuid-dev libreadline-dev kpartx git bc
apt-get -y install screen #because I'm going to built it in a screen session

You will also need to download some prerequisites from VMware:

  • Virtual Disk Development Kit here - I used VMware-vix-disklib-6.0.2-3566099.x86_64.tar.gz
  • OVF Tool here - I used VMware-ovftool-4.1.0-2459827-lin.x86_64.bundle

Place these files in your home folder on the build device.

Create Build Environment

We are broadly following the instructions in the Photon OS wiki (which I contributed some changes too! :-) )

Install Docker:

wget -qO- https://get.docker.com/ | sh

Ensure ‘real’ bash is used:

ln -sf /bin/bash /bin/sh

Now we need to clone the Photon OS source:

cd ~
git clone https://github.com/vmware/photon

Now lets install OVFTool:

sh ~/VMware-ovftool-4.1.0-2459827-lin.x86_64.bundle --eulas-agreed --required

Now we’re going to setup the VMware VDDK and add it to the LD_LIBRARY_PATH for the current session.

tar -zxf VMware-vix-disklib-6.0.2-3566099.x86_64.tar.gz 
cp -r vmware-vix-disklib-distrib/include/* /usr/include/
mkdir /usr/lib/vmware
cp -a ~/vmware-vix-disklib-distrib/lib64/* /usr/lib/vmware/
rm /usr/lib/vmware/libstdc++.so.6* #because this conflicts with the system library
export LD_LIBRARY_PATH=/usr/lib/vmware #if you want to export the library only for this session
echo "/usr/lib/vmware" > /etc/ld.so.conf.d/vmware.conf && ldconfig #if you want the library settings to persist reboots
/root/photon/tools/bin/vixdiskutil #check this command shows some help, and doesn't report a library error

Lets build!

Now we are actually ready to build Photon OS. Before we do so, we can perform any customisations we want. For example I’m going to change the default root password and fix a problem with vmtoolsd PAM configuration by editing the file ~/photon/support/cloud-image-builder/ova/ova-custom-patch.sh

echo -e "putasecurepasswordhere\nputasecurepasswordhere" | passwd root
#chage -d 0 root

cat > /etc/pam.d/vmtoolsd <<EOL
auth       sufficient       pam_unix2.so
auth       sufficient       pam_unix.so shadow
auth       required         pam_unix_auth.so shadow
account    sufficient       pam_unix2.so
account    sufficient       pam_unix.so
account    required         pam_unix_acct.so

Now lets actually build the image!

$ screen
$ cd ~/photon
$ make cloud-image IMG_NAME=ova
$ ls -l ~/photon/stage/ova/photon-*
-rw-r--r-- 1 root root 206274560 Dec  1 09:14 /root/photon/stage/ova/photon-custom-1.0-19fc0f6.ova
-rw-r--r-- 1 root root 206274560 Dec  1 09:14 /root/photon/stage/ova/photon-custom-hw10-1.0-19fc0f6.ova
-rw-r--r-- 1 root root 206284800 Dec  1 09:13 /root/photon/stage/ova/photon-ova-1.0-19fc0f6.ova
-rw-r--r-- 1 root root 206284800 Dec  1 09:13 /root/photon/stage/ova/photon-ova-hw10-1.0-19fc0f6.ova


Hopefully this guide has helped other in creating a build environment and starting to explore further with Photon OS!