2017年3月

创建要作为swap分区的文件

增加1GB大小的交换分区,则命令写法如下,其中的count等于想要的块的数量(bs*count=文件大小)。

dd if=/dev/zero of=/root/swapfile bs=1M count=1024

格式化为交换分区文件

mkswap /root/swapfile #建立swap的文件系统

启用交换分区文件

swapon /root/swapfile #启用swap文件

使系统开机时自启用

在文件/etc/fstab中添加一行:

/root/swapfile swap swap defaults 0 0

Preparation

Install build environment:

apt-get install build-essential libtool automake libncurses5-dev bison flex

Download kernel source code:

wget -O- https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.1.tar.xz | tar -xJ
cd linux-4.10.1

Build

default config:

make defconfig ARCH=um

change the config as you like:

make menuconfig ARCH=um
UML-specific options → Force a static link
Device Drivers → Network device support → Universal TUN/TAP device driver support
Networking support → Networking options → TCP: advanced congestion control → BBR TCP
Networking support → Networking options → TCP: advanced congestion control → Default TCP congestion control → BBR
Networking support → Networking options → Qos and/or fair queueing → Quick Fair Queueing scheduler (QFQ)
Networking support → Networking options → Qos and/or fair queueing → Controlled Delay AQM (CODEL)
Networking support → Networking options → Qos and/or fair queueing → Fair Queue Controlled Delay AQM (FQ_CODEL)
Networking support → Networking options → Qos and/or fair queueing → Fair Queue

build:

make vmlinux ARCH=um
strip -s vmlinux