SmartOS add custom files

I was working on this bug 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:

  1. Create a directory called custom which will hold the custom /etc/system file.
  2. [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
    
  3. Create a loader.conf.local and the etc subdirectory with your custom system file
  4. [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]# 
    
  5. In loader.conf.local we will specify the loader to use the custom /etc/system
  6. 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
    
  7. Create an iso from the smartos-live repo using the gmake-iso target.

  8. Install the new platform image using the iso created in the previous step

  9. $ piadm install /opt/platform.iso
    

  10. Activate the new platform image, take the name from piadm list
  11. $ piadm activate  
    

  12. Reboot

  13. $ shutdown
    

Now your custom /etc/system file should be in /system/boot/etc/system.

Troubleshooting

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://kebe.com/blog/?p=504