Kernel and Initrd filenames not correct in Foreman Full Host disk image

We have created a new bootdisk for Ubuntu but the boot variables are not
correct in it.
We mounted the iso image and found that the kernel and initrd filenames are
not matching the filenames in syslinux.cfg

··· ------------------------------------------------------------- root@rsiwal:~# mount -oloop /data/vboxubuntu.vbox.local_20160729_1200.iso /tmp/bootdisk/ root@rsiwal:~# cat /tmp/bootdisk/isolinux.cfg default linux label linux kernel BOOT/UBUNTU16_04_16_04_X86_64_LINUX append initrd=BOOT/UBUNTU16_04_16_04_X86_64_INITRD_GZ interface=auto url=http://foreman-aws.example.com/unattended/provision?token=a0b1896f-1176-4d30-8b74-7bb1391a4e42 ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=vboxubuntu.vbox.local console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA keyboard-configuration/layoutcode=us localechooser/translation/warn-light=true localechooser/translation/warn-severe=true locale=en_US #Disabling IPAPPEND as not suppoerted by Ubuntu 16.04 # IPAPPEND 2 root@rsiwal:~# ls -R /tmp/bootdisk/boot /tmp/bootdisk/boot: ubuntu16_04_16_04_x86_64_initr ubuntu16_04_16_04_x86_64_linu root@rsiwal:~# ls -R /tmp/bootdisk/boot -----------------------------------------------------------------------------------------------------------

Here are the foreman logs:-
2016-07-29 06:00:30 [app] [I] Rendered hosts/_nics.html.erb (53.5ms)
2016-07-29 06:00:30 [app] [I] Completed 200 OK in 61ms (Views: 53.0ms |
ActiveRecord: 3.4ms)
2016-07-29 06:00:41 [app] [I] Started GET
"/bootdisk/disks/full_hosts/vboxubuntu.vbox.local" for 14.142.72.154 at
2016-07-29 06:00:41 +0000
2016-07-29 06:00:41 [app] [I] Processing by
ForemanBootdisk::DisksController#full_host as HTML
2016-07-29 06:00:41 [app] [I] Parameters: {“id”=>“vboxubuntu.vbox.local”}
2016-07-29 06:00:41 [foreman_bootdisk] [I] Retrieved
http://archive.ubuntu.com/ubuntu//dists/xenial/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux
from local cache (use foreman-rake tmp:cache:clear to empty)
2016-07-29 06:00:41 [foreman_bootdisk] [I] Retrieved
http://archive.ubuntu.com/ubuntu//dists/xenial/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz
from local cache (use foreman-rake tmp:cache:clear to empty)
2016-07-29 06:00:42 [app] [I] Rendered text template (0.0ms)
2016-07-29 06:00:42 [app] [I] Sent data
vboxubuntu.vbox.local_20160729_1200.iso (3.8ms)
2016-07-29 06:00:42 [app] [I] Completed 200 OK in 521ms (Views: 3.6ms |
ActiveRecord: 19.5ms)

Foreman Version : 1.12.1
Foreman Installed on CentOS 7.2
Host being created : Ubuntu 16.04

I think foreman_bootdisk is miscalculating the maximum length of the
filenames that the ISO9660 format supports, as it's not taking into
account the "linux"/"initrd_gz" extensions.

Can you try to edit
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_bootdisk-8.0.1/app/services/foreman_bootdisk/iso_generator.rb
on your server? Towards the bottom is iso9660_filename and two mentions
of "0…30" - change these to something much shorter, e.g. 0…20, then
restart Foreman (touch ~foreman/tmp/restart.txt, or restart httpd). If
that works then I'll write a more correct fix.

··· On 29/07/16 07:14, Rajnesh Kumar Siwal wrote: > We have created a new bootdisk for Ubuntu but the boot variables are not > correct in it. > We mounted the iso image and found that the kernel and initrd filenames > are not matching the filenames in syslinux.cfg > ------------------------------------------------------------- > root@rsiwal:~# mount -oloop > /data/vboxubuntu.vbox.local_20160729_1200.iso /tmp/bootdisk/ > root@rsiwal:~# cat /tmp/bootdisk/isolinux.cfg > default linux > label linux > kernel BOOT/UBUNTU16_04_16_04_X86_64_LINUX > append initrd=BOOT/UBUNTU16_04_16_04_X86_64_INITRD_GZ interface=auto > url=http://foreman-aws.example.com/unattended/provision?token=a0b1896f-1176-4d30-8b74-7bb1391a4e42 > ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=vboxubuntu.vbox.local > console-setup/ask_detect=false console-setup/layout=USA > console-setup/variant=USA keyboard-configuration/layoutcode=us > localechooser/translation/warn-light=true > localechooser/translation/warn-severe=true locale=en_US > #Disabling IPAPPEND as not suppoerted by Ubuntu 16.04 > # IPAPPEND 2 > root@rsiwal:~# ls -R /tmp/bootdisk/boot > /tmp/bootdisk/boot: > ubuntu16_04_16_04_x86_64_initr ubuntu16_04_16_04_x86_64_linu


Dominic Cleal
dominic@cleal.org

Following lines were replaced and apache was restarted but the issue is
still NOT FIXED:

··· -------------------------------------------------------------------------------------------------- #file = File.basename(name).upcase.tr_s('^A-Z0-9_', '_')[0..30] #dir == '.' ? file : File.join(dir.upcase.tr_s('^A-Z0-9_', '_')[0..30], file) # Fixing long file and directory names file = File.basename(name).upcase.tr_s('^A-Z0-9_', '_')[0..20] dir == '.' ? file : File.join(dir.upcase.tr_s('^A-Z0-9_', '_')[0..20], file) -----------------------------------------------------------------------------------------------------

[root@foreman-aws tmp]# hammer -v bootdisk host --full FULL --host
vboxubuntu.vbox.local
Successfully downloaded host disk image to
vboxubuntu.vbox.local_20160729_1200.iso
[root@foreman-aws tmp]# mount -oloop
vboxubuntu.vbox.local_20160729_1200.iso /mnt/
[root@foreman-aws tmp]# cat /mnt/isolinux.cfg

default linux
label linux
kernel BOOT/UBUNTU16_04_16_04_X86_LINUX
append initrd=BOOT/UBUNTU16_04_16_04_X86_INITRD_GZ interface=auto
url=http://foreman-aws.example.com/unattended/provision?token=a0b1896f-1176-4d30-8b74-7bb1391a4e42
ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=vboxubuntu.vbox.local
console-setup/ask_detect=false console-setup/layout=USA
console-setup/variant=USA keyboard-configuration/layoutcode=us
localechooser/translation/warn-light=true
localechooser/translation/warn-severe=true locale=en_US
#Disabling IPAPPEND as not suppoerted by Ubuntu 16.04

IPAPPEND 2

[root@foreman-aws tmp]# ls -R /mnt/boot
/mnt/boot:
ubuntu16_04_16_04_x86_initrd_g ubuntu16_04_16_04_x86_linux
[root@foreman-aws tmp]# echo “ubuntu16_04_16_04_x86_initrd_g” |wc -c
31
[root@foreman-aws tmp]# echo “ubuntu16_04_16_04_x86_linux” |wc -c
28
[root@foreman-aws tmp]#

On Friday, July 29, 2016 at 1:16:31 PM UTC+5:30, Dominic Cleal wrote:

On 29/07/16 07:14, Rajnesh Kumar Siwal wrote:

We have created a new bootdisk for Ubuntu but the boot variables are not
correct in it.
We mounted the iso image and found that the kernel and initrd filenames
are not matching the filenames in syslinux.cfg

root@rsiwal:~# mount -oloop
/data/vboxubuntu.vbox.local_20160729_1200.iso /tmp/bootdisk/
root@rsiwal:~# cat /tmp/bootdisk/isolinux.cfg
default linux
label linux
kernel BOOT/UBUNTU16_04_16_04_X86_64_LINUX
append initrd=BOOT/UBUNTU16_04_16_04_X86_64_INITRD_GZ interface=auto
url=
http://foreman-aws.example.com/unattended/provision?token=a0b1896f-1176-4d30-8b74-7bb1391a4e42
ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=vboxubuntu.vbox.local
console-setup/ask_detect=false console-setup/layout=USA
console-setup/variant=USA keyboard-configuration/layoutcode=us
localechooser/translation/warn-light=true
localechooser/translation/warn-severe=true locale=en_US
#Disabling IPAPPEND as not suppoerted by Ubuntu 16.04

IPAPPEND 2

root@rsiwal:~# ls -R /tmp/bootdisk/boot
/tmp/bootdisk/boot:
ubuntu16_04_16_04_x86_64_initr ubuntu16_04_16_04_x86_64_linu

I think foreman_bootdisk is miscalculating the maximum length of the
filenames that the ISO9660 format supports, as it’s not taking into
account the “linux”/“initrd_gz” extensions.

Can you try to edit
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_bootdisk-8.0.1/app/services/foreman_bootdisk/iso_generator.rb

on your server? Towards the bottom is iso9660_filename and two mentions
of “0…30” - change these to something much shorter, e.g. 0…20, then
restart Foreman (touch ~foreman/tmp/restart.txt, or restart httpd). If
that works then I’ll write a more correct fix.


Dominic Cleal
dom...@cleal.org <javascript:>

This only appears to be one character out, having the last "z"
truncated. Just shorten the filename again, e.g. 15 rather than 20.

··· On 29/07/16 09:40, Rajnesh Kumar Siwal wrote: > > Following lines were replaced and apache was restarted but the issue is > still NOT FIXED: > -------------------------------------------------------------------------------------------------- > #file = File.basename(name).upcase.tr_s('^A-Z0-9_', '_')[0..30] > #dir == '.' ? file : File.join(dir.upcase.tr_s('^A-Z0-9_', > '_')[0..30], file) > # Fixing long file and directory names > file = File.basename(name).upcase.tr_s('^A-Z0-9_', '_')[0..20] > dir == '.' ? file : File.join(dir.upcase.tr_s('^A-Z0-9_', > '_')[0..20], file) > ----------------------------------------------------------------------------------------------------- > > [root@foreman-aws tmp]# hammer -v bootdisk host --full FULL --host > vboxubuntu.vbox.local > Successfully downloaded host disk image to > vboxubuntu.vbox.local_20160729_1200.iso > [root@foreman-aws tmp]# mount -oloop > vboxubuntu.vbox.local_20160729_1200.iso /mnt/ > [root@foreman-aws tmp]# cat /mnt/isolinux.cfg > > > default linux > label linux > kernel BOOT/UBUNTU16_04_16_04_X86_LINUX > append initrd=BOOT/UBUNTU16_04_16_04_X86_INITRD_GZ interface=auto > url=http://foreman-aws.example.com/unattended/provision?token=a0b1896f-1176-4d30-8b74-7bb1391a4e42 > ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=vboxubuntu.vbox.local > console-setup/ask_detect=false console-setup/layout=USA > console-setup/variant=USA keyboard-configuration/layoutcode=us > localechooser/translation/warn-light=true > localechooser/translation/warn-severe=true locale=en_US > #Disabling IPAPPEND as not suppoerted by Ubuntu 16.04 > # IPAPPEND 2 > [root@foreman-aws tmp]# ls -R /mnt/boot > /mnt/boot: > ubuntu16_04_16_04_x86_initrd_g ubuntu16_04_16_04_x86_linux


Dominic Cleal
dominic@cleal.org

Thanks a lot, Domnic.
It WORKED !!!

··· +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ [root@foreman-aws tmp]# hammer -v bootdisk host --full FULL --host vboxubuntu.vbox.local Successfully downloaded host disk image to vboxubuntu.vbox.local_20160729_1200.iso /mnt/boot: ubuntu16_04_16_0_initrd_gz ubuntu16_04_16_0_linux [root@foreman-aws tmp]# grep -i --color ubuntu16_04_16_0_initrd_gz /mnt/isolinux.cfg append initrd=BOOT/UBUNTU16_04_16_0_INITRD_GZ interface=auto url=http://foreman-aws.chargepoint.com/unattended/provision?token=a0b1896f-1176-4d30-8b74-7bb1391a4e42 ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=vboxubuntu.vbox.local console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA keyboard-configuration/layoutcode=us localechooser/translation/warn-light=true localechooser/translation/warn-severe=true locale=en_US [root@foreman-aws tmp]#

On Friday, July 29, 2016 at 2:14:07 PM UTC+5:30, Dominic Cleal wrote:

On 29/07/16 09:40, Rajnesh Kumar Siwal wrote:

Following lines were replaced and apache was restarted but the issue is
still NOT FIXED:


#file = File.basename(name).upcase.tr_s('^A-Z0-9_', '_')[0..30] 
#dir == '.' ? file : File.join(dir.upcase.tr_s('^A-Z0-9_', 

’)[0…30], file)
# Fixing long file and directory names
file = File.basename(name).upcase.tr_s(’^A-Z0-9
’, ‘’)[0…20]
dir == ‘.’ ? file : File.join(dir.upcase.tr_s(’^A-Z0-9
’,
’_’)[0…20], file)


[root@foreman-aws tmp]# hammer -v bootdisk host --full FULL --host
vboxubuntu.vbox.local
Successfully downloaded host disk image to
vboxubuntu.vbox.local_20160729_1200.iso
[root@foreman-aws tmp]# mount -oloop
vboxubuntu.vbox.local_20160729_1200.iso /mnt/
[root@foreman-aws tmp]# cat /mnt/isolinux.cfg

default linux
label linux
kernel BOOT/UBUNTU16_04_16_04_X86_LINUX
append initrd=BOOT/UBUNTU16_04_16_04_X86_INITRD_GZ interface=auto
url=
http://foreman-aws.example.com/unattended/provision?token=a0b1896f-1176-4d30-8b74-7bb1391a4e42
ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=vboxubuntu.vbox.local
console-setup/ask_detect=false console-setup/layout=USA
console-setup/variant=USA keyboard-configuration/layoutcode=us
localechooser/translation/warn-light=true
localechooser/translation/warn-severe=true locale=en_US
#Disabling IPAPPEND as not suppoerted by Ubuntu 16.04

IPAPPEND 2

[root@foreman-aws tmp]# ls -R /mnt/boot
/mnt/boot:
ubuntu16_04_16_04_x86_initrd_g ubuntu16_04_16_04_x86_linux

This only appears to be one character out, having the last "z"
truncated. Just shorten the filename again, e.g. 15 rather than 20.


Dominic Cleal
dom...@cleal.org <javascript:>