Skip to content Skip to main navigation Skip to footer

How To Add IFL To The Grub Menu With makeGRUB

Introduction:

Starting with IFL version 2.83, the 'makeGRUB' script provided with Image for Linux (IFL) has been modified to be able to add IFL to the Grub menu of a Linux distribution. Both Grub legacy and Grub2 are supported for most distributions (please see the Limitations section below). Doing this provides the following capability:

  • Can manually select IFL from the Grub menu while booting up to the Linux distribution.
  • Can manually execute 'iflreboot' (with optional script parameter) from the running Linux distribution to reboot the system into IFL.
  • Can set up Linux cron jobs (with optional script parameter) to automatically reboot the system into IFL, perform one or more image operations, and then automatically reboot back up to the Linux distribution.

An advantage of using this method is that the IFL Boot Disk will be available without needing to handle the IFL boot media, or having to create a separate IFL partition to boot it from. The files to boot IFL will be installed in the /boot/ifl directory, meaning they will be included on the /boot partition if there is one. If there is no separate /boot partition, they will be on the root partition. In addition, 2 scripts will be installed in the /usr/local/bin directory to support the ability to reboot into IFL, either manually, or from a cron job.

Setting this up is accomplished with the 'makeGRUB' script, which includes the following capabilities on its' main menu:

1. Create the Grub boot files for IFL: Customized versions can be created with the same configuration options available in 'makeISO', 'makeHDD', and 'makePXE'. The title of the IFL item on the Grub menu can also be customized.

2. Install the Grub boot files for IFL: This adds IFL to the menu, populates /boot/ifl with the IFL files, and installs the associated scripts in /usr/local/bin.

3. Schedule IFL cron jobs: Add, delete, and edit IFL cron jobs from the menu interface.

4. Uninstall the Grub boot files for IFL. This removes IFL from the Grub menu, and deletes all files installed by the install option.

Limitations:

1. Fedora UEFI installs (including Fedora UEFI derivatives) are currently not supported. BIOS-based Fedora installs (and derivatives) are supported.

2. The Grub directory (i.e. /boot/grub) must be on a regular partition, such as /dev/sda1, /dev/sda2, etc. Other types of block devices such as RAID or LVM drives are not supported. Note that many typical/default partition layouts use a regular partition for /boot, and LVM for root, swap, etc. As long as /boot is on a regular partition, these configurations are supported.

3. The partition containing the /boot/grub directory must be formatted as ext2/3/4. Other file systems are not supported.

Precautions:

Since adding IFL to the Grub menu requires modifying existing files, you may wish to make backup copies of the files listed below before proceeding. While these backups are not normally expected to be needed, having them available can make things easier if problems do occur.

For Grub Legacy installs:

1. The menu.lst or grub.conf file in one of the following locations:

  /boot/grub/menu.lst                           (most Grub legacy installs)

  /boot/grub/grub.conf                          (Fedora, Redhat, Centos Grub legacy installs)

  /boot/efi/EFI/redhat/grub.conf             (Redhat, CentOS Grub legacy installs on UEFI)

For Redhat (and Redhat derivatives), the actual text file is grub.conf, but menu.lst is also there as a symlink to grub.conf. The file to backup is grub.conf.

For Grub2 installs:

1. /etc/grub.d/40_custom

2. The grub.cfg file in one of the following locations:

  /boot/grub/grub.cfg                            (most Grub2 installs)

  /boot/grub2/grub.cfg                          (Fedora, OpenSuse)

Install Procedure to add IFL to the Grub menu:

1. Install the 'dialog' program (if necessary).  The 'dialog' program will be required by 'makeGRUB' (and 'iflbuild') to display some of the menus and other screens. Since many distributions do not install the 'dialog' package by default, it is suggested that you do that now. Common command lines are:

apt-get install dialog      (Debian, Ubuntu, Linux Mint, etc.)

yum install dialog          (Fedora, Redhat, etc.)

zypper install dialog      (OpenSuse)

Or use a graphical package manager. If you forget this step, the scripts will fail to run, and will exit with a message to install the 'dialog' package.

2. One of the following IFL zip files is required:

ifl_en.zip                     (registered CUI version)

ifl_en_gui.zip               (registered GUI version)

ifl_en_trial.zip              (trial CUI version)

ifl_en_gui_trial.zip        (trial GUI version)

Note: The non-network zip files are for use in Windows only, and cannot be used for this purpose. However, 'makeGRUB' supports creating both network and non-network versions of IFL. This is selectable from the menu when you create the Grub boot files for IFL (see step 9 of this install procedure).

3. Set up IFL on your distribution as outlined in the following tutorial:

https://www.terabyteunlimited.com/howto/ifl_setup_linux/

Setting up IFL on a Linux distribution basically just involves extracting the zip file to a directory, opening a terminal window, changing to the directory extracted to, and then running the 'setup' script (as root or with 'sudo'). When 'setup' completes, you will see the 'makeGRUB' script in the IFL directory. Also in the IFL directory will be the 'iflbuild' script, which optionally can be used as a front end to 'makeGrub', as is shown in the following steps.

4. (Optional) Populate the scripts directory. In the extracted IFL directory, there is a 'scripts' directory provided as a location to add any user scripts that you wish to be available while booted into IFL. Note that in addition to Linux shell scripts, tbosdt .tbs and .run scripts are also supported. Adding one or more scripts to this directory will not, by itself,  cause any of them to run on boot, but they will be available to run manually. To have one or more of the scripts run on boot, or to display a menu of scripts on boot, please see the "Configuring User Scripts" section later in this article.

5. (Optional) Run './iflbuild' to start the 'iflbuild' script. On the main menu, select "View/Modify ifl-custom.ini" if you wish to customize any ifl.ini settings that will be in effect when you boot into IFL.

6. Run './makeGRUB' (or start it from the 'iflbuild' menu in step 5).

7. Select "Create Grub boot files for IFL" on the main menu.

8. (Optional) Select "Modify IFL Grub menu title". Use this item to customize the IFL title on the Grub menu.

9. (Optional) Select "Network or non-network". Use this item to enable or disable network support in IFL.

10. Select "Continue to IFL Settings Menu". This will take you to the IFL Boot Media Settings" menu, which is common to all of the make* scripts. On this menu, you can configure items such as video mode, kernel boot parameters, network interfaces, restore disc settings, etc. There is also a "Configure User Shell Scripts" item which can be used to specify a script to run on boot, a sequence of scripts to run on boot, or a menu of scripts to be displayed on boot. For more information on configuring user shell scripts, please see the "Configuring User Shell Scripts" section later in this article.

11. Select "Finished/Exit Menu" to create the IFL boot files. After responding to the two prompts for console login and root password, the set of Grub files for IFL will be created and placed in the 'grub' directory within the extracted IFL directory. They are not yet installed in the Linux distribution. This will take you back to the 'makeGRUB' main menu, from where you can repeat steps 7 to 11 at any time if you wish to change any IFL settings.

12. Select "Install Grub boot files for IFL". This item will install the Grub boot files for IFL that were created in step 11. Doing this will add IFL to the Grub menu. A confirmation screen will be displayed to explain the actions that will be taken. Press <OK> to confirm the install, or <Cancel> to back out.  While installing, information about the steps being taken will be displayed as they occur.

Important Note: To make any changes to the settings and configuration of IFL, you will need to repeat steps 7 to 11 to recreate the files, and then repeat step 12 to have the changes take effect in the installed version of IFL.

Booting into IFL:

 

1. On a normal boot: Simply select IFL from the Grub menu. If the menu is hidden (as Ubuntu and other distributions sometimes do), you can usually press <Shift> to display the menu, and then select IFL. For information on how to unhide the menu, please see item 1 in the Additional Information section below.

2. Rebooting to IFL manually using 'iflreboot': When the Grub files for IFL were installed, a script was installed at /usr/local/bin/iflreboot. When executed, 'iflreboot' will cause the following sequence to occur:

  • set the default Grub menu item to IFL
  • reboot the system, which will then automatically boot into IFL
  • on boot, IFL will restore the previous default menu item
  • on next reboot, the system will automatically boot to the previous default menu item

3. Rebooting to IFL from a cron job:  This is the same as item 2 above, except that 'iflreboot' is initiated by the cron job, instead of manually from a command prompt. Please see the section on cron jobs for more information.

Note 1: In items 2 and 3 above, the 'iflreboot' script can take an optional script parameter. Please see the "Configuring User Scripts" section below for more information.

Note 2: Even if the Grub menu is hidden, it will still boot into IFL when it is set as the default boot item.

Note 3: If you decide not to boot into IFL after initiating a reboot with 'iflreboot', IFL will remain as the default item on the Grub menu until you do boot into IFL. If desired, the normal default menu item can be restored from the Linux distribution by running 'iflupdate' from the command prompt. The 'iflupdate' script is installed by 'makeGRUB' in the /usr/local/bin directory, along with 'iflreboot'.

Scheduling and Managing Cron Jobs:

1. Select "Schedule IFL cron jobs" from the 'makeGRUB' main menu. If any IFL cron jobs already exist, they will be listed on the screen. Otherwise it will say that no cron jobs are currently defined.

2. Select "Add an IFL cron job" to create a new cron job.  The resulting screen will have an input box at the bottom, and a screen of text explaining how to configure a cron job. The input box will contain the default cron job line, which is already configured to run the 'iflreboot' script. The default line will only need to be edited to set the time(s) and date(s) when it will run, and to (optionally) add a script parameter at the end. Please see the section on user scripts for information on the available script parameters. When ready, press "OK" to create the cron job.

3. Select "Edit an existing IFL cron job" to edit an existing IFL cron job. This will bring up a menu where you can choose from the list of existing IFL cron jobs to edit. Selecting a cron job will bring up a screen similar to the "Add an IFL cron job" screen, where the time, date, and script parameters can be changed as needed.

4. Select "Delete an IFL cron job" to delete an existing cron job. This will bring up a menu of existing cron jobs that can be deleted.

All IFL cron jobs will be stored in the file /etc/cron.d/iflcron, which is simply a text file containing one IFL cron job per line. This file will be deleted when the Gub boot files for IFL are uninstalled from 'makeGRUB'. It will also be deleted if there are no IFL cron jobs currently defined. IFL cron jobs are limited to a max of 12.

Configuring User Scripts:

The information below assumes that the IFL scripts directory has been populated with one or more user scripts, as described in step 4 of the install procedure above. From there, user scripts can be configured in one of the 5 ways outlined below:

1. Normal Boot (no scripts will run). This is the default. Scripts in the scripts directory (if any) can be executed manually, and will also be available by selecting "Display User Scripts Menu" from the desktop menu (GUI), or the Auxiliary menu (CUI).

2. Specify a single script to execute automatically on boot. There are 3 ways of doing this:

  1. On the IFL Boot Media Settings menu in 'makeGRUB, select the "Configure User Scripts" item, and then choose "Select a script to run on boot". That will display a menu from where you can choose the script to execute on boot.
  2. When running the 'iflreboot' script, add the script name as a command line parameter. For example, the command line 'iflreboot myscript' will cause 'myscript' to execute on boot. The script name cannot contain any spaces in this situation.
  3. When configuring a cron job for IFL, add the script name to the end of the cron job line, as shown in the example below. This is the same thing as (2), except that it's automated, rather than executed manually. The script name cannot contain any spaces in this situation.

        30 5 * * Sun root /usr/local/bin/iflreboot myscript

Note that when an 'iflreboot' parameter is specified, as in (2) and (3) above, that will override any setting specified using (1) for that IFL session.

3. Specify that all scripts execute sequentially on boot. Scripts will execute in numeric, upper case, lower case order. There are 3 ways of doing this:

  1. On the IFL Boot Media Settings menu in 'makeGRUB, select the "Configure User Scripts" item, and then choose "Run all scripts in scripts directory on boot".
  2. When running the 'iflreboot' script, use 'runall' as the command line parameter, as in 'iflreboot runall'. Note that 'seq' will also work for compatibility reasons.
  3. When configuring a cron job for IFL, add 'runall' to the end of the cron job line, as shown in the example below. This is the same thing as (2), except that it's automated, rather than executed manually.

        30 5 * * Sun root /usr/local/bin/iflreboot runall

Note that when an 'iflreboot' parameter is specified, as in (2) and (3) above, that will override any setting specified using (1) for that IFL session.

4. Specify that all scripts listed in the file scriptslist.txt (located in scripts directory) will execute in the order listed in that file. There are 3 ways of doing this:

  1. On the IFL Boot Media Settings menu in 'makeGRUB, select the "Configure User Scripts" item, and then choose "Run all scripts in scriptslist.txt on boot".
  2. When running the 'iflreboot' script, use 'runlist' as the command line parameter, as in 'iflreboot runlist'.
  3. When configuring a cron job for IFL, add 'runlist' to the end of the cron job line, as shown in the example below. This is the same thing as (2), except that it's automated, rather than executed manually.

        30 5 * * Sun root /usr/local/bin/iflreboot runlist

Note that when an 'iflreboot' parameter is specified, as in (2) and (3) above, that will override any setting specified using (1) for that IFL session.

5. Specify that a menu of all scripts is displayed on boot.  There are 3 ways of doing this:

  1. On the IFL Boot Media Settings menu in 'makeGRUB, select the "Configure User Scripts" item, and then choose "Display a menu of all scripts on boot".
  2. When running the 'iflreboot' script, use 'menu' as the command line parameter, as in 'iflreboot menu'.
  3. When configuring a cron job for IFL, add 'menu' to the end of the cron job line, as shown in the example below. This is the same thing as (2), except that it's automated, rather than executed manually.

        30 5 * * Sun root /usr/local/bin/iflreboot menu

Note that when an 'iflreboot' parameter is specified, as in (2) and (3) above, that will override any setting specified using (1) for that IFL session.

Additional Note: Those familiar with using the RUNSCRIPTS option in config.txt to specify scripts to run on boot, can continue to use that method in place of item 1 in methods 2 and 3 above. However, please note that any script parameter specified with 'iflreboot' will override any RUNSCRIPTS settings, just as it overrides any settings made via the "Configure User Scripts" menu item in 'makeGRUB'.

Removing (uninstalling) IFL from the Grub Menu:

1. Run './makeGRUB' to start 'makeGRUB'.

2. Select "Uninstall Grub boot files for IFL" on the main menu. This item will uninstall the Grub boot files for IFL that were installed in step 12 of the install procedure above. Doing this will remove IFL from the Grub menu, and will delete all files previously installed by 'makeGRUB'.  A confirmation screen will be displayed to explain the actions that will be taken. Press <OK> to confirm, or <Cancel> to back out.  While uninstalling, information about the steps being taken will be displayed as they occur.

Important Note:  Uninstalling the Grub files from the Linux distribution (step 2 above) does not delete the Grub files in the grub directory (within the IFL directory). Those files will remain there until you either delete the extracted IFL directory, or until you create new ones, as in steps 7 to 11 of the install procedure. As long as the grub directory still contains the set of files you want to install, you can install and uninstall them as many times as you wish. You will only need to create a new set of files if you want to change IFL settings.

Additional Information:

1. Unhiding the Grub2 menu: Some distributions, such as Ubuntu, will hide the Grub boot menu, particularly if no other operating systems were added to the menu during installation. The hidden menu will not prevent IFL from booting as expected when using the 'iflreboot' script as described in this article. However, if you do wish to unhide the menu, information about doing that can be found at the link below:

GRUB 2 Menu Not Shown When Booting Linux

Was This Article Helpful?

0