Guide to Setup an OpenChannel SSD using QEMU
Table Of Contents
- Download Linux Kernel and Compile it
- Install and Setup QEMU
- Compile and Install NVMe CLI, liblightnvm and pblk-tools
This blog post describes the steps that I took to set up an environment with OpenChannel SSD using QEMU.
Download Linux Kernel and Compile it
The first step is to download the Linux kernel source from OpenChannelSSD’s GitHub repository. At the time of writing, features like pblk were not available on mainline Linux kernel. Compiling your own kernel might not be necessary in the future.
- Change to the directory where you want to clone the git repository. In this example I will use
/home/arpith/part/linux
- Clone the kernel:
At the time of writing this, latest kernel was available in thefor-next
branch of https://github.com/OpenChannelSSD/linux
- Copy the kernel config file from your existing system to the kernel tree:
- Make sure that the .config file includes the following:
- Bring the config file up to date. Answer any questions that get prompted. Unless you know you are interested in a particular feature, accepting the default option by pressing Enter should be a safe choice:
- Clean the kernel source directory:
- Build the linux-image and linux-header .deb files using a thread per core + 1.
This creates .deb
files which is used to install the kernel in QEMU.
Install and Setup QEMU
In case you don’t have a physical OpenChannel SSD in hand, you may use Keith Busch’s QEMU branch to emulate the device via a backend file.
- Create an empty file to hold your NVMe device.
- Clone, compile and install QEMU
You might need to install the following depencencies.
sudo apt install libpixman-1-dev libaio-dev libspice-server-dev libspice-protocol-dev libattr1-dev libcap-dev
- Download Ubuntu and install it in QEMU. Start by creating a disk image and booting Ubuntu from an ISO.
For more information on what the parameters do, visit smdaudhilbe.wordpress.com
-
Follow the on-screen instructions to install Ubuntu
-
After installation, start the VM with the following parameters. You may notice that I am using spice.
- You may have noticed that I am trying to share host’s
/home/arpith/part
to the guest.
Once the VM boots up, mount that folder in the guest. To do so, run the following command in the guest.
- Remember the Kernel we compiled earlier? Install it.
Alternatively, you may use -kernel
option to load the kernel as described here, but I had some issues with networking and mouse pointer (which disappeared!). Hence the need for this workaround. (The issue is that the kernel does not load modules correctly when using the -kernel
option. Not sure what is the cause of this issue. Maybe I’ll look into this later when I have time. A quick solution is to change certain parameters in .config
from =m
to =y
. The driver is now built into the kernel.)
- Reboot the virtual machine. Ensure that it is running the kernel that you compiled with
uname -a
.
Compile and Install NVMe CLI, liblightnvm and pblk-tools
- Install Nvme CLI
- Install liblightnvm
- Install pblk-tools
- If everything went according to plan, run the following command and check if a virtual disk is detected.
References
- http://lightnvm.io/
- https://wiki.archlinux.org/index.php/QEMU#qxl
- https://smdaudhilbe.wordpress.com/2013/04/11/how-to-install-ubuntu-inside-qemu-emulator-and-make-a-virtual-machine/
- https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel
- https://wiki.ubuntu.com/KernelTeam/GitKernelBuild
- https://superuser.com/questions/628169/how-to-share-a-directory-with-the-host-without-networking-in-qemu