作成:2021年02月23日
ホストOS:Debian GNU/Linux 10.7
ゲストOS:FreeBSD 12.2-RELEASE r366954 GENERIC amd64
FreeBSDでは、デフォルトで/usr/libexec/getty Pc ttyv0から/usr/libexec/getty Pc ttyv7まで起動してる。
結構メモリーを消費する。必要ないなら2個ぐらいにして、その他は削除した方がいい。
/etc/ttysファイルを開き、以下をコメントする。
#ttyv2 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv3 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv4 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv5 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv6 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv7 "/usr/libexec/getty Pc" xterm onifexists secure
/etc/ttysファイルの内容は、以下となる
# vi /etc/ttys
#
# $FreeBSD: releng/12.2/sbin/init/ttys.amd64 338454 2018-09-04 15:48:13Z brd $
# @(#)ttys 5.1 (Berkeley) 4/17/89
#
# This file specifies various information about terminals on the system.
# It is used by several different programs. Common entries for the
# various columns include:
#
# name The name of the terminal device.
#
# getty The program to start running on the terminal. Typically a
# getty program, as the name implies. Other common entries
# include none, when no getty is needed, and xdm, to start the
# X Window System.
#
# type The initial terminal type for this port. For hardwired
# terminal lines, this will contain the type of terminal used.
# For virtual consoles, the correct type is typically xterm.
# Other common values include dialup for incoming modem ports, and
# unknown when the terminal type cannot be predetermined.
#
# status Must be on or off. If on, init will run the getty program on
# the specified port. If the word "secure" appears, this tty
# allows root login.
#
# name getty type status comments
#
# If console is marked "insecure", then init will ask for the root password
# when going to single-user mode.
console none unknown off secure
#
ttyv0 "/usr/libexec/getty Pc" xterm onifexists secure
# Virtual terminals
ttyv1 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv2 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv3 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv4 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv5 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv6 "/usr/libexec/getty Pc" xterm onifexists secure
#ttyv7 "/usr/libexec/getty Pc" xterm onifexists secure
ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure
# Serial terminals
# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
ttyu0 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu1 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu2 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu3 "/usr/libexec/getty 3wire" vt100 onifconsole secure
# Dumb console
dcons "/usr/libexec/getty std.9600" vt100 off secure
再起動する。 # reboot
再起動後にメモリ使用量を確認した。
再起動前
# top -n
last pid: 75600; load averages: 0.66, 0.52, 0.50 up 21+19:55:41 13:23:32
36 processes: 3 running, 33 sleeping
CPU: 1.5% user, 0.0% nice, 1.8% system, 0.4% interrupt, 96.3% idle
Mem: 168M Active, 1769M Inact, 334M Laundry, 549M Wired, 290M Buf, 70M Free
Swap: 4096M Total, 34M Used, 4062M Free
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
801 iplog 522 20 0 895M 270M select 300:07 0.00% iplog
795 mysql 9 20 0 530M 120M select 111:00 0.00% mariadbd
533 bind 5 52 0 104M 61M sigwai 92:22 0.00% named
377 root 1 20 0 10M 588K select 11:53 0.00% devd
621 ntpd 1 20 0 15M 2832K RUN 8:49 0.00% ntpd
520 root 1 20 0 11M 1580K select 7:57 0.00% syslogd
842 root 1 20 0 17M 3816K select 1:59 0.00% sendmail
68919 root 1 20 0 67M 39M select 0:41 0.00% httpd
849 root 1 20 0 11M 1640K nanslp 0:34 0.00% cron
68923 www 5 20 0 80M 55M lockf 0:19 0.00% httpd
68920 www 5 20 0 79M 51M lockf 0:18 0.00% httpd
68924 www 5 20 0 79M 53M lockf 0:17 0.00% httpd
68922 www 5 23 0 80M 54M lockf 0:16 0.00% httpd
69146 www 5 20 0 80M 55M lockf 0:15 0.00% httpd
70195 www 5 20 0 79M 54M lockf 0:14 0.00% httpd
69159 www 5 20 0 77M 52M kqread 0:12 0.00% httpd
74091 www 5 20 0 78M 53M lockf 0:05 0.00% httpd
72684 www 5 20 0 80M 55M lockf 0:04 0.00% httpd
仮想端末をコメントし、再起動後
# top -n
last pid: 920; load averages: 0.98, 0.76, 0.35 up 0+00:03:01 13:39:33
29 processes: 2 running, 27 sleeping
CPU: 8.3% user, 0.0% nice, 7.8% system, 1.2% interrupt, 82.6% idle
Mem: 210M Active, 3656K Inact, 181M Wired, 132M Buf, 2491M Free
Swap: 4096M Total, 4096M Free
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
802 iplog 4 52 0 16M 4556K select 0:08 5.96% iplog
533 bind 5 52 0 78M 63M sigwai 0:09 1.95% named
796 mysql 9 52 0 510M 104M select 0:02 0.00% mariadbd
901 www 5 33 0 84M 63M lockf 0:01 0.00% httpd
831 root 1 20 0 67M 43M select 0:00 0.00% httpd
904 www 5 20 0 68M 46M lockf 0:00 0.00% httpd
622 ntpd 1 20 0 16M 5608K select 0:00 0.00% ntpd
520 root 1 20 0 11M 2656K select 0:00 0.00% syslogd
377 root 1 20 0 10M 1464K select 0:00 0.00% devd
902 www 5 20 0 68M 43M lockf 0:00 0.00% httpd
910 root 1 22 0 20M 9364K select 0:00 0.00% sshd
913 yumi 1 20 0 20M 9392K RUN 0:00 0.00% sshd
917 yumi 1 20 0 12M 3236K wait 0:00 0.00% su
650 mysql 1 52 0 12M 2724K wait 0:00 0.00% sh
900 www 5 20 0 68M 43M lockf 0:00 0.00% httpd
903 www 5 20 0 68M 43M lockf 0:00 0.00% httpd
914 yumi 1 23 0 13M 4508K wait 0:00 0.00% bash
843 root 1 20 0 17M 6972K select 0:00 0.00% sendmail
再起動前
# vmstat
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr vt0 cd0 in sy cs us sy id
1 0 0 2.5G 70M 17 0 0 0 23 67 0 0 8 756 135 2 2 96
仮想端末をコメントし、再起動後
# vmstat
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr vt0 cd0 in sy cs us sy id
1 0 0 1.2G 2.4G 684 0 7 0 596 69 0 0 45 3744 613 7 8 85
再起動前
# sysctl -a | grep Memory
Virtual Memory: (Total: 2763824K Active: 2667672K)
Real Memory: (Total: 712908K Active: 689552K)
Shared Virtual Memory: (Total: 88576K Active: 56192K)
Shared Real Memory: (Total: 62468K Active: 39560K)
Free Memory: 70772K
仮想端末をコメントし、再起動後
# sysctl -a | grep Memory
Virtual Memory: (Total: 1251700K Active: 1232792K)
Real Memory: (Total: 267884K Active: 266144K)
Shared Virtual Memory: (Total: 88328K Active: 77568K)
Shared Real Memory: (Total: 56604K Active: 55044K)
Free Memory: 2548900K
再起動前
# sysctl hw.physmem
hw.physmem: 3106357248
仮想端末をコメントし、再起動後
# sysctl hw.physmem
hw.physmem: 3106357248
再起動前
# swapinfo
Device 1K-blocks Used Avail Capacity
/dev/vtbd0s1b 4194272 35064 4159208 1%
仮想端末をコメントし、再起動後
# swapinfo
Device 1K-blocks Used Avail Capacity
/dev/vtbd0s1b 4194272 0 4194272 0%
再起動前
# vmstat -h
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr vt0 cd0 in sy cs us sy id
1 0 0 2.5G 70M 17 0 0 0 23 67 0 0 8 756 135 2 2 96
仮想端末をコメントし、再起動後
# vmstat -h
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr vt0 cd0 in sy cs us sy id
2 0 0 1.2G 2.4G 474 0 5 0 413 72 0 0 34 3022 519 6 6 88