locale-gen fails on raspberry Pi

2013-12-12 · 142 words · 1 minute read

I’ve tried to generate the locales on my Raspberry Pi, but i ran into a problem that i was not able to solve for a few hours.

1root@rpi: ~$ locale-gen
2Generating locales...
3  en_US.UTF-8.../usr/bin/locale-gen: line 41:   303 Killed
4localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias
5$locale

locale gave me another error

 1root@rpi: ~$ locale
 2locale: Cannot set LC_CTYPE to default locale: No such file or directory
 3locale: Cannot set LC_ALL to default locale: No such file or directory
 4LANG=en_US.UTF-8
 5LC_CTYPE="en_US.UTF-8"
 6LC_NUMERIC="en_US.UTF-8"
 7LC_TIME="en_US.UTF-8"
 8LC_COLLATE="en_US.UTF-8"
 9LC_MONETARY="en_US.UTF-8"
10LC_MESSAGES=C
11LC_PAPER="en_US.UTF-8"
12LC_NAME="en_US.UTF-8"
13LC_ADDRESS="en_US.UTF-8"
14LC_TELEPHONE="en_US.UTF-8"
15LC_MEASUREMENT="en_US.UTF-8"
16LC_IDENTIFICATION="en_US.UTF-8"
17LC_ALL=

But finally i found the solution in an inconsiderable forum post. The reason for the locale-gen error is simply not enough RAM!

The solution is easy, just create a swapfile:

1fallocate -l 512M /swapfile
2chmod 600 /swapfile
3mkswap /swapfile
4swapon /swapfile

Then run locale-gen again and it works :-)