Trim diskless rootimg

the exclude list attribute: linuximage.exlist

To reduce the memory occupation and boot-up time for the diskless node, the initrd and rootimg.gz should be kept as compact as possible under the premise of meeting the user’s requirements.

xCAT provides an exclude list attribute linuximage.exlist in the osimage object definition, which enables user to trim the rootimg on the diskless node after the rpms are installed into the rootimg directory by genimage on management node.

Take the osimage sles12.1-ppc64le-netboot-compute for example:

# lsdef -t osimage -o sles12.1-ppc64le-netboot-compute
Object name: sles12.1-ppc64le-netboot-compute
    exlist=/opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.exlist
    imagetype=linux
    osarch=ppc64le
    osdistroname=sles12.1-ppc64le
    osname=Linux
    osvers=sles12.1
    otherpkgdir=/install/post/otherpkgs/sles12.1/ppc64le
    permission=755
    pkgdir=/install/sles12.1/ppc64le
    pkglist=/opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist
    postinstall=/opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.postinstall
    profile=compute
    provmethod=netboot
    rootimgdir=/install/netboot/sles12.1/ppc64le/compute

the content of exlist file

The file specified in linuximage.exlist includes relative path of the directories and files that will be excluded from the rootimg.gz generated by packimage. The relative path suppose the rootimg directory, /install/netboot/sles12.1/ppc64le/compute/rootimg here, to be the base directory. [1] [2]

xCAT ships a default exlist file, user can add or remove entries based on it according to their need.

The content of the default exlist file /opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.exlist is:

# cat /opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.exlist
./boot*
./etc/bootsplash/themes/SLES/images*
./opt/sci/include*
./usr/include*
./usr/lib/locale*
./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/auto/Encode/CN*
./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/auto/Encode/JP*
./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/auto/Encode/TW*
./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/auto/Encode/KR*
./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/Encode/CN*
./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/Encode/JP*
./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/Encode/KR*
./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/Encode/TW*
./usr/lib64/gcc/powerpc64le-suse-linux/4.8/include*
./usr/local/include*
./usr/local/man*
./usr/powerpc64le-suse-linux/include*
./usr/share/X11/locale/*
+./usr/share/X11/locale/en_US.UTF-8*
+./usr/share/X11/locale/C*
./usr/share/cracklib*
./usr/share/doc*
./usr/share/doc/packages/cyrus-sasl/doc*
./usr/share/gnome*
./usr/share/i18n*
./usr/share/info*
./usr/share/locale/*
+./usr/share/locale/en_US*
+./usr/share/locale/C*
./usr/share/man*
./usr/share/omf*
./usr/share/vim/site/doc*
./usr/share/vim/vim[0-9]*/doc*
./var/cache/man*
./var/cache/zypp*

The content above presents some syntax supported in exlist file:

  • exclude entry:

    ./usr/share/X11/locale/*
    

all the files and subdirectories under rootimg/usr/share/X11/locale/ will be excluded.

  • include entry:

    +./usr/share/locale/C*
    

all the files and subdirectories with the name matching pattern C* under /usr/share/locale/ will be included in the rootimg.gz, it is quite useful to use + initialed entries following an exclude entry to include some specific files or directories under the excluded parent directory.

  • pattern of the file name and directory [3]:

    ./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/Encode/JP*
    

all the files and subdirectories matching the pattern ./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/Encode/JP* will be excluded, such as

./usr/lib/perl5/5.18.2/ppc64le-linux-thread-multi/Encode/JP
./usr/lib/perl5/5.18.2/ppc64le-linux-thread-multi/Encode/JP/H2Z.pm
./usr/lib/perl5/5.18.2/ppc64le-linux-thread-multi/Encode/JP/JIS7.pm
./usr/lib/perl5/5.18.2/ppc64le-linux-thread-multi/Encode/JP.pm

customize the exlist file and the osimage definition

Please check the default exlist file and make sure:

  • all files and directories you do not want in the image will be excluded from the rootimg.
  • no file or directory you need will be excluded from the rootimg.

If you want to customize the osimage sles12.1-ppc64le-netboot-compute with your own exlist file, please follow the following steps:

#create a customized exlist file based on the default one
cp /opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.exlist  /install/custom/netboot/sles/compute.sles12.ppc64le.exlist

#edit the newly created exlist file according to your need
vi /install/custom/netboot/sles/compute.sles12.ppc64le.exlist

#specify the newly created exlist file in the osimage definition
chdef -t osimage -o sles12.1-ppc64le-netboot-compute exlist=/install/custom/netboot/sles/compute.sles12.ppc64le.exlist
[1]It would only make sense to use an absolute path name here. It means that this entry will never match anything: /usr/share/locale/*.
[2]The exlist file entry should not be ended with a slash /, it means that this entry will never match anything: ./usr/lib/perl[0-9]/[0-9.]*/ppc64le-linux-thread-multi/Encode/.
[3]Pattern match test applies to the whole file name,starting from one of the start points specified in the exlist file entry. The regex syntax comply the with the regex syntax of system command find -path, please refer to its doc for details.