编译工具 ========== 编译 qemu-nvme ------------------ .. highlight:: bash :: cd qemu-nvme ./configure --target-list=x86_64-softmmu --prefix=$HOME/Code/ocssd/out --python=/usr/bin/python3 --disable-werror make -j $(nproc) make install 编译后,需要把 qemu 配置到 PATH 里,在 :file:`.bashrc` 或者 :file:`.zshrc` 中追加: .. highlight:: bash :: export PATH=$HOME/Code/ocssd/out/qemu-nvme/bin:$PATH 之后,重启当前命令窗口 配置 Linux 内核 ------------------ 首先,让内核进行默认配置 .. highlight:: bash :: cd linux make defconfig .. image:: /_static/2-compile/defconfig.png :align: center :alt: defconfig 运行结果 接着,使用 menuconfig 菜单,对内核进行附加配置,我们需要启用几个内核编译选项: .. highlight:: bash :: make menuconfig .. image:: /_static/2-compile/menuconfig.png :align: center :alt: menuconfig 运行结果 首先,为内核勾选调试符号支持,在路径 Kernel hacking —— Compile-time checks and compiler options —— Compile the kernel with debug info。 .. image:: /_static/2-compile/menuconfig-debuginfo.png :align: center :alt: debuginfo 配置 按两次 esc 跳出到上层菜单,回车选择下层菜单。 使用空格键选择和切换,星号表示编译为内核内建模块,M表示编译为内核可加载模块,之后的都 选星号即可。 接着,为内核勾选 NVMe 支持,在路径 Device Drivers —— NVME Support —— NVM Express block device .. image:: /_static/2-compile/menuconfig-nvme.png :align: center :alt: NVME 配置 接着,为内核勾选 OCSSD 支持,在路径 Device Drivers —— Open-Channel SSD target support,选中后,按回车到子菜单中勾选全部选项。 .. image:: /_static/2-compile/menuconfig-ocssd1.png :align: center :alt: OCSSD 配置 .. image:: /_static/2-compile/menuconfig-ocssd2.png :align: center :alt: OCSSD 配置 至此配置完成,保存后退出 menuconfig 即可。 编译 Linux 内核 --------------- .. highlight:: bash :: cd linux make bzImage -j $(nproc)