VirtualBox

Ticket #19856 (closed defect: fixed)

Opened 3 months ago

Last modified 5 weeks ago

'VBoxManage unattended install' fails to detect system locale => fixed in svn/6.1.x x>14

Reported by: Yahont Owned by: paulson
Component: VM control Version: VirtualBox 6.1.10
Keywords: Cc:
Guest type: Linux Host type: Mac OS X

Description

Version 6.1.12 r139181 (Qt5.6.3), macOS 10.15.6 (19G2021)

According to the documentation on the unattended install if the locale and the timezone is not specified in arguments the VirtualBox must get the locale and the timezone from the host OS. But for macOS this does not work.

Here is script to test:

#!/bin/bash
# safe bash
set -o errexit -o noclobber -o nounset -o pipefail -o xtrace -o errtrace
# check command line arguments
if [ $# -ne 2 ]
then
   echo -e "Usage:\n\t $0 <redhat_installation_image.iso> <ssh_public_key_file>" 1>&2
   exit 1
fi
dvd_iso="$1"
echo "Check installation image \"${dvd_iso}\""
eval $(VBoxManage unattended detect --iso "${dvd_iso}" --machine-readable)
if [ "$OSTypeId" = 'RedHat_64' -a "$OSVersion" = '7' ]
then
   echo "The installation image \"${dvd_iso}\" is Ok"
else
   echo "Error: The installation image must be RedHat 7 64bit or so like (CentOS, for instance)" 1>&2
   exit 2
fi
ssh_public_key="$2"
echo "Check ssh public key \"${ssh_public_key}\""
if [ -r "${ssh_public_key}" ]
then
   ssh_fingerprint="$(ssh-keygen -l -f "${ssh_public_key}" | cut -d ' ' -f 2)"
else
   echo "Error: The ssh public key file is not readable" 1>&2
   exit 3
fi

readonly vm_name='TestVirtualBox'
readonly vboxvm_vdi=~/"Library/VirtualBox/${vm_name}/${vm_name}.vdi"

VBoxManage createvm --name "${vm_name}" --ostype RedHat_64 --register
VBoxManage modifyvm "${vm_name}" --memory 600 --vram=10 --boot1 dvd --boot2 disk --boot3 none --boot4 none --rtcuseutc on --graphicscontroller vmsvga --firmware bios --defaultfrontend headless --nic1 nat --nictype1 virtio --mouse ps2 --keyboard ps2 --audio none --cpus 2
VBoxManage setextradata "${vm_name}" 'GUI/ScaleFactor' 2
VBoxManage createmedium disk --filename "${vboxvm_vdi}" --size 3072
VBoxManage storagectl "${vm_name}" --name 'DiskController' --add sas --hostiocache on --bootable on
VBoxManage storagectl "${vm_name}" --name 'DVDController' --add sata --hostiocache on --bootable on
VBoxManage storageattach "${vm_name}" --storagectl 'DiskController' --type hdd --port 0 --device 0 --medium "${vboxvm_vdi}"
VBoxManage storageattach "${vm_name}" --storagectl 'DVDController' --type dvddrive --port 0 --device 0 --medium "${dvd_iso}"
VBoxManage unattended install "${vm_name}" --iso="${dvd_iso}" --hostname="${vm_name}.${vm_name}" --package-selection-adjustment='minimal' --script-template="redhat.kickstart" --post-install-command="mkdir -m 700 \"\${MY_TARGET}/root/.ssh\" && echo '$(cat "${ssh_public_key}")' >>\"\${MY_TARGET}/root/.ssh/authorized_keys\"" --start-vm='headless' --extra-install-kernel-parameters='net.ifnames=0 biosdevname=0 ks=cdrom:/ks.cfg' # --locale='ru_RU' --time-zone="Europe/Moscow"

Kickstart file:

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL

eula --agreed

# Firewall configuration
firewall --disabled

# Install OS instead of upgrade
install

# Use CDROM installation media
cdrom

# Root password
rootpw --plaintext @@VBOX_INSERT_ROOT_PASSWORD_SH@@

# System authorization information
auth  --useshadow  --passalgo=sha512

# Use text mode install
text

# System keyboard
keyboard --vckeymap=us

# System language
lang @@VBOX_INSERT_LOCALE@@

# OL 6.4 needs this, but it doesn't work with RHEL60.
#unsupported_hardware

# SELinux configuration
selinux --enforcing

# Installation logging level
logging --level=info

# System timezone
timezone@@VBOX_COND_IS_RTC_USING_UTC@@ --utc@@VBOX_COND_END@@ @@VBOX_INSERT_TIME_ZONE_UX@@

# Network information
network --device=eth0 --onboot=on --bootproto=dhcp --noipv6 --activate

# System bootloader configuration
bootloader --location=mbr --append="nomodeset crashkernel=auto net.ifnames=0 biosdevname=0"
zerombr

# Partition clearing information
clearpart --all --initlabel

# Disk partitioning information
part / --label system --fstype ext4 --grow --asprimary

# Reboot after installation
# Note! Not sure exctly when the --eject option was added. Need to find out an make it optional.
reboot --eject

%packages
-plymouth
-chrony
-kexec-tools
-NetworkManager
-NetworkManager-team
-NetworkManager-tui
-NetworkManager-wifi
%end

# Post install happens in a different script.
# Note! We mount the CDROM explictily here since the location differs between fedora 26 to rhel5
#       and apparently there isn't any way to be certain that anaconda didn't unmount it already.
%post --nochroot --log=/mnt/sysimage/root/ks-post.log
df -h
mkdir -p /tmp/vboxcdrom
mount /dev/cdrom /tmp/vboxcdrom
cp /tmp/vboxcdrom/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
chmod a+x /mnt/sysimage/root/vboxpostinstall.sh
/bin/bash /mnt/sysimage/root/vboxpostinstall.sh --rhel
umount /tmp/vboxcdrom
%end

%addon com_redhat_kdump --disable
%end

Here is an environment:

$ locale
LANG="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_CTYPE="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_ALL="ru_RU.UTF-8"
$ sudo systemsetup -gettimezone
Password:
Time Zone: Europe/Moscow

When I with default timezone and locale, the VirtualBox does not get it from the OS:

VBoxManage: info: Starting unattended installation of RedHat_64 in machine 'TestVirtualBox' (084b9732-228c-42d2-b4a7-84495815cadc).
VBoxManage: info: Using values:
                           isoPath = /Users/olleg/prog/CentOS-7-x86_64-Minimal-2003.iso
                              user = vboxuser
                          password = changeme
                      fullUserName =
                        productKey =
                  additionsIsoPath = /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
             installGuestAdditions = false
              validationKitIsoPath =
            installTestExecService = false
                            locale = en_US
                           country = RU
                          timeZone = Etc/UTC
                             proxy =
                          hostname = TestVirtualBox.TestVirtualBox
       packageSelectionAdjustments = minimal
                 auxiliaryBasePath = /Users/olleg/Library/VirtualBox/TestVirtualBox/Unattended-084b9732-228c-42d2-b4a7-84495815cadc-
                        imageIndex = 1
                scriptTemplatePath = /Users/olleg/prog/redhat.kickstart
     postInstallScriptTemplatePath = /Applications/VirtualBox.app/Contents/MacOS/UnattendedTemplates/redhat_postinstall.sh
                postInstallCommand = mkdir -m 700 "${MY_TARGET}/root/.ssh" && echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB9PrVXezMvKBPbSYDL5b/dtlQKlhLoamO5Ga47xa+KG olleg@petrel' >>"${MY_TARGET}/root/.ssh/authorized_keys"
      extraInstallKernelParameters = net.ifnames=0 biosdevname=0 ks=cdrom:/ks.cfg
                          language = en-US
                  detectedO
{{{

}}}
STypeId = RedHat_64
                 detectedOSVersion = 7
                  detectedOSFlavor =
               detectedOSLanguages = en-US
                   detectedOSHints =
VBoxManage: info: Waiting for VM 'TestVirtualBox' to power on...
VBoxManage: info: VM 'TestVirtualBox' (084b9732-228c-42d2-b4a7-84495815cadc) has been successfully started.

But if I uncomment this options in the scripts, all works:

VBoxManage: info: Starting unattended installation of RedHat_64 in machine 'TestVirtualBox' (cf49aefb-c275-4422-9952-b505aecf1346).
VBoxManage: info: Using values:
                           isoPath = /Users/olleg/prog/CentOS-7-x86_64-Minimal-2003.iso
                              user = vboxuser
                          password = changeme
                      fullUserName =
                        productKey =
                  additionsIsoPath = /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
             installGuestAdditions = false
              validationKitIsoPath =
            installTestExecService = false
                            locale = ru_RU
                           country = RU
                          timeZone = Europe/Moscow
                             proxy =
                          hostname = TestVirtualBox.TestVirtualBox
       packageSelectionAdjustments = minimal
                 auxiliaryBasePath = /Users/olleg/Library/VirtualBox/TestVirtualBox/Unattended-cf49aefb-c275-4422-9952-b505aecf1346-
                        imageIndex = 1
                scriptTemplatePath = /Users/olleg/prog/redhat.kickstart
     postInstallScriptTemplatePath = /Applications/VirtualBox.app/Contents/MacOS/UnattendedTemplates/redhat_postinstall.sh
                postInstallCommand = mkdir -m 700 "${MY_TARGET}/root/.ssh" && echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB9PrVXezMvKBPbSYDL5b/dtlQKlhLoamO5Ga47xa+KG olleg@petrel' >>"${MY_TARGET}/root/.ssh/authorized_keys"
      extraInstallKernelParameters = net.ifnames=0 biosdevname=0 ks=cdrom:/ks.cfg
                          language = en-US
                  detectedOSTypeId = RedHat_64
                 detectedOSVersion = 7
                  detectedOSFlavor =
               detectedOSLanguages = en-US
                   detectedOSHints =
VBoxManage: info: Waiting for VM 'TestVirtualBox' to power on...
VBoxManage: info: VM 'TestVirtualBox' (cf49aefb-c275-4422-9952-b505aecf1346) has been successfully started.

Attachments

Screenshot 2020-09-03 at 14.26.48.png Download (332.0 KB) - added by Yahont 3 months ago.
screenshot

Change History

Changed 3 months ago by Yahont

screenshot

comment:1 Changed 3 months ago by paulson

  • Owner set to paulson
  • Status changed from new to accepted
  • Summary changed from VirtualBox does not detect locale and timezone under MacOS to 'VBoxManage unattended install' fails to detect system locale

Thanks for the bug report. I've updated the synopsis as this isn't specific to macOS hosts and I've confirmed that there is a problem with the locale retrieval code. For the timezone detection the code as it stands today simply checks for $TZ in the environment and uses that if set.

comment:2 Changed 2 months ago by paulson

  • Summary changed from 'VBoxManage unattended install' fails to detect system locale to 'VBoxManage unattended install' fails to detect system locale => fixed in svn/6.1.x x>14

The issue with 'VBoxManage unattended install' failing to detect the locale has been addressed in revision r140292 of the development branch of VirtualBox and is available now in the development snapshot Testbuilds. The fix has also been backported to the 6.1 branch of VirtualBox as of revision r140295 and is available now in the 6.1.x Testbuilds. The fix will also be part of the next maintenance release of VirtualBox 6.1.x.

The approach which 'VBoxManage unattended install' uses for determining the system's locale has also been extended to check well known configuration locations /etc/localtime, /etc/timezone, and /etc/sysconfig/clock if $TZ is not set. Those improvements are present in revision r140509 in the development branch and r140537 in the 6.1 branch and will be part of any Testbuilds containing those revisions.

comment:3 Changed 5 weeks ago by arudnev

  • Status changed from accepted to closed
  • Resolution set to fixed

Fixed in 6.1.16

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use