From 8e9428986da0e01d7b41293e94ecf493f35cb616 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 17 Jan 2020 18:02:50 +0100 Subject: [PATCH] SLE15: genimage fixes - Mount /sys and /proc - needed for newer versions of the SLE permissions RPM. See: https://github.com/openSUSE/permissions/commit/2d0ef5d55b30f72322d18951214353ecfd9c4245 - Create /sys to have /sys/kernel/fscaps. Fixes: "Warning: running kernel does not support fscaps" - Fix permissions of /dev devices - Make sure /sys and /proc are unmounted everytime --- xCAT-server/share/xcat/netboot/sles/genimage | 60 +++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 9d4f0d706..ab1d79707 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -72,6 +72,31 @@ sub xdie { die @_; } +sub umount { + # some rpms mounts the imageroot/proc on the /proc, need to release it, + # otherwise got kernal panic when installing + # sometimes, the proc fs is not mounted, so one warning/error message will display, + # and I add one check point here. + my $MFD; + open MFD, "/proc/mounts"; + my @lines = ; + close MFD; + + my $ret = grep m{$rootimg_dir/proc}, @lines; + if ($ret > 0) { + system("umount -l $rootimg_dir/proc"); + } + $ret = grep m{$rootimg_dir/sys}, @lines; + if ($ret > 0) { + system("umount -l $rootimg_dir/sys"); + } +} + +# Make sure we clean up all mounts everytime +END { + umount(); +} + #-- fetch current version form CVS (overwrite locally changed versions) # if (opendir(CVS,"$pathtofiles/CVS")){ # close CVS; @@ -225,26 +250,32 @@ unless ($onlyinitrd) { mkpath "$rootimg_dir/etc"; mkpath "$rootimg_dir/dev"; + mkpath "$rootimg_dir/proc"; + mkpath "$rootimg_dir/sys"; + + #needed for newer versions of the SLE permissions RPM. See: https://github.com/openSUSE/permissions/commit/2d0ef5d55b30f72322d18951214353ecfd9c4245 + system "mount -t proc none $rootimg_dir/proc"; + #Create /sys to have /sys/kernel/fscaps. Fixes: "Warning: running kernel does not support fscaps" + system "mount -o bind /sys $rootimg_dir/sys"; #system "mount -o bind /dev $rootimg_dir/dev"; unless (-e "$rootimg_dir/dev/zero") { - system "mknod $rootimg_dir/dev/zero c 1 5"; + system "mknod -m 0666 $rootimg_dir/dev/zero c 1 5"; } unless (-e "$rootimg_dir/dev/null") { - system "mknod $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11 + system "mknod -m 0666 $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11+ } - unless (-e "$rootimg_dir/dev/random") { - system "mknod $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11 + system "mknod -m 0666 $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11+ } unless (-e "$rootimg_dir/dev/urandom") { - system "mknod $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11 + system "mknod -m 0666 $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11+ } for (my $i = 0 ; $i <= 12 ; $i++) { unless (-e "$rootimg_dir/dev/tty$i") { - system "mknod $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11 + system "mknod -m 0620 $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11+ } } @@ -872,19 +903,8 @@ system("cd $rootimg_dir/usr/bin/; ln -s ../../bin/keyctl $rootimg_dir/usr/bin/ke # which is different from the Redhat family -# some rpms mounts the imageroot/proc on the /proc, need to release it, -# otherwise got kernal panic when installing -# sometimes, the proc fs is not mounted, so one warning/error message will display, -# and I add one check point here. -my $MFD; -open MFD, "/proc/mounts"; -my @lines = ; -close MFD; - -my $ret = grep m{$rootimg_dir/proc}, @lines; -if ($ret > 0) { - system("umount -l $rootimg_dir/proc"); -} +# umount /proc and /sys from rootimg +umount(); # Load driver update disk, and copy them to the root image my @dd_drivers = &load_dd(); @@ -1953,7 +1973,7 @@ sub generic_post { # This function is meant to leave the image in a state approx } unlink("$rootimg_dir/dev/null"); - system("mknod $rootimg_dir/dev/null c 1 3"); + system("mknod -m 0666 $rootimg_dir/dev/null c 1 3"); open($cfgfile, ">", "$rootimg_dir/etc/fstab"); print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n"; print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n";