Bug#538118: don't run update-grub in chroots

Stefan Lippers-Hollmann s.L-H at gmx.de
Tue Aug 18 14:29:14 UTC 2009


tags 538118 + patch
thanks

Hi

Running update-grub as part of the maintainer scripts also breaks 
installing grub2/ grub-pc inside a chroot (without having a full /dev/ 
bind-mounted into the chroot, which is often not wanted). This particular 
behaviour seems to be a regression introduced in grub2 1.96+20090808-1, as 
merely installing grub2 into a chroot (procfs and devpts mounted, but not 
/dev/ itself) did work for me with grub2 1.96+20090725-1.

The attached patch, taken from udev's chroot detection (#395889) reliably 
omits calling update-grub inside a chroot. I suggest applying this patch to
the maintainer scripts (and not update-grub itself), as there are reasons 
(rescue system, etc.) to execute update-grub inside a chrooted system 
manually (with a full /dev/ (bind-)mounted).

Regards
	Stefan Lippers-Hollmann

# cdebootstrap --arch=amd64 --flavour=minimal sid /mnt/ http://ftp.at.debian.org/debian/

P: Retrieving Release
[...]
P: Writing resolv.conf

# chroot /mnt/ /bin/bash

# mount -t proc -onodev,noexec,nosuid proc-chroot /proc
# mount -t devpts devpts-chroot /dev/pts/
# LANG=C
# export LANG

# apt-get update
[...]
# apt-get install apt-utils dialog whiptail debconf                                                                                                                                                                                                                                                           
[...]
Get:1 http://ftp.at.debian.org sid/main apt-utils 0.7.22.2 [194kB]                                                                                                                                                                                                                                                       
Get:2 http://ftp.at.debian.org sid/main libncursesw5 5.7+20090803-1 [379kB]                                                                                                                                                                                                                                              
Get:3 http://ftp.at.debian.org sid/main libnewt0.52 0.52.10-4 [67.8kB]                                                                                                                                                                                                                                                   
Get:4 http://ftp.at.debian.org sid/main libpopt0 1.14-4 [46.4kB]                                                                                                                                                                                                                                                         
Get:5 http://ftp.at.debian.org sid/main whiptail 0.52.10-4 [38.9kB]                                                                                                                                                                                                                                                      
Get:6 http://ftp.at.debian.org sid/main libgpm2 1.20.4-3.2 [35.0kB]                                                                                                                                                                                                                                                      
Get:7 http://ftp.at.debian.org sid/main dialog 1.1-20080819-1 [282kB]                                                                                                                                                                                                                                                    
Get:8 http://ftp.at.debian.org sid/main libfribidi0 0.10.9-1 [44.8kB]                                                                                                                                                                                                                                                    
[...]

# DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_NOWARNINGS=yes apt-get install grub2                                                                                                                                                                                                        
[...]
Get:1 http://ftp.at.debian.org sid/main ucf 3.0018 [64.3kB]                                                                                                                                                                                                                                                              
Get:2 http://ftp.at.debian.org sid/main libfreetype6 2.3.9-5 [408kB]                                                                                                                                                                                                                                                     
Get:3 http://ftp.at.debian.org sid/main grub-common 1.96+20090808-1 [1212kB]                                                                                                                                                                                                                                             
Get:4 http://ftp.at.debian.org sid/main grub-pc 1.96+20090808-1 [669kB]                                                                                                                                                                                                                                                  
Get:5 http://ftp.at.debian.org sid/main grub2 1.96+20090808-1 [184kB]                                                                                                                                                                                                                                                    
Fetched 2538kB in 8s (304kB/s)                                                                                                                                                                                                                                                                                           
Preconfiguring packages ...                                                                                                                                                                                                                                                                                              
Selecting previously deselected package ucf.                                                                                                                                                                                                                                                                             
(Reading database ... 6193 files and directories currently installed.)                                                                                                                                                                                                                                                   
Unpacking ucf (from .../archives/ucf_3.0018_all.deb) ...                                                                                                                                                                                                                                                                 
Moving old data out of the way                                                                                                                                                                                                                                                                                           
Selecting previously deselected package libfreetype6.                                                                                                                                                                                                                                                                    
Unpacking libfreetype6 (from .../libfreetype6_2.3.9-5_amd64.deb) ...                                                                                                                                                                                                                                                     
Selecting previously deselected package grub-common.                                                                                                                                                                                                                                                                     
Unpacking grub-common (from .../grub-common_1.96+20090808-1_amd64.deb) ...                                                                                                                                                                                                                                               
Selecting previously deselected package grub-pc.                                                                                                                                                                                                                                                                         
Unpacking grub-pc (from .../grub-pc_1.96+20090808-1_amd64.deb) ...                                                                                                                                                                                                                                                       
Selecting previously deselected package grub2.                                                                                                                                                                                                                                                                           
Unpacking grub2 (from .../grub2_1.96+20090808-1_amd64.deb) ...                                                                                                                                                                                                                                                           
Setting up ucf (3.0018) ...                                                                                                                                                                                                                                                                                              
Setting up libfreetype6 (2.3.9-5) ...                                                                                                                                                                                                                                                                                    
Setting up grub-common (1.96+20090808-1) ...                                                                                                                                                                                                                                                                             
Setting up grub-pc (1.96+20090808-1) ...                                                                                                                                                                                                                                                                                 

Creating config file /etc/default/grub with new version
grep: /etc/kernel-img.conf: No such file or directory
grub-probe: error: cannot find a device for /.

dpkg: error processing grub-pc (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of grub2:
 grub2 depends on grub-pc; however:
  Package grub-pc is not configured yet.
dpkg: error processing grub2 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 grub-pc
 grub2
E: Sub-process /usr/bin/dpkg returned an error code (1)

# sed -i s/^\#\!\\/.*/\&x/ /var/lib/dpkg/info/grub-pc.postinst

# apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Setting up grub-pc (1.96+20090808-1) ...
+ case "$1" in
+ . /usr/share/debconf/confmodule
++ '[' '!' '' ']'
++ PERL_DL_NONLAZY=1
++ export PERL_DL_NONLAZY
++ '[' '' ']'
++ exec /usr/share/debconf/frontend /var/lib/dpkg/info/grub-pc.postinst configure ''
+ case "$1" in
+ . /usr/share/debconf/confmodule
++ '[' '!' 1 ']'
++ '[' -z '' ']'
++ exec
++ '[' '' ']'
++ exec
++ DEBCONF_REDIR=1
++ export DEBCONF_REDIR
+ ucf --three-way --debconf-ok /usr/share/grub/default/grub /etc/default/grub
+ ucfr grub-pc /etc/default/grub
+ grep -q '[= ]/sbin/update-grub' /etc/kernel-img.conf
grep: /etc/kernel-img.conf: No such file or directory
+ mkdir -p /boot/grub
+ test -e /boot/grub/device.map
+ test -e /boot/grub/core.img
+ grub-mkdevicemap --no-floppy
+ db_get grub-pc/linux_cmdline
+ _db_cmd 'GET grub-pc/linux_cmdline'
+ IFS=' '
+ printf '%s\n' 'GET grub-pc/linux_cmdline'
+ IFS='
'
+ read -r _db_internal_line
+ RET=fillme
+ case ${_db_internal_line%%[   ]*} in
+ return 0
+ '[' fillme '!=' fillme ']'
+ test -e /boot/grub/stage2
++ grub-mkdevicemap -m -
++ sed -e '/^(fd[0-9]\+)/d;s,.*\t,,g'
++ tr '\n' ,
++ sed -e 's/,$//g;s/,/, /g'
+ db_subst grub-pc/install_devices CHOICES
+ _db_cmd 'SUBST grub-pc/install_devices' CHOICES
+ IFS=' '
+ printf '%s\n' 'SUBST grub-pc/install_devices CHOICES'
+ IFS='
'
+ read -r _db_internal_line
+ RET=0
+ case ${_db_internal_line%%[   ]*} in
+ return 0
+ db_input high grub-pc/install_devices
+ _db_cmd 'INPUT high' grub-pc/install_devices
+ IFS=' '
+ printf '%s\n' 'INPUT high grub-pc/install_devices'
+ IFS='
'
+ read -r _db_internal_line
+ RET='30 question skipped'
+ case ${_db_internal_line%%[   ]*} in
+ return 30
+ true
+ db_go
+ _db_cmd 'GO '
+ IFS=' '
+ printf '%s\n' 'GO '
+ IFS='
'
+ read -r _db_internal_line
+ RET=ok
+ case ${_db_internal_line%%[   ]*} in
+ return 0
+ db_get grub-pc/install_devices
+ _db_cmd 'GET grub-pc/install_devices'
+ IFS=' '
+ printf '%s\n' 'GET grub-pc/install_devices'
+ IFS='
'
+ read -r _db_internal_line
+ RET=
+ case ${_db_internal_line%%[   ]*} in
+ return 0
++ echo
++ sed -e 's/,/ /g'
+ touch /boot/grub/grub.cfg
+ for i in /usr/share/grub/ascii.pf2 /usr/share/images/desktop-base/moreblue-orbit-grub.png
+ test -e /usr/share/grub/ascii.pf2
+ cp /usr/share/grub/ascii.pf2 /boot/grub/
+ for i in /usr/share/grub/ascii.pf2 /usr/share/images/desktop-base/moreblue-orbit-grub.png
+ test -e /usr/share/images/desktop-base/moreblue-orbit-grub.png
+ test -e /boot/grub/grub.cfg
+ update-grub
grub-probe: error: cannot find a device for /.

dpkg: error processing grub-pc (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of grub2:
 grub2 depends on grub-pc; however:
  Package grub-pc is not configured yet.
dpkg: error processing grub2 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 grub-pc
 grub2
E: Sub-process /usr/bin/dpkg returned an error code (1)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grub-pc_dont-call-update-grub-in-chroot.diff
Type: text/x-patch
Size: 646 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-grub-devel/attachments/20090818/982a7d10/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.alioth.debian.org/pipermail/pkg-grub-devel/attachments/20090818/982a7d10/attachment.pgp>


More information about the Pkg-grub-devel mailing list