1. 国内ubuntu源
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
sudo vim /etc/apt/sources.list
换成阿里源:
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
2. 静态IP
sudo vim /etc/network/interfaces
增加以下内容(网卡名“ens3”根据实际的名称替换):
iface ens3 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 114.114.114.114
然后重启网络服务:
systemctl restart networking.service
查看当前IP信息:
ifconfig
如果不生效则需重启虚拟机:
sudo reboot
3. 扩大交换分区
3.1 查看Swap空间大小:
free -h
3.2 在原有swap基础上增加8G空间
sudo mkdir /swap
cd /swap/
sudo dd if=/dev/zero of=swapfile bs=1G count=8
3.3 创建一个Swap文件
sudo mkswap /swap/swapfile
3.4 尝试激活Swap文件
sudo swapon /swap/swapfile
3.5 修改文件权限
sudo chmod 0600 /swap/swapfile
3.6 开机自动挂载
sudo vim /etc/fstab
增加:
/swap/swapfile swap swap defaults 0 0
脚本文件:
#!/bin/bash
echo "start to make swap file..."
mkdir /swap
cd /swap/
dd if=/dev/zero of=swapfile bs=1G count=8
mkswap /swap/swapfile
swapon /swap/swapfile
chmod 0600 /swap/swapfile
echo "/swap/swapfile swap swap defaults 0 0" >> /etc/fstab
echo "finish"
free -h