Modifying boot files with SmartOS under Loader

2021-04-20
2 min read

I was working on this bug https://www.illumos.org/issues/6395, but in order to test my changes I needed to load a custom /etc/system file, as I’m using PIADM(1M) the steps are the following:

  • Create a directory called custom which will hold the custom /etc/system file.
[root@smartos-dev /zones/boot]# ls -lrt
total 12
drwxr-xr-x   4 root     root           5 Apr  8 02:50 platform-20210408T001154Z
drwxr-xr-x   3 root     root           3 Apr 20 16:02 etc
drwxr-xr-x   4 root     root           5 Apr 20 19:07 platform-20210420T172124Z
drwxr-xr-x   4 root     root          15 Apr 20 22:43 boot-20210408T001154Z
drwxr-xr-x   3 root     root           4 Apr 20 23:08 custom
drwxr-xr-x   4 root     root          16 Apr 20 23:35 boot-20210420T172124Z
lrwxrwxrwx   1 root     root          23 Apr 20 23:35 boot -> ./boot-20210420T172124Z
lrwxrwxrwx   1 root     root          27 Apr 20 23:35 platform -> ./platform-20210420T172124Z
  • Create a loader.conf.local and the etc subdirectory with your custom system file
[root@smartos-dev /zones/boot/custom]# ls -lrt
total 3
-rw-r--r--   1 root     root         102 Apr 20 22:47 loader.conf.local
drwxr-xr-x   2 root     root           3 Apr 21 00:20 etc
[root@smartos-dev /zones/boot/custom]# 

In the loader.conf.local we will specify the loader to use the custom /etc/system

system_load="YES"
system_type="file"
system_name="/custom/etc/system"
system_flags="name=/etc/system"

I just copied the /etc/system file to /zones/boot/custom/etc/ and added the following for my test.

set segkpsize=0x80000
  • Now with files in place we need to install another platform image so the custom files would be picked up on this new platform image. I just created an iso from the smartos-live repo using the gmake-iso target.

    $ piadm install /opt/platform.iso
    
  • Activate the new platform image, take the name from piadm list

     piadm activate <new platform image> 
    
  • Reboot

Now your custom /etc/system file should be in /system/boot/etc/system. In case you are not able to boot because of a misconfiguration on the custom system file, you will need to choose boot to boot loader, then type disable-module system and your file won’t be used at boot so you will be able to get into the system and fix it.

Thank you very much sjorge, danmcd and jbk on #smartos irc channel, for guiding me through this and point me to the documentation.

References

https://wiki.smartos.org/modifying-boot-files/
https://movementarian.org/blog/posts/2019-02-12-modifying-boot-files-with-smartos-under-loader/
https://smartos.topicbox.com/groups/smartos-discuss/T420746d875884043