Now Reading
Boot to Vim, Vim as Pid 1

Boot to Vim, Vim as Pid 1

2023-04-21 20:53:22


This can be a response on an excellent article from Pascal Bourguignon, specifically how
to run Emacsas PID 1.

As everyone knows, no person makes use of emacs.

The above assertion is ment to start out a flamewar. Please achieve this, see the contact
web page to contact me.

No, all joking apart, I discovered it to be an excellent article and needed to see how I
may try this with Vim. Not in Person Mode Linux, however by creating an precise ISO.
Boot to Vim, as you may wish to name it.

That is truly pretty easy. Compile vim statically, set it as init= at
boot and also you’re finished.

We’re going to use small (9MB) distro named Tiny Core, Core edition and
customise that in addition proper into our static construct of Vim.

Just lately I eliminated all Google Adverts from this web site because of their invasive monitoring, in addition to Google Analytics. Please, in the event you discovered this content material helpful, contemplate a small donation utilizing any of the choices under:

I’m developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you’ll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you’ll get $100 credit for 60 days.

Constructing Vim

Please learn and observe my tutorial on building a statically linked Vim.
This provides you with an executable we’ll use afterward within the tutorial.


You will want a number of instruments to construct the ISO, specifically cpio, tar, gzip,
advdef and mkisofs. These can in all probability be put in along with your package deal
supervisor. Please try this first.

First create a folder for constructing:

mkdir vim-as-pid-1
cd vim-as-pid-1

Additionally create a number of folders for the ISO construct:

mkdir /tmp/isomount
mkdir extract

Obtain the newest Tiny Core, Core version (with out GUI):


Copy the recordsdata from the ISO:

mount Core-current.iso /tmp/isomount/ -o loop,ro

cp -a /tmp/isomount/boot /tmp/

This creates a /tmp/boot folder with the core.gz and boot loader. Do not
overlook to umount it:

umount /tmp/isomount

We are going to use the /tmp/boot folder afterward when placing again collectively the ISO.

Altering the ISO

Go into the folder the place we’ll extract the core.gz root filesystem:

cd extract

Use zcat and cpio to extract the core.gz rootfs:

zcat /tmp/boot/core.gz | cpio -i -H newc -d

We now have an extracted root filesystem:

# ls
bin  dev  and many others  house  init  lib  linuxrc  mnt  choose  proc  root  run  sbin  sys  tmp  usr  var

Place the earlier built static Vim within the bin/ folder:

cp ~/vim bin/

You are able to do extra customizations, for instance, modifying the boot loader message.
That’s in a file named boot.msg in /tmp/boot/isolinux/:

# vim /tmp/boot/isolinux/boot.msg
 ( -   Boot to Vim
 //   Vim as Pid 1, as a result of Superior!

Press <Enter> to start or F2, F3, or F4 to view boot choices.

Altering the inittab

Besides in to Vim immediately we have to change the init configuration. Edit the
following file:

vim and many others/inittab

Change the next strains:

See Also

::sysinit:/and many others/init.d/rcS
tty1::respawn:/sbin/getty 38400 tty1



Do notice that this doesn’t truly make Vim PID 1. Init will nonetheless handle Vim,
and do stuff like fsck and mount the basis partition learn/write. If you wish to
go barebones, add init=/bin/vim to the bootloader (isolinux.cfg). Then, from
Vim, do :!fsck /dev/sda and mount -o remount,rw /.

Constructing a brand new ISO

Ensure you are nonetheless within the extract folder. Subject the next command to
construct a brand new tinycore.gz file which the ISO will use because it’s initramfs:

discover | cpio -o -H newc | gzip -2 > ../tinycore.gz

Copy that over the unique core.gz file in /tmp/boot which we copied

cp ../tinycore.gz /tmp/boot/core.gz

Create a brand new folder for the brand new ISO construct recordsdata:

mkdir /tmp/newiso

Copy the /tmp/boot folder to it:

cp -a /tmp/boot /tmp/newiso/

Construct a brand new ISO utilizing mkisofs:

cd /tmp/
mkisofs -l -J -R -V Boot_To_Vim -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/ -o Boot_to_Vim.iso newiso

You now have a file in /tmp named Boot_to_Vim.iso:

ls -la /tmp/Boot_to_Vim.iso
-rw-r--r-- 1 root root 11044864 Sep 17 08:05 /tmp/Boot_to_Vim.iso

You should utilize this in addition a VM, or burn an ISO. In the event you exit vim, it would

You can begin up an actual shell by giving the :!sh command, in command mode. To
shut down, situation the :!halt command.

Extra information on remastering Tiny Core could be discovered here.


Tags: blog
, compile
, emacs
, mips
, tiny-core
, vim

Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top