TLDR; just follow this guide.

At home I run DHCP and DNS servers on Odroid U3, a system on a chip (SoC) computer. This allows me to have lots of control over my home network and most importantly – fun. I also run some web sites and Postgresql databases for testing purposes.

The SoC computer runs Ubuntu 16.04 as the operating system. Recently, the Odroid U3 died.

A coworker also has an SoC, an Odroid XU4. But, he found no use of it so I bought it off him at a very good price. This new SoC will replace the Odroid U3.

After flashing the Ubuntu 16.04 image on this new XU4, it didn’t seem to have correct locale set. I found this out when I could not start Postgresql server, and here is the log message:

2017-12-24 09:53:17 UTC FATAL: configuration file "/etc/postgresql/9.5/main/postgresql.conf" contains errors
2017-12-24 09:53:43 UTC LOG: invalid value for parameter "lc_messages": "en_US.UTF-8"
2017-12-24 09:53:43 UTC LOG: invalid value for parameter "lc_monetary": "en_US.UTF-8"
2017-12-24 09:53:43 UTC LOG: invalid value for parameter "lc_numeric": "en_US.UTF-8"
2017-12-24 09:53:43 UTC LOG: invalid value for parameter "lc_time": "en_US.UTF-8"
2017-12-24 09:53:43 UTC FATAL: configuration file "/etc/postgresql/9.5/main/postgresql.conf" contains errors

To check the locale setting, run:

# localectl
System Locale: n/a

VC Keymap: n/a
X11 Layout: us
X11 Model: pc105

To list available locale, run:

# localectl list-locales
C.UTF-8

From the above output, there is no other available locales available. I only need English language, especially the en_US.utf8, which is provided by language-pack-en-base package. Install it with the following command:

# apt-get install language-pack-en-base

Recheck the available locales:

# localectl list-locales
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8

Now I can set the system-wide local with the following command:

# localectl set-locale LANG=en_US.utf8
# localectl
System Locale: LANG=en_US.utf8
VC Keymap: n/a
X11 Layout: us
X11 Model: pc105

Once the locale was correctly set to en_US.utf8, I was able to to successfully start Postgresql server.

Here’s an extract from the Postgresql log:

...
2017-12-24 10:12:36 UTC LOG: database system was shut down at 2017-12-24 09:28:26 UTC
2017-12-24 10:12:36 UTC LOG: MultiXact member wraparound protections are now enabled
2017-12-24 10:12:36 UTC LOG: database system is ready to accept connections
2017-12-24 10:12:36 UTC LOG: autovacuum launcher started
2017-12-24 10:12:37 UTC LOG: incomplete startup packet
...

Ref: