OSInside / kiwi

KIWI - Appliance Builder Next Generation
https://osinside.github.io/kiwi
GNU General Public License v3.0
307 stars 152 forks source link

create_init_link_from_linuxrc failed #1394

Closed syyhao1994 closed 4 years ago

syyhao1994 commented 4 years ago

Problem description

when i use kiwi of pxe, i got the error as below: KiwiCommandError: ln: stderr: ln: failed to access '/home/mkiso/kiwi_boot_root.v8u7eh4n/linuxrc': No such file or directory

Expected behaviour

building success

Steps to reproduce the behaviour

I use the command kiwi-ng --type pxe system build --description /home/linuxiso/ --target-dir /home/mkiso/

and my config.xml is listed as below:


<?xml version="1.0" encoding="utf-8"?>

<image schemaversion="1.0" name="linux">
    <description type="system">
        <author>syy</author>
        <contact>syy</contact>
        <specification>pxe initrd</specification>
    </description>
    <preferences>
        <type image="cpio" bootprofile="default" bootkernel="std"/>
        <version>1.0.0</version>
        <packagemanager>yum</packagemanager>
        <bootsplash-theme>upstream</bootsplash-theme>
        <bootloader-theme>upstream</bootloader-theme>
        <locale>en_US</locale>
        <keytable>us.map.gz</keytable>
        <rpm-check-signatures>false</rpm-check-signatures>
        <type image="pxe" filesystem="ext4" boot="/home/linuxiso"/>
    </preferences>
    <profiles>
        <profile name="std" description="KERNEL: Default"/>
        <profile name="default" description="Booting default setup"/>
    </profiles>
    <repository type="rpm-md" alias="OS">
            <source path="dir:///home/repos"/>
    </repository>
    <packages type="bootstrap">
        <package name="filesystem" />
    </packages>
    <packages type="image">
        <package name="openssl"/>
        <package name="zstd"/>
        <package name="kernel"/>
        <package name="openssh"/>
        <package name="dhcp"/>
        <package name="iproute"/>
        <package name="lvm2"/>
    </packages>
</image>

OS and Software information

syyhao1994 commented 4 years ago

kiwi boot images provides the linuxrc script, however the kernel also expects an init executable to be present. This method creates a hard link to the linuxrc file

It seems there are no linuxrc script in initrd.xz. There are no problems if i delete self.setup.create_init_link_from_linuxrc() in kiwi/boot/image/builtin_kiwi.py

schaefi commented 4 years ago

You are creating <type image="cpio" that is not a pxe suitable image type. May I ask what you would like to achieve ?

Also maybe the docs here are helpful:

and we prefer pxe images that are disk images deployed via pxe, see the docs for that here:

Hope that helps

syyhao1994 commented 4 years ago

You are creating <type image="cpio" that is not a pxe suitable image type. May I ask what you would like to achieve ?

Also maybe the docs here are helpful:

and we prefer pxe images that are disk images deployed via pxe, see the docs for that here:

Hope that helps

I only need a linux and rootfs(initrd), and i do not need to install through pxe. As i creating <type image="cpio" , i can get files that i needed(.kernel, initrd.xz, .md5, .packages, tar.xz) only if i commented the self.setup.create_init_link_from_linuxrc() in kiwi/boot/image/builtin_kiwi.py.I don not know if its suitable to do so. Looking forward to hearing from you. Thank you.

davidcassany commented 4 years ago

Not sure what you are after but if you use something like

<type image="pxe" filesystem="ext4" initrd_system="dracut">

The result will be:

  1. An image with an ext4 filesystem containing the rootfs of the system without any bootloader installation
  2. An initrdfile created with dracut
  3. The kernel file
  4. An *.append text file containing the kernel command flags and options
  5. .md5, .packages metafiles

You could eventually boot it with something similar to qemu-kvm --kernel <kernelfile> --initrd <initrdfile> -hda <imagefile> --append <kernelcmds>

syyhao1994 commented 4 years ago

Not sure what you are after but if you use something like

<type image="pxe" filesystem="ext4" initrd_system="dracut">

The result will be:

  1. An image with an ext4 filesystem containing the rootfs of the system without any bootloader installation
  2. An initrdfile created with dracut
  3. The kernel file
  4. An *.append text file containing the kernel command flags and options
  5. .md5, .packages metafiles

You could eventually boot it with something similar to qemu-kvm --kernel <kernelfile> --initrd <initrdfile> -hda <imagefile> --append <kernelcmds>

You are right! I could boot it with the action below after change grub.cfg, $ cp .initrd.xz /boot/initrd $ cp .kernel /boot/linux.

Acturally my question is that there is a error: KiwiCommandError: ln: stderr: ln: failed to access '/home/mkiso/kiwi_boot_root.v8u7eh4n/linuxrc': No such file or directory It seems kiwi did not provides a linuxrc script, if i create a linurc script under root, everything will be ok. I can also solve the problem through commented the self.setup.create_init_link_from_linuxrc() in kiwi/boot/image/builtin_kiwi.py.

syyhao1994 commented 4 years ago

And i found another problem. The mod of my root filesystem (/) is 700. I think 555 or 755 maybe better.

[root@localhost /]# ls -l / -d drwx------ 15 root root 460 Apr 20 11:09 /

DEBUG: 19:44:35 | EXEC: [rsync -a /home/mkiso/kiwi_boot_root.3xwb3uzf/ /tmp/kiwi_boot_root_copy._48briaa] DEBUG: 19:44:36 | EXEC: [rm -r -f /tmp/kiwi_boot_root_copy._48briaa/boot] I think rsync -a change the mod of /home/mkiso/kiwi_boot_root.3xwb3uzf/, the mod of /home/mkiso/kiwi_boot_root.3xwb3uzf/ is 755, but the mod of /home/mkiso/kiwi_boot_root.3xwb3uzf/ is 700.

schaefi commented 4 years ago

Hi, in our sprint meeting we came across this one and wondered if there is anything we can do to help you with or to identify if there is some bug in kiwi. To be honest we have no clue about your use case or why you are doing the things as you are doing them.

We don't see a problem in permissions or missing boot data. usually all that is handled via dracut but it seems you are using your own boot code ? Just a lot of guessing and we don't know how we could help you.

It would help to understand your use case or what you would like to achieve

Thanks

syyhao1994 commented 4 years ago

Hi, in our sprint meeting we came across this one and wondered if there is anything we can do to help you with or to identify if there is some bug in kiwi. To be honest we have no clue about your use case or why you are doing the things as you are doing them.

We don't see a problem in permissions or missing boot data. usually all that is handled via dracut but it seems you are using your own boot code ? Just a lot of guessing and we don't know how we could help you.

It would help to understand your use case or what you would like to achieve

Thanks

I am sorry for my unclearly description. I used the config.xml and the command kiwi-ng --type pxe system build --description /home/linuxiso/ --target-dir /home/mkiso/, and i got an initrdfile created with dracut and a kernel file. Then i can modify /boot/grub.cfg with a new option on my virtual machine as i do the action as below: $ cp .initrd.xz /boot/initrd $ cp .kernel /boot/linux

Then i can reboot my virtual machine to choose to login to the linux and initrdfile system. The problem is here, when i login to the system, i found the permission of / is 0700, rather than 0755 or 0555.

I take a look at image-root.log, and i found that the permission maybe change during the rsync action listed as below: DEBUG: 19:44:35 | EXEC: [rsync -a /home/mkiso/kiwi_boot_root.3xwb3uzf/ /tmp/kiwi_boot_root_copy._48briaa] The permission of /home/mkiso/kiwi_boot_root.3xwb3uzf/ is 0755, but the permission of /tmp/kiwi_boot_root_copy._48briaa is 0700. Maybe the mkdtemp funtion of /usr/lib/python3.7/site-packages/kiwi/boot/image/builtin_kiwi.py could not save the permisson of the original directory.

schaefi commented 4 years ago

Sorry for the long delay. I finally understand what you were referring to with the permission bits. A pull request to fix this will follow