[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#847166: debian-installer: preseed fails from hd-media



Package: debian-installer
Severity: normal
Tags: d-i

Dear Maintainer,

The installer fails to detect the second usb flash drive with preseed file and
mount it to /media/ (both in Stretch and in Jessie).

My plan was to burn debian official image to one usb flash drive,
and put preseed.cfg to another one. Then it was necessary to tell the installer
which one of the three /dev/sd* drives is the hard drive on the PC (the order
of detection is dynamic, hence it is not guaranteed that the hard drive will
always be /dev/sda). For this I used the following d-i setting in preseed.cfg:

d-i partman/early_command string \
  USBDEV=$(mount | grep cdrom | cut -d" " -f1 | sed "s/\(.*\)./\1/"); \
  mount >> /var/log/syslog; \
  for MYDEV in $(list-devices disk | grep -v "$USBDEV"); do \
    mount $MYDEV /mnt/; \
    [ -e /mnt/preseed.cfg ] && AUXDEV=$MYDEV; \
    umount /mnt/; \
  done; \
  BOOTDEV=$(list-devices disk | grep -v "$USBDEV" | grep -v "$AUXDEV" | head -n1); \
  echo $USBDEV $AUXDEV $BOOTDEV >> /var/log/syslog; \
  debconf-set partman-auto/disk $BOOTDEV; \
  debconf-set grub-installer/bootdev $BOOTDEV

This is what this "early_command" does:
1) detect which device is the installation media (using the fact that it is
   mounted to /cdrom)
2) loop through the rest of the disk devices and check which one contains
   file preseed.cfg in the root directory
3) then exclude the media with preseed.cfg and the installation media from the
   list of all disk devices, and take the first one from what is rest - this
   will be the hard drive to use for installation
4) use debconf-set to set the hard drive for the installer

Then I downloaded latest (2016-11-28) debian testing image from

    http://cdimage.debian.org/cdimage/weekly-builds/amd64/jigdo-dvd/debian-testing-amd64-DVD-1.jigdo

and burned to usb flash with

    dd if=debian-testing-amd64-DVD-1.iso of=/dev/sdb bs=4M; sync

Then I put preseed.cfg to root directory of another usb flash (vfat),
inserted both flash drives to the PC, booted from debian flash and in boot menu
pressed TAB (on "Graphical install" menu option). Then I added
file=/hd-media/preseed.cfg as said in the documentation[1], and also I added
auto=true in order that answers to keyboard and locale questions will be taken
from preseed.cfg instead of being asked interactively. Preseed file contains
answers to all the questions so that install will be fully automatic
(see attachment). So, the following was added before "--- quiet" in the kernel
boot parameters, leaving the default parameters untouched:

    auto=true file=/hd-media/preseed.cfg

Then I pressed ENTER.

After a while an error appeared (see preseed_retrieve_error_0.png in the attachment)
It said that file:///hd-media/preseed.cfg could not be retrieved.

Then I switched to second console (Ctrl+Alt+F2) and issued "mount" command.
This is its output:

rootfs on / type rootfs (rw,size=1916196k,nr_inodes=234575)
none on /run type tmpfs (rw,nosuid,relatime,size=191620k,mode=755)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=938312k,nr_inodes=234578,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/sdb1 on /cdrom type iso9660 (ro,relatime)
/dev/sdb2 on /media type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)

We see that in Stretch second partition on installation media is mounted to /media/.
It contains the following:

    ~ # ls /media
    efi

Now let's see which disk devices are in the system:

    ~ # ls /dev/sd*
    /dev/sda /dev/sda1 /dev/sda2 /dev/sda5 /dev/sdb /dev/sdb1 /dev/sdb2 /dev/sdc /dev/sdc1

Considering the output of "mount", it is clear, that the media with
preseed.cfg is /dev/sdc1. Let's try to mount it and ensure:

    ~ # mount /dev/sdc1 /mnt
    ~ # ls /mnt
    preseed.cfg

Then out of curiosity I decided to take the same preseed.cfg and carry out
the same steps for the latest stable release (jessie 8.6.0 amd64).

So, I added the same line before "--- quiet" in the kernel boot parameters.
The installation failed with the same error message. The output of "mount" command
in Jessie is:

rootfs on / type rootfs (rw,size=1920360k,nr_inodes=236631)
none on /run type tmpfs (rw,nosuid,relatime,size=192036k,mode=755)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=946536k,nr_inodes=236634,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/sdb1 on /cdrom type iso9660 (ro,relatime)
/dev/sdb1 on /media type iso9660 (ro,relatime)

Notice, that in Jessie the installation media is mounted twice - to /cdrom/ and
to /media/.

Now let's see which disk devices are in the system:

    ~ # ls /dev/sd*
    /dev/sda /dev/sda1 /dev/sda2 /dev/sda5 /dev/sdb /dev/sdb1 /dev/sdb2 /dev/sdc /dev/sdc1

The devices are the same as with Stretch.
Let's try to mount /dev/sdc1 and ensure that preseed.cfg is there:

    ~ # mount /dev/sdc1 /mnt
    ~ # ls /mnt
    preseed.cfg

To sum it up, both in Stretch and in Jessie the second usb flash drive is
visible from the installer, but it is not detected and not mounted to /media/.
Moreover, the devices which are mounted to /media/ are detected incorrectly.

Cursory investigation suggests that the bug is lurking in one of the following
files from debian-installer sources:

debian-installer/packages/iso-scan/debian/iso-scan.postinst
debian-installer/packages/apt-setup/load-install-cd
debian-installer/packages/preseed/debian/file-preseed.postinst
debian-installer/packages/preseed/preseed.sh
debian-installer/packages/hw-detect/driver-injection-disk.sh
debian-installer/packages/cdrom-detect/debian/cdrom-detect.postinst

In these source files only iso9660 filesystems are scanned. So, I decided to
create iso image with only one file - preseed.cfg, and burn it to the second usb
drive.

In the output of "mount" commands above there is no /hd-media/. Why the
documentation[1] says to use "file=/hd-media/..." then?
But there is /media/. So, I decided to try with file=/media/preseed.cfg

So, I came up with the following commands:

    $ mkdir iso
    $ cp preseed.cfg iso/
    $ genisoimage -o preseed.iso iso/
    $ dd if=preseed.iso of=/dev/sdb; sync

Then I inserted the usb flash with debian and the usb flash with preseed.iso
and powered on the PC. In the boot menu I did everything the same as above,
but instead of file=/hd-media/preseed.cfg I used file=/media/preseed.cfg
This time the installer did not fail with preseed retrieve error, which means
that preseed media with iso9660 filesystem was detected and mounted correctly
to /media/ (both in Stretch and in Jessie).
This time the system was successfully installed with this preseed file without
any errors and without asking any questions (both for Stretch and for Jessie).

As we see, this is a problem that usb flash drive with filesystem different from
iso9660 is not detected correctly by the installer (both in Stretch and in
Jessie).

But there is one more problem: /cdrom/ is available in /target/ in late_command,
but /media/ is not. This is a problem, because I cannot put additional files
to the second usb flash drive and use them in postinst.sh script, which
is started via in-target in late_command. To demonstrate the problem, I put the
following to preseed.cfg:

d-i preseed/late_command string \
  echo ------------ >> /var/log/syslog; \
  mount >> /var/log/syslog; \
  echo ------------ >> /var/log/syslog; \
  in-target mount >> /var/log/syslog; \
  echo ------------ >> /var/log/syslog

After Stretch is installed by the procedure described above, we can find the
output from the above commands in /var/log/installer/syslog:

------------
rootfs on / type rootfs (rw,size=1916196k,nr_inodes=234575)
none on /run type tmpfs (rw,nosuid,relatime,size=191620k,mode=755)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=938312k,nr_inodes=234578,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/sdb1 on /cdrom type iso9660 (ro,relatime)
/dev/sda1 on /target type ext4 (rw,relatime,errors=remount-ro,data=ordered)
/dev/sda1 on /dev/.static/dev type ext4 (rw,relatime,errors=remount-ro,data=ordered)
devtmpfs on /target/dev type devtmpfs (rw,relatime,size=938312k,nr_inodes=234578,mode=755)
/dev/sdb1 on /target/media/cdrom0 type iso9660 (ro,relatime)
------------
Dec  6 06:10:52 in-target: /dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
Dec  6 06:10:52 in-target: devtmpfs on /dev type devtmpfs (rw,relatime,size=938312k,nr_inodes=234578,mode=755)
Dec  6 06:10:52 in-target: /dev/sdb1 on /media/cdrom0 type iso9660 (ro,relatime)
Dec  6 06:10:52 in-target: proc on /proc type proc (rw,relatime)
Dec  6 06:10:52 in-target: sysfs on /sys type sysfs (rw,relatime)
Dec  6 06:10:52 in-target: devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
Dec  6 06:10:52 in-target: none on /run type tmpfs (rw,nosuid,relatime,size=191620k,mode=755)
------------

For Jessie the output is:

------------
rootfs on / type rootfs (rw,size=1920360k,nr_inodes=236631)
none on /run type tmpfs (rw,nosuid,relatime,size=192036k,mode=755)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=946536k,nr_inodes=236634,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/sdb1 on /cdrom type iso9660 (ro,relatime)
/dev/sda1 on /target type ext4 (rw,relatime,errors=remount-ro,data=ordered)
/dev/sda1 on /dev/.static/dev type ext4 (rw,relatime,errors=remount-ro,data=ordered)
devtmpfs on /target/dev type devtmpfs (rw,relatime,size=946536k,nr_inodes=236634,mode=755)
/dev/sdb1 on /target/media/cdrom0 type iso9660 (ro,relatime)
------------
Dec  6 06:52:33 in-target: /dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
Dec  6 06:52:33 in-target: devtmpfs on /dev type devtmpfs (rw,relatime,size=946536k,nr_inodes=236634,mode=755)
Dec  6 06:52:33 in-target: /dev/sdb1 on /media/cdrom0 type iso9660 (ro,relatime)
Dec  6 06:52:33 in-target: proc on /proc type proc (rw,relatime)
Dec  6 06:52:33 in-target: sysfs on /sys type sysfs (rw,relatime)
Dec  6 06:52:33 in-target: devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
Dec  6 06:52:33 in-target: none on /run type tmpfs (rw,nosuid,relatime,size=192036k,mode=755)
------------

As we see, in Stretch and in Jessie installation media (/dev/sdb1) is mounted to
/cdrom in installer and to /media/cdrom0 in target system. But the usb flash
drive with preseed.cfg, which was detected and correctly mounted to /media
(because the preseeded installation was successful) is not mounted neither in
installer nor in target system.

Is it worth to create a separate bug report about it?

Let me ask you a couple of questions related to the topic:

Is it possible to use something like the following commands in late_command to
use local repository from the second usb flash drive in target system?

  mount -o bind /media/my-local-repo /target/var/my-local-repo; \
  echo "deb file:///var/ my-local-repo/" >> /target/etc/apt/sources.list; \
  in-target apt-get update; \
  in-target apt-get install mytool; \

Is it OK to use something like the following commands for creating the local
repo on the second usb flash drive?

  sudo mkdir /var/my-local-repo
  <copy necessary *.deb files to /var/my-local-repo>
  sudo dpkg-scanpackages /var/my-local-repo /dev/null > /var/my-local-repo/Packages
  cp -r /var/my-local-repo/ /media/user/PRESEED_DISK/


[1]: https://www.debian.org/releases/stretch/i386/apbs02.html.en

-- System Information:
Debian Release: stretch/sid
Architecture: amd64 (x86_64)

Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Attachment: preseed_retrieve_error_0.png
Description: PNG image

## Locales
d-i debian-installer/language string en
d-i localechooser/supported-locales multiselect en_US.UTF-8, ru_RU.UTF-8
d-i debian-installer/country string US
d-i keyboard-configuration/xkb-keymap select us
# If you want the preconfiguration file to work on systems both with and
# without a dhcp server, uncomment these lines and the static network
# configuration below.
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
## Static network configuration.
# IPv4 example
d-i netcfg/get_ipaddress string 192.168.0.100
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string 192.168.0.1
d-i netcfg/get_nameservers string 8.8.8.8
d-i netcfg/confirm_static boolean true
## for the hostname nor the domain
# <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=755848>
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/choose_interface select auto
d-i netcfg/hostname string debian
d-i netcfg/domain string test
## Account setup
d-i passwd/root-login boolean false
d-i passwd/user-fullname string user
d-i passwd/username string user
d-i passwd/user-password password 1
d-i passwd/user-password-again password 1
d-i user-setup/encrypt-home boolean false
d-i user-setup/allow-password-weak boolean true

d-i	hw-detect/load_firmware	boolean	false
## Clock and time zone setup
d-i clock-setup/utc boolean true
d-i time/zone string Asia/Krasnoyarsk
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string 0.us.pool.ntp.org
## Partitioning
#d-i partman/early_command string mount >> /var/log/mylog
# Detect hard drive on the PC:
d-i partman/early_command string \
  USBDEV=$(mount | grep cdrom | cut -d" " -f1 | sed "s/\(.*\)./\1/"); \
  for MYDEV in $(list-devices disk | grep -v "$USBDEV"); do \
    mount $MYDEV /mnt/; \
    [ -e /mnt/preseed.cfg ] && AUXDEV=$MYDEV; \
    umount /mnt/; \
  done; \
  BOOTDEV=$(list-devices disk | grep -v "$USBDEV" | grep -v "$AUXDEV" | head -n1); \
  echo $USBDEV $AUXDEV $BOOTDEV >> /var/log/syslog; \
  mount >> /var/log/syslog; \
  debconf-set partman-auto/disk $BOOTDEV; \
  debconf-set grub-installer/bootdev $BOOTDEV
d-i partman-auto/method string regular
d-i partman/choose_partition select finish
d-i partman-auto/choose_recipe select atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
## Scan another CD or DVD?
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
# Apt setup
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true
d-i apt-setup/use_mirror boolean true
# Package mirror
d-i mirror/country string manual
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
d-i apt-setup/use_mirror boolean true
# Additional repositories, local[0-9] available
# Add the following line to your /etc/apt/sources.list
d-i apt-setup/local0/repository string deb http://httpredir.debian.org/debian/ jessie main contrib non-free
d-i apt-setup/local0/repository string deb http://httpredir.debian.org/debian/ jessie-updates main contrib non-free
d-i apt-setup/local0/source boolean true
popularity-contest popularity-contest/participate boolean true
# Package selection
tasksel tasksel/first multiselect standard, ssh-server, mate-desktop 
d-i pkgsel/upgrade select full-upgrade
# Automatically install grub to the MBR
d-i grub-installer/only_debian boolean true
# Turn off last message about the install being complete
d-i finish-install/reboot_in_progress note

Reply to: