【Google Compute Engine】【Ubuntu 22.04】開発環境インストール/microEmacs UTF-8のビルド

開発ツールのインストール

$ sudo apt install build-essential gcc g++ make libtool
$ sudo apt install ncurses-dev

ソース入手とコンパイル、インストール

$ git clone https://github.com/paaguti/mg3a.git
$ cd mg3a
$ autoreconf -i
$ ./configure
$ make
$ sudo make install

【Google Compute Engine】同じマシンインスタンス(e2-micro)でもOSにより使えるRAMサイズが異なる件

Ubuntu 20.04 -> RAM=1GB

$ free
              total        used        free      shared  buff/cache   available
Mem:         976928      194180      264992         948      517756      630508
Swap:             0           0           0

Rocky Linux 8 -> RAM=0.7GB

$ free
              total        used        free      shared  buff/cache   available
Mem:         773508      284048      167452        5212      322008      368184
Swap:             0           0           0

CentOS7 -> RAM=1GB

$ free
              total        used        free      shared  buff/cache   available
Mem:        1011100      182636      646636        6708      181828      685676
Swap:             0           0           0

Ubuntu 22.04 -> RAM=1GB

$ free
               total        used        free      shared  buff/cache   available
Mem:          972472      222320      313928         952      436224      597748
Swap:              0           0           0

CentOS8 Stream -> RAM=0.7GB

$ free
              total        used        free      shared  buff/cache   available
Mem:         785772      285224      175096        5288      325452      377388
Swap:             0           0           0

【Google Compute Engine】dnf使うと殺される件(Killed)

OS=Rocky8 Optimized for GCP

# dnf update
...
Killed

# dmesg
...
[  137.810169] Out of memory: Killed process 1638 (dnf)

e2-microだときびしい

対策1)メモリ増やす

Always Free なのでスペック変更できない。Oracle CloudはRAM1GBでも動いたのに。

対策2)SWAPエリアを作る。

# fallocate -l 1G /swapfile
# mkswap /swapfile
# chmod 0600 /swapfile
# swapon /swapfile

動いた。

# dnf update
...
Total download size: 245 M
Is this ok [y/N]:

リブート後もswapが有効になるには以下を設定

# vi /etc/fstab
/swapfile none                    swap    defaults        0 0

SWAPがあるか確認

# free
              total        used        free      shared  buff/cache   available
Mem:         773308      200076      202456        2764      370776      344372
Swap:       1048572      100360      948212