Linux设置虚拟内存
dd if=/dev/zero of=/var/swapfile bs=1M count=128
mkswap /var/swapfile
swapon /var/swapfile
128代表设置128M大小的虚拟内存,根据情况自行修改
最后,修改/etc/fstab,添加一行(保证重启系统后,swap依然生效)
/var/swapfile none swap sw 0 0
dd if=/dev/zero of=/var/swapfile bs=1M count=128
mkswap /var/swapfile
swapon /var/swapfile
128代表设置128M大小的虚拟内存,根据情况自行修改
最后,修改/etc/fstab,添加一行(保证重启系统后,swap依然生效)
/var/swapfile none swap sw 0 0
前面有篇文章讲述如何搭建proxmox,这次主要讲述如何配置网络
开启IPv4,IPv6转发,编辑/etc/sysctl.conf,添加以下内容到尾部:
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=1
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.default.forwarding=1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv6.conf.enp3s0.autoconf=0
net.ipv6.conf.enp3s0.accept_ra=2
net.ipv6.conf.default.forwarding=1
net.ipv6.conf.all.forwarding=1
net.ipv6.conf.default.proxy_ndp=1
net.ipv6.conf.all.proxy_ndp=1
其中的enp3s0需要修改为自己的网卡名
最后,编辑/etc/network/interfaces,在下方添加内容如下:
auto vmbr0
#private sub network
iface vmbr0 inet static
address 10.10.10.1
netmask 255.255.255.0
bridge_ports none
bridge_stp off
bridge_fd 0
iface vmbr0 inet6 static
#母鸡的ipv6地址
address 2400:38e0:1:4191::1/64
post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o enp3s0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o enp3s0 -j MASQUERADE
post-up ip neigh add proxy 2400:38e0:1:4191::11 dev enp3s0
pre-downip neigh del proxy 2400:38e0:1:4191::11 dev enp3s0
这样配置好后,开小鸡时,选择桥接 vmbr0,IPv4 和 IPv6 都配置为静态,然后手动输入:
IPv4/CIDR:10.10.10.2/24
网关(IPV4):10.10.10.1
IPv6/CIDR:2400:38e0:1:4191::11/64
网关(IPV6):2400:38e0:1:4191::1
添加rc-local.service服务
以下为一整条命令,一起复制运行
cat > /etc/systemd/system/rc-local.service <<EOF
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
EOF
新建rc-local文件
以下为一整条命令,一起复制运行
cat > /etc/rc.local <<EOF
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
EOF
添加权限并设置开机自启
chmod +x /etc/rc.local
systemctl enable rc-local
systemctl start rc-local.service
检查状态
systemctl status rc-local.service
返回Active:active信息,则成功。
最后我们就可以在/etc/rc.loacl里,添加开机的自启命令什么的了。添加在exit 0之前。