View Issue Details

IDProjectCategoryView StatusLast Update
0013213CentOS-7-OTHERpublic2017-05-02 19:41
Reporterschlomo 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0013213: autorelabel fails on Vagrant image for VirtualBox
Description/.autorelabel does not work on the standard centos/7 Vagrant images when using the VirtualBox provider.
Steps To Reproduce1. Create an empty directory and put the Vagrantfile with the following content:


2. Install plugins:
vagrant plugin install vagrant-reload

3. Start the VM:
vagrant up

4. Observe the output, it will show that the autorelabel service failed:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' is up to date...
==> default: Setting the name of the VM: centos-7-vagrant_default_1493753483965_28121
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: ++ touch /.autorelabel
==> default: Running provisioner: reload...
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'centos/7' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: ++ ls -l /.autorelabel
==> default: -rw-r--r--. 1 root root 0 May 2 19:31 /.autorelabel
==> default: ++ systemctl status rhel-autorelabel
==> default: ● rhel-autorelabel.service - Relabel all filesystems, if necessary
==> default: Loaded: loaded (/usr/lib/systemd/system/rhel-autorelabel.service; static; vendor preset: disabled)
==> default: Active: failed (Result: exit-code) since Tue 2017-05-02 19:32:00 UTC; 22s ago
==> default: Process: 563 ExecStart=/lib/systemd/rhel-autorelabel (code=exited, status=208/STDIN)
==> default: Main PID: 563 (code=exited, status=208/STDIN)
==> default:
==> default: May 02 19:32:00 localhost.localdomain systemd[1]: Starting Relabel all filesystems, if necessary...
==> default: May 02 19:32:00 localhost.localdomain systemd[563]: Failed at step STDIN spawning /lib/systemd/rhel-autorelabel: Inappropriate ioctl for device
==> default: May 02 19:32:00 localhost.localdomain systemd[1]: rhel-autorelabel.service: main process exited, code=exited, status=208/STDIN
==> default: May 02 19:32:00 localhost.localdomain systemd[1]: Failed to start Relabel all filesystems, if necessary.
==> default: May 02 19:32:00 localhost.localdomain systemd[1]: Unit rhel-autorelabel.service entered failed state.
==> default: May 02 19:32:00 localhost.localdomain systemd[1]: rhel-autorelabel.service failed.
==> default: ++ grep ttyS0 /proc/cmdline /etc/default/grub /boot/grub2/grub.cfg
==> default: /proc/cmdline:BOOT_IMAGE=/vmlinuz-3.10.0-514.10.2.el7.x86_64 root=/dev/mapper/VolGroup00-LogVol00 ro no_timer_check console=tty0 console=ttyS0,115200 net.ifnames=0 biosdevname=0 crashkernel=auto rd.lvm.lv=VolGroup00/LogVol00 rd.lvm.lv=VolGroup00/LogVol01 rhgb quiet
==> default: /etc/default/grub:GRUB_CMDLINE_LINUX="no_timer_check console=tty0 console=ttyS0,115200 net.ifnames=0 biosdevname=0 crashkernel=auto rd.lvm.lv=VolGroup00/LogVol00 rd.lvm.lv=VolGroup00/LogVol01 rhgb quiet"
==> default: /boot/grub2/grub.cfg: linux16 /vmlinuz-3.10.0-514.10.2.el7.x86_64 root=/dev/mapper/VolGroup00-LogVol00 ro no_timer_check console=tty0 console=ttyS0,115200 net.ifnames=0 biosdevname=0 crashkernel=auto rd.lvm.lv=VolGroup00/LogVol00 rd.lvm.lv=VolGroup00/LogVol01 rhgb quiet

Additional InformationThe reason is that the images configure console=ttyS0 which is not connected in VirtualBox but autorelabel requires a working tty, see https://github.com/rear/rear-workshop-osbconf-2016/issues/4#issuecomment-286515264 for details.

Using Vagrant image centos/7 mentioned in https://seven.centos.org/2017/04/updated-centos-vagrant-images-available-v1703-01/

Removing the console= options from the kernel command line actually solves the problem. You can verify that with the following commands and the given Vagrantfile, it will remove the console= settings from the grub config before rebooting (setting the FIX environment variable activates the fix script):

$ vagrant destroy -f
$ FIX=1 vagrant up
#Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' is up to date...
==> default: Setting the name of the VM: centos-7-vagrant_default_1493753768029_7916
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: ++ sed -i -e 's/ console=[^ ]\+\?//g' /etc/default/grub
==> default: ++ cat /etc/default/grub
==> default: GRUB_TIMEOUT=1
==> default: GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
==> default: GRUB_DEFAULT=saved
==> default: GRUB_DISABLE_SUBMENU=true
==> default: GRUB_TERMINAL_OUTPUT="console"
==> default: GRUB_CMDLINE_LINUX="no_timer_check net.ifnames=0 biosdevname=0 crashkernel=auto rd.lvm.lv=VolGroup00/LogVol00 rd.lvm.lv=VolGroup00/LogVol01 rhgb quiet"
==> default: GRUB_DISABLE_RECOVERY="true"
==> default: ++ grub2-mkconfig -o /boot/grub2/grub.cfg
==> default: Generating grub configuration file ...
==> default: Found linux image: /boot/vmlinuz-3.10.0-514.10.2.el7.x86_64
==> default: Found initrd image: /boot/initramfs-3.10.0-514.10.2.el7.x86_64.img
==> default: done
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: ++ touch /.autorelabel
==> default: Running provisioner: reload...
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'centos/7' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: ++ ls -l /.autorelabel
==> default: ls: cannot access /.autorelabel: No such file or directory
==> default: ++ : '************ AUTORELABELING DONE ***************'
==> default: ++ systemctl status rhel-autorelabel
==> default: ● rhel-autorelabel.service - Relabel all filesystems, if necessary
==> default: Loaded: loaded (/usr/lib/systemd/system/rhel-autorelabel.service; static; vendor preset: disabled)
==> default: Active: inactive (dead)
==> default: Condition: start condition failed at Tue 2017-05-02 19:37:07 UTC; 19s ago
==> default: none of the trigger conditions were met
==> default: ++ grep ttyS0 /proc/cmdline /etc/default/grub /boot/grub2/grub.cfg
==> default: ++ : '************ EVERYTING IS FINE NOW ***************'

TagsNo tags attached.
abrt_hash
URLhttps://github.com/rear/rear-workshop-osbconf-2016/issues/4

Activities

schlomo

schlomo

2017-05-02 19:41

reporter  

Vagrantfile (1,188 bytes)
# BUG proof for VirtualBox vagrant with centos/7 failing to run autorelabel
#
# before starting install the reload plugin with: vagrant plugin install vagrant-reload
#
# see the bug: vagrant up
# destroy VM: vagrant destroy -f
# see the fix (disable serial console): FIX=1 vagrant up
#
# destroy VM: vagrant destroy -f

Vagrant.configure(2) do |config|
  config.vm.box = "centos/7"

  config.vm.provider "virtualbox" do |vb|
     vb.memory = "1024"
  end
  config.vm.synced_folder ".", "/vagrant", disabled: true

  if ENV['FIX']
    config.vm.provision "shell", inline: <<-SHELL
      set -x
      sed -i -e 's/ console=[^ ]\\+\\?//g' /etc/default/grub
      cat /etc/default/grub
      grub2-mkconfig -o /boot/grub2/grub.cfg
    SHELL
  end

  config.vm.provision "shell", inline: <<-SHELL
     set -x
     touch /.autorelabel
  SHELL

  config.vm.provision :reload

  config.vm.provision "shell", inline: <<-SHELL
     set -x
     ls -l /.autorelabel || : "************ AUTORELABELING DONE ***************"
     systemctl status rhel-autorelabel
     grep ttyS0 /proc/cmdline /etc/default/grub /boot/grub2/grub.cfg || : "************ EVERYTING IS FINE NOW ***************"
  SHELL
end
Vagrantfile (1,188 bytes)

Issue History

Date Modified Username Field Change
2017-05-02 19:41 schlomo New Issue
2017-05-02 19:41 schlomo File Added: Vagrantfile