virt-builder stucks in endless loop due to /sbin/dhclient-script failure

Bug #1649280 reported by Kamil Madac
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
isc-dhcp (Ubuntu)
New
Undecided
Unassigned

Bug Description

virt-builder cannot build VM image as it uses locally installed /sbin/dhclient-script. dhclient-script tries to find out whether / is RW and reads /etc/fstab. Issue is that it does not exists in supermin machine which virt-builder uses and it end up in an endless loop of messages:

...
/sbin/dhclient-script: 31: /sbin/dhclient-script: cannot open /etc/fstab: No such file
RTNETLINK answers: File exists
/sbin/dhclient-script: 31: /sbin/dhclient-script: cannot open /etc/fstab: No such file
RTNETLINK answers: File exists
/sbin/dhclient-script: 31: /sbin/dhclient-script: cannot open /etc/fstab: No such file
RTNETLINK answers: File exists
/sbin/dhclient-script: 31: /sbin/dhclient-script: cannot open /etc/fstab: No such file
RTNETLINK answers: File exists
/sbin/dhclient-script: 31: /sbin/dhclient-script: cannot open /etc/fstab: No such file
^C
WARNING: CTRL+C pressed!!!

How to reproduce the bug (on 16.04):
~# apt install libguestfs-tools
~# virt-builder debian-8 --root-password password:xxx --hostname testvm --format qcow2 -v

Proposed solution:
Do not use /etc/fstab for finding out the state of / in dhclient-script, but use /proc/mounts instead of it. It makes more sense as it shows real state of filesystems and it exists on supermin machines, so virt-builder runs flawlessly.

Patch:
--- /sbin/dhclient-script.orig 2016-12-12 14:48:18.062438451 +0100
+++ /sbin/dhclient-script 2016-12-12 14:53:24.897500263 +0100
@@ -28,7 +28,7 @@
 wait_for_rw() {
     local file=$1
     # Find out whether we are going to mount / rw
- exec 9>&0 </etc/fstab
+ exec 9>&0 </proc/mounts
     rootmode=rw
     while read dev mnt type opts dump pass junk; do
         [ "$mnt" != / ] && continue

After you apply the patch delete virt-builder cache by deleting of /var/tmp/.guestfs-* directories and run virt-builder again.

Description: Ubuntu 16.04.1 LTS
Release: 16.04
libguestfs-tools 1:1.32.2-4ubuntu2
isc-dhcp-client 4.3.3-5ubuntu12.3

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.