Sunday, May 03, 2020

kernel in qemu

Wanted to start with kernel development and experiment with it. But i did not want to have to have to install  the kernel in my main machine. In this case the virtualization is the answer. I write the steps i did and the link(s) i used in order to get started.

To put everything together this is what i needed to do:
  1. install necessary packages
  2. download the kernel and build it
  3. create a root filesystem for qemu using buildroot
  4. run the kernel with the root filesystem with qemu

https://medium.com/@clem.boin/creating-a-minimal-kernel-development-setup-using-qemu-and-archlinux-987896954d84 has every detail to get started. There is no need to create a disk on anything and the debugging is a bonus. Although i dont know if the configure as it describes actually works, as i follow slightly different approach here.

Basic, i download the latest kernel (5.6.10) from https://www.kernel.org/ in a directory and then i did the normal make menuconfig, make and sudo make modules_install. If i wanted to install the kernel in my system and boot into it i will have to run also sudo make install and then configure the bootloader with sudo grub2-mkconfig -o /boot/grub2/grub.cfg.

Before go on, i want to share the parameters i used to build the kernel. I was actually trying to follow the http://linuxdocs.org/HOWTOs/Kernel-HOWTO.html#toc4 so the first thing i did was to disable the CONFIG_MODVERSIONS. That was for some convenience as i was just experiment. to find this when the menuconfig opens type / and copy paste the name that you are looking for. This will provide the path of where the config is located and exit. I had to repeat this for another error as the first attempt to build failed.

At the end build was ready and the modules were installed. now i had to build the filesystem. I cloned the buildroot, cd into it and i run make. This also takes some time and apparently you need Internet as it seems to download stuff (if you have perl installed and PERL_MM_OPT is set you will have to unset it).

finally i run the kernel in the qemu:

qemu-system-x86_64 -no-kvm -kernel arch/x86_64/boot/bzImage -boot c -m 2049M -hda ../buildroot/output/images/rootfs.ext2 -append "root=/dev/sda rw console=ttyS0,115200 acpi=off" -serial stdio -display none






























Sunday, April 26, 2020

configuring i3 with py3status

i used to run the vpn connection from the terminal. I could not find a way to make the i3 status show the correct status when the VPN was running. i use the py3status and taking a look in the documentation i though that it would be as simple as to edit the i3 configuration to point to a pid file that i would store the pid process when i run the openvpn. Something like

vpn_status {
  check_pid = True                 
  pidfile = "/var/run/openvpn-client/myvpn.pid"
}
and adding in the vpn config

writepid /var/run/openvpn-client/myvpn.pid

After some research and taking a look in the vpn_status module of the py3status, i decided to try my luck using the NetworkManager. This work quite well as the module checks for dbus messages of the NetworkManager. the modue does not need any additional in the py3status config.

To add the vpn connection from nmcli, the commands are:

sudo nmcli connection import type openvpn file /etc/openvpn/myvpn.ovpn 

Add the username to the vpn connection that it needs to connect

nmcli connection modify myvpn +vpn.data username=<username>

And finally run the onnection up using --ask to prompt for the password of that specific user

sudo nmcli --ask connection up myvpn
Now the i3 status shows the VPN is up and running displaying the name of the vpn. Giving the correct password you should see that the connection is activation (Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)

With ip route you can check that vpn has setup the routing. in my case i have a problem as it adds a default route to the vpn address which could not see outside. i had to delete this because i could not access the Internet

sudo ip r delete default via 10.100.200.1

if you want to close the connection

nmcli connection down myvpn

i dont know how i could do that without NetworkManager but i would be happy if someone has some hints.