Clonezilla intergrate in FOG



  • Goodafternoon,

    I tried to make a Hook and make my own task. But if i run this task below:

    <?php
    /**
     * Alters the boot task to make a custom entry.
     *
     * PHP version 5
     *
     * @category BootTask
     * @package  FOGProject
     * @author   Tom Elliott <tommygunsster@gmail.com>
     * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
     * @link     https://fogproject.org
     */
    /**
     * Alters the boot task to make a custom entry.
     *
     * @category BootTask
     * @package  FOGProject
     * @author   Tom Elliott <tommygunsster@gmail.com>
     * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
     * @link     https://fogproject.org
     */
    class BootTask23 extends Hook
    {
        /**
         * The name of this hook.
         *
         * @var string
         */
        public $name = 'BootTask23';
        /**
         * The description of this hook.
         *
         * @var string
         */
        public $description = 'Alter the boot task to make a custom task hook';
        /**
         * Is this hook active or not.
         *
         * @var bool
         */
        public $active = true;
        /**
         * Initializes object.
         *
         * @return void
         */
        public function __construct()
        {
            parent::__construct();
            self::$HookManager
                ->register(
                    'IPXE_EDIT',
                    array(
                        $this,
                        'changeTask'
                    )
                );
        }
        /**
         * Change the task.
         *
         * @param mixed $arguments The items to alter.
         *
         * @return void
         */
        public function changeTask($arguments)
        {
            if (!isset($arguments['ipxe']['task'])) {
                return;
            }
            $TaskType = self::getClass('TaskType')
                ->set('name', 'BootTask23')
                ->load('name');
            if (!$TaskType->isValid()) {
                return;
            }
            $keys = array_keys($arguments['ipxe']['task']);
            if (!in_array($TaskType->get('id'), $keys)) {
                return;
            }
            $arguments['ipxe']['task'][$TaskType->get('id')] = array(
                'kernel http://IP of fogserver/fog/service/ipxe/vmlinuz',
                'initrd http://IP of fogserver/fog/service/ipxe/initrd.img',
                'imgargs vmlinuz initrd=initrd.img fetch=http://IP of fogserver/fog/service/ipxe/filesystem.squashfs boot=live hostname=oneiric config quiet noswap nolocales edd=on nomodeset ocs_prerun="dhclient -v enp1s0" ocs_prerun1="sleep 2" ocs_prerun2="mount -t cifs -o user=,domain=,password= ***location*** /home/partimag/" ocs_prerun3="sleep 2"ocs_live_run="ocs-sr -g auto -e1 auto -e2 -batch -r -scr -k1 -p poweroff restoredisk ***name of file*** sda" ocs_live_extra_param="" keyboard-layouts=NONE ocs_live_batch="yes" ocs_lang="en_US.UTF-8" noprompt vga=791',
                'boot',
            );
            $arguments['Host']
                ->get('task')
                ->set(
                    'stateID',
                    self::getCompleteState()
                )->save();
        }
    }
    

    Why if i run the task above ill get the following error:

    Init Version 20200517
    Fatal error: Unknown request type :: Null
    Kernel variables and settings:
    Bzimage loglevel =4

    and it said computer will reboot in 1 minute.

    Does someone can help me out with this?

    Thank you,


  • Senior Developer

    @kaywokke Great to hear you got this working with the help of @george1421! Well done, as this is definitely not an easy one to setup if you’re still a FOG beginner.

    You might want to share your code and steps in this topic to help the community. I am sure someone will find this helpful one day.



  • @george1421 Thank you George it is working now! also it is booting. Thank you.


  • Moderator

    You might want to read through this thread. It talks about creating the hook and then adding in the task type edit plugin that you will need.

    https://forums.fogproject.org/topic/10274/creating-task-with-tasktypemanagement



  • @george1421 Hi george thanks for the information, i am new at fog so it is not easy for me to understand. Where can i set this parameter in the Hook? where do i need to put the type parameter?

    Because if i do it from the task editor page and i save it and check again the task it is dissapeared.


  • Moderator

    @kaywokke said in Clonezilla intergrate in FOG:

    i want to boot the device in Clonezilla where it automatically set back the right image of the device.

    Isn’t this duplicating the same function that FOG does already? Without any coding?

    But back on topic.

    I know how hooks are supposed to work as well as I understand how the FOS Engine runs. In a normal FOG deployment the FOG server sends messages to the FOS Engine (the customized version of linux that runs on the target computer) via kernel parameters the FOG server writes into the command that starts the FOS engine. There is a special kernel parameter to the FOS engine called type. That type parameter tells the main FOS script what to do on the target computer. See this main script. https://github.com/FOGProject/fos/blob/master/Buildroot/board/FOG/FOS/rootfs_overlay/bin/fog

    When the FOS engine prints unknown request type Null, is because the type kernel parameter was not set. When you write that hook, I assume that you are creating your own new type parameter. You need to pass that parameter to the FOS engine. So as I see it, you need to program the hook (what the code will actually do) as well as configure a matching parameter to send via the task type edit plugin.

    Now onto what I was mentioning before. I have a tutorial on how to add a FOG iPXE menu to boot different live linux environments using FOG. Understand this is unrelated to imaging. https://forums.fogproject.org/topic/10944/using-fog-to-pxe-boot-into-your-favorite-installer-images
    This is all done without any programming. I’m just creating a new iPXE menu that calls up the different linux kernels. While I haven’t had the need, I assume you could pxe boot into clonezilla this way to.


  • Moderator

    @kaywokke

    type=down for deploy
    type=up for capture

    Simple as that.

    But there are other potential parameters that may be necessary for it to function as expected.



  • @Sebastian-Roth Sebastian what you mean with possibly is there a place where i can find documentatio about the type?

    @george1421 i want to boot the device in Clonezilla where it automatically set back the right image of the device.


  • Moderator

    @kaywokke Thank you on the image that was able to confirm what I suspected and what Sebastian pointed out. The unknown request type::Null is created because there is no type kernel parameter defined. So the FOS engine doesn’t know what to do.

    Also as Sebastian mentioned and the reason why I asked what your goal is, because there are other ways to pxe boot into a clonezilla setup with FOG than a dedicated task.

    What did you create in task type edit plugin? Somewhere you need to pass the type= kernel parameter to the FOS engine.

    If you look in the task type edit plugin on your computer you will see examples to Capture an image the kernel args are type=up In your case your type should match what you programmed in the hook.


  • Senior Developer

    @kaywokke FOG needs particular parameters to be able to run tasks. As this is not a normal FOG task I am wondering if you don’t simply want to add this to the iPXE menu and image your machines through this.

    While I can see the advantage of making this a task I still may ask. If you need this to be a task you’ll need to add parameters like type=down and possibly more to make this work.



  • @george1421 this is the screenshot that i have strange is we had another Fog Projects server that has the same error now.



  • We have multiple clonezilla images i want to deploy a task where it automatically image the device.
    91a6b722-abf0-48cf-bc66-5189814385e6-image.png


  • Moderator

    I can’t really help you with the programming side, but is your goal to simply netboot clonezilla or do you specifically need an unmanned/forced task to boot into clonezilla on next reboot?

    On point of your question, what does the kernel parameters say. See if you can get a clear screen shot of all of the kernel parameters in the error message.


Log in to reply
 

311
Online

7.4k
Users

14.5k
Topics

136.5k
Posts