@@ -25,14 +25,8 @@ import (
2525)
2626
2727const (
28-
29- // ToDo: this is not being invoked...
30- initScriptFileName = "init"
31- // Having #!/bin/bash header causes a kernel panic.
32- // Not having the init file at all, causes a kernel panic.
33- initContent = `mount -t proc proc /proc
34- /lib/systemd/systemd
35- `
28+ initKernelInitrdPath = "/init"
29+ initBinaryInitrdPath = "/lib/systemd/systemd"
3630
3731 dracutConfig = `add_dracutmodules+=" dmsquash-live livenet selinux "
3832add_drivers+=" overlay "
@@ -81,10 +75,10 @@ func createFullOSInitrdImage(writeableRootfsDir, outputInitrdPath string) error
8175 return fmt .Errorf ("failed to clean root filesystem directory (%s):\n %w" , writeableRootfsDir , err )
8276 }
8377
84- initScriptPath := filepath .Join (writeableRootfsDir , initScriptFileName )
85- err = os .WriteFile ( initScriptPath , [] byte ( initContent ), 0755 )
78+ initKernelLocalPath := filepath .Join (writeableRootfsDir , initKernelInitrdPath )
79+ err = os .Symlink ( initBinaryInitrdPath , initKernelLocalPath )
8680 if err != nil {
87- return fmt .Errorf ("failed to create (%s):\n %w" , initScriptPath , err )
81+ return fmt .Errorf ("failed to create symlink (%s):\n %w" , initKernelLocalPath , err )
8882 }
8983
9084 err = initrdutils .CreateInitrdImageFromFolder (writeableRootfsDir , outputInitrdPath )
@@ -107,7 +101,7 @@ func createBootstrapInitrdImage(writeableRootfsDir, kernelVersion, outputInitrdP
107101
108102 chroot := safechroot .NewChroot (writeableRootfsDir , true /*isExistingDir*/ )
109103 if chroot == nil {
110- return fmt .Errorf ("failed to create a new chroot object for %s. " , writeableRootfsDir )
104+ return fmt .Errorf ("failed to create a new chroot object for (%s) " , writeableRootfsDir )
111105 }
112106 defer chroot .Close (true /*leaveOnDisk*/ )
113107
@@ -354,7 +348,7 @@ func getSizeOnDiskInBytes(fileOrDir string) (size uint64, err error) {
354348 diskSizeRegex := regexp .MustCompile (`^(\d+)\s+` )
355349 matches := diskSizeRegex .FindStringSubmatch (duStdout )
356350 if matches == nil || len (matches ) < 2 {
357- return 0 , fmt .Errorf ("failed to parse 'du -s' output (%s). " , duStdout )
351+ return 0 , fmt .Errorf ("failed to parse 'du -s' output (%s)" , duStdout )
358352 }
359353
360354 sizeInKbsString := matches [1 ]
0 commit comments