Something killing locale-gen

Ran pacman -Syu on my PogoPlugv4 this afternoon and noticed that locale-gen was being killed for some reason.

[user@tengu ~]$ sudo pacman -Syu
:: Synchronizing package databases...
...
:: Starting full system upgrade...
...
( 2/36) upgrading glibc
Generating locales...
  en_US.UTF-8.../usr/bin/locale-gen: line 41: 17709 Killed localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias $locale
( 3/36) upgrading libseccomp
...

Ran it manually and saw the same behavior. I could see something was in a bad state as tmux would also refuse to reattach my session.

[user@tengu ~]$ sudo locale-gen
Generating locales...
  en_US.UTF-8.../usr/bin/locale-gen: line 41: 18396 Killed localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias $locale
[user@tengu ~]$ tmux a
tmux: invalid LC_ALL, LC_CTYPE or LANG

My hunch was locale-gen was hitting the memory limit for the PogoPlugv4, which doesn’t have much.

[user@tengu ~]$ free -m
              total        used        free      shared  buff/cache   available
Mem:            117          53           1           0          62          58

Nor was there any configured swap space.

[user@tengu ~]$ swapon --show
[user@tengu ~]$ echo $?
0

The memory we can’t do anything about, but we can use swap space to give us some wiggle room. However, we run into more issues.

[root@tengu ~]$ fallocate -l 512M /swap
fallocate: fallocate failed: Operation not supported
[user@tengu ~]$ mount | grep sda
/dev/sda1 on / type ext3 (rw,relatime,data=ordered)

I guess there’s an issue with fallocate on F2FS or XFS, per archlinux.org, but we’re running ext3.

The man pages for fallocate state “fallocate() is available on Linux since kernel 2.6.23. Support is provided by glibc since version 2.10.” My versions seem to be in line with that.

[user@tengu ~]$ uname -r
4.4.14-1-ARCH
[user@tengu ~]$ /lib/libc.so.6 | grep release
GNU C Library (GNU libc) stable release version 2.25, by Roland McGrath et al.

UPDATE: After some searching it turns out that fallocate does not support ext3, per this Bugzilla ticket. Guess this is what I get for using ext3.

Whatever, we can get around this by using dd.

[root@tengu ~]$ dd if=/dev/zero of=/swap bs=1024 count=524288
524288+0 records in
524288+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 23.8825 s, 22.5 MB/s
[root@tengu ~]$ chmod 600 /swap
[root@tengu ~]$ mkswap /swap
Setting up swapspace version 1, size = 512 MiB (536866816 bytes)
no label, UUID=a938d5b6-7113-4456-a633-7824b73d440d
[root@tengu ~]$ swapon /swap

We can confirm the system now has a swap space.

[root@tengu ~]$ swapon --show
NAME             TYPE SIZE  USED   PRIO
/swap            file 512M  14.5M  -1
[root@tengu ~]$ cat /proc/swaps
Filename         Type            Size    Used    Priority
/swap            file            524284  14816   -1

Now locale-gen should have enough room to do what it needs to do.

[root@tengu ~]$ locale-gen
Generating locales...
  en_US.UTF-8... done
Generation complete.

Done. Now pacman and tmux are happy.