In the upcoming blog posts, we will explore one of my favorites editors: VIM. I wanted to start from scratch, so any new user can learn how to quickly customize the editor.
In this post we explore an operating-system-level virtualization method for running multiple isolated Linux systems (containers) on a single control host (LXC host). This will allow me to start a clean and minimal operative system within my fully fledged environment so I can teach VIM from scratch.
This is just one application, you can leverage the power these contained environments for much more apart from testing new packages and having project contained configurations . We can see it as virtualization at bare-metal level. We can even emulate other architectures, as described in this post. So if we don’t want to carry around a raspberry pi for development, we can run it in a container environment in our host system.
Anyhow, lets get to it. First we create the directory where we want to store our container, in my case, the vim_container:
Installing a minimal Arch Linux system
I will start a minimal arch installation within that container:
sudo pacstrap -c ./clean_vim base --ignore linux
-c option stands for cached. This tells to used cached packages as I’m also running in arch, so it is faster and it does not need to download them. We install
base which includes the minimal system and ignore the linux package. As explained in the arch wiki, the linux package is not required to run a container, and could cause some issues during the booting process.
In order to be able to login we need to perform some modifications to the clean installed arch system. One option is mentioned in this github issue. We can simply delete
/etc/securetty from the container, which will allow root login on all ttys:
sudo rm ./clean_vim/etc/securetty
That should be it. Another option is mentioned in this video. We can simply comment the first line of
sudo vim ./clean_vim/etc/pam.d/login
#%PAM-1.0 #auth required pam_securetty.so auth requisite pam_nologin.so auth include system-local-login account include system-local-login session include system-local-login
We are ready to go.
Boot and login
For launching the container we will need
sudo pacman -S systemd
Now we can boot into our container:
sudo systemd-nspawn -b -D ./clean_vim
-b option stands for boot, and
-D specifies the directory.
We are done, after executing that command we would see the system booting up and we would enter the login screen.
To exit the container we can either log in and execute
poweroff or just press in less than a second
ctrl+] 3 times (it is mentioned in the beginning when we launch the container)
Fix container shell compatibility with host terminal
I use urxvt as my terminal. This ended up having a minor incompatibility with the guest shell. When I would press backspace, a white space character would appear. After some googling I found that the issue was that my terminal and the guest shell differed on emulation. To fix this, we just need to do:
We can include this line in the guests `root/.profile` so it happens automatically after login in.