[arch-releng] Improve image detection on boot time
These two patches make image detection faster and less error-prone. Depending on a unique file system label, the /dev/archiso device is generated and archiso uses mkinitcpio's poll_device to wait for it.
--- archiso/hooks/archiso | 67 +++++++++++++------------------------------ archiso/hooks/archiso-early | 8 ++-- 2 files changed, 24 insertions(+), 51 deletions(-) diff --git a/archiso/hooks/archiso b/archiso/hooks/archiso index d779478..688a880 100644 --- a/archiso/hooks/archiso +++ b/archiso/hooks/archiso @@ -50,61 +50,34 @@ run_hook () ramdisk_size="75%" fi msg -n ":: Mounting tmpfs, size=${ramdisk_size}..." - mount -t tmpfs -o "size=${ramdisk_size}" tmpfs /tmpfs + mount -t tmpfs -o "size=${ramdisk_size}" tmpfs /tmpfs msg "done." - # external drives may need to settle - msg ":: Waiting for devices to settle..." - /sbin/udevadm trigger --subsystem-match=usb - /sbin/udevadm settle - usbdelay=$(( ${usbdelay:-0} + 1 )) - msg ":: Waiting ${usbdelay}s for USB devices" - /bin/sleep "${usbdelay}" - - msg ":: Scanning for boot device..." + msg ":: Waiting for boot device..." /bin/mkdir -p /bootmnt - found=0 - - /bin/modprobe -q isofs >/dev/null 2>&1 - msg ":: Scanning cd drives..." - for cdrom in /dev/hd[a-z] /dev/sr[0-9]* /dev/scd[a-z] /dev/sg[0-9]*; do - [ ! -e "${cdrom}" ] && continue - if mount -r -t iso9660 "${cdrom}" /bootmnt >/dev/null 2>&1; then - if [ -e "/bootmnt/isomounts" ]; then - found=1 - msg "${cdrom}" - break - fi - else - echo "Failed to mount ${cdrom}" - fi - [ ${found} -eq 0 ] && umount /bootmnt >/dev/null 2>&1 + while ! poll_device /dev/archiso 30; do + echo "ERROR: boot device didn't show up after 30 seconds..." + echo " Falling back to interactive prompt" + echo " You can try to fix the problem manually, log out when you are finished" + PS1="ramfs$ " /bin/sh -i done - if [ ${found} -eq 0 ]; then - msg ":: Scanning usb drives..." - for usb in /dev/sd[a-z][0-9]; do - [ ! -e "${usb}" ] && continue - if mount -r -t vfat "${usb}" /bootmnt >/dev/null 2>&1 ||\ - mount -r -t ext2 "${usb}" /bootmnt >/dev/null 2>&1; then - if [ -e "/bootmnt/isomounts" ]; then - found=1 - msg "${usb}" - break - fi - else - echo "Failed to mount ${usb}" - fi - [ ${found} -eq 0 ] && umount /bootmnt >/dev/null 2>&1 - done - fi - - if [ ${found} -eq 0 ]; then - echo "ERROR: cannot find boot device, cannot continue..." - echo " Falling back to interactive prompt" - PS1="ramfs$ " /bin/sh -i + eval $(fstype < /dev/archiso 2>/dev/null) + if [ -n "${FSTYPE}" -a "${FSTYPE}" != "unknown" ]; then + if mount -r -t "${FSTYPE}" /dev/archiso /bootmnt >/dev/null 2>&1; then + if [ -e "/bootmnt/isomounts" ]; then + echo "SUCCESS: Mounted archiso volume successfully." + else + echo "ERROR: Mounting was successful, but the isomounts file does not exist." + exit 1 + fi + else + echo "ERROR: Failed to mount /dev/archiso" exit 1 + fi + else + echo "ERROR: /dev/archiso found, but the filesystem type is unknown." fi /bin/modprobe -q squashfs >/dev/null 2>&1 diff --git a/archiso/hooks/archiso-early b/archiso/hooks/archiso-early index 884c4be..d57b73b 100644 --- a/archiso/hooks/archiso-early +++ b/archiso/hooks/archiso-early @@ -1,8 +1,8 @@ # vim: set ft=sh: run_hook () { - # Set our usbdelay time. Default: 0 - cd / - /bin/mkdir -p etc/modprobe.d/ - echo "options usb-storage delay_use=${usbdelay:-0}" > /etc/modprobe.d/usb-delay + if [ -n "${archisolabel}" ]; then + echo "ACTION==\"add|change\", SUBSYSTEM==\"block\", IMPORT{program}=\"vol_id --export \$tempnode\"" > /lib/udev/rules.d/00-archiso-device.rules + echo "ENV{ID_FS_LABEL_ENC}==\"${archisolabel}\", SYMLINK+=\"archiso\"" >> /lib/udev/rules.d/00-archiso-device.rules + fi } -- 1.6.3.3
--- archiso/mkarchiso | 7 ++++++- configs/install-iso/Makefile | 4 ++-- configs/install-iso/boot-files/grub/menu.lst | 4 ++-- .../install-iso/boot-files/isolinux/isolinux.cfg | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/archiso/mkarchiso b/archiso/mkarchiso index 530403c..9d2dd30 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -214,6 +214,10 @@ _imgcommon () { fi cp "${work_dir}/isomounts" "${work_dir}/iso/" + + export LABEL="ARCHISO_$(pwgen -n 8 1 | tr [a-z] [A-Z])" + [ -f ${work_dir}/iso/boot/grub/menu.lst ] && sed "s|archisolabel=[^ ]*|archisolabel=${LABEL}|" -i ${work_dir}/iso/boot/grub/menu.lst + [ -f ${work_dir}/iso/boot/isolinux/isolinux.cfg ] && sed "s|archisolabel=[^ ]*|archisolabel=${LABEL}|" -i ${work_dir}/iso/boot/isolinux/isolinux.cfg } command_iso () { @@ -251,6 +255,7 @@ command_iso () { -no-emul-boot -boot-load-size 4 -boot-info-table \ -publisher "Arch Linux <http://www.archlinux.org>" \ -A "Arch Linux Live/Rescue CD" \ + -V "${LABEL}" \ -o "${imgname}" "${work_dir}/iso/" } @@ -267,7 +272,7 @@ command_usb () { dd if=/dev/zero of="$fsimg" bs=512 count="$imgsz" # create a filesystem on the image - mke2fs -m 0 -F "$fsimg" + mke2fs -m 0 -F -L "${LABEL}" "$fsimg" # mount the filesystem and copy data modprobe loop diff --git a/configs/install-iso/Makefile b/configs/install-iso/Makefile index 77ed056..fbac10e 100644 --- a/configs/install-iso/Makefile +++ b/configs/install-iso/Makefile @@ -43,8 +43,8 @@ base-iso: root-image cp isomounts $(WORKDIR) sed -i "s|@ARCH@|$(ARCH)|g" "$(WORKDIR)/isomounts" - mkinitcpio -c initcpio-ide -b $(WORKDIR)/root-image -k $(kver) -g $(WORKDIR)/iso/boot/archiso_ide.img - mkinitcpio -c initcpio-pata -b $(WORKDIR)/root-image -k $(kver) -g $(WORKDIR)/iso/boot/archiso_pata.img + mkinitcpio -c ./initcpio-ide -b $(WORKDIR)/root-image -k $(kver) -g $(WORKDIR)/iso/boot/archiso_ide.img + mkinitcpio -c ./initcpio-pata -b $(WORKDIR)/root-image -k $(kver) -g $(WORKDIR)/iso/boot/archiso_pata.img core-pkgs: base-iso mkdir $(WORKDIR)/core-pkgs/ diff --git a/configs/install-iso/boot-files/grub/menu.lst b/configs/install-iso/boot-files/grub/menu.lst index fd5a4bc..41a72f9 100644 --- a/configs/install-iso/boot-files/grub/menu.lst +++ b/configs/install-iso/boot-files/grub/menu.lst @@ -4,11 +4,11 @@ color light-blue/blue black/light-grey splashimage=/boot/splash.xpm.gz title Boot Arch Linux Live CD -kernel /boot/vmlinuz26 lang=en locale=en_US.UTF-8 usbdelay=5 ramdisk_size=75% +kernel /boot/vmlinuz26 lang=en locale=en_US.UTF-8 archisolabel=XXX ramdisk_size=75% initrd /boot/archiso_pata.img title Boot Arch Linux Live CD [Legacy IDE, no SATA] -kernel /boot/vmlinuz26 lang=en locale=en_US.UTF-8 usbdelay=5 ramdisk_size=75% +kernel /boot/vmlinuz26 lang=en locale=en_US.UTF-8 archisolabel=XXX ramdisk_size=75% initrd /boot/archiso_ide.img title Release Notes diff --git a/configs/install-iso/boot-files/isolinux/isolinux.cfg b/configs/install-iso/boot-files/isolinux/isolinux.cfg index d9e5084..793271e 100644 --- a/configs/install-iso/boot-files/isolinux/isolinux.cfg +++ b/configs/install-iso/boot-files/isolinux/isolinux.cfg @@ -8,11 +8,11 @@ DEFAULT arch LABEL arch KERNEL /boot/vmlinuz26 -APPEND lang=en locale=en_US.UTF-8 usbdelay=5 ramdisk_size=75% initrd=/boot/archiso_pata.img +APPEND lang=en locale=en_US.UTF-8 archisolabel=XXX ramdisk_size=75% initrd=/boot/archiso_pata.img LABEL archide KERNEL /boot/vmlinuz26 -APPEND lang=en locale=en_US.UTF-8 usbdelay=5 ramdisk_size=75% initrd=/boot/archiso_ide.img +APPEND lang=en locale=en_US.UTF-8 archisolabel=XXX ramdisk_size=75% initrd=/boot/archiso_ide.img LABEL memtest KERNEL /boot/memtest -- 1.6.3.3
Thomas Bächler schrieb:
These two patches make image detection faster and less error-prone. Depending on a unique file system label, the /dev/archiso device is generated and archiso uses mkinitcpio's poll_device to wait for it.
Hmm, seems like git send-email screwed this up, I'll look at it again tomorrow.
Thomas Bächler schrieb:
These two patches make image detection faster and less error-prone. Depending on a unique file system label, the /dev/archiso device is generated and archiso uses mkinitcpio's poll_device to wait for it.
Okay, my mails show up in the archive (subject screwed up), but I didn't get them on the mailing list. Did you get them?
Am Samstag, den 25.07.2009, 11:37 +0200 schrieb Thomas Bächler:
Thomas Bächler schrieb:
These two patches make image detection faster and less error-prone. Depending on a unique file system label, the /dev/archiso device is generated and archiso uses mkinitcpio's poll_device to wait for it.
Okay, my mails show up in the archive (subject screwed up), but I didn't get them on the mailing list. Did you get them?
Yes, i'm currently testing... (First ISO boots fine, i wonder why the generated label is only "ARCHISO_", then i saw that i have no pwgen on my machine ;-) Something for the depends of archiso PKGBUILD... But the build iso boots fine with ARCHISO_ label... Now i make both a ISO and a usb image... Gerhard
Gerhard Brauer schrieb:
Yes, i'm currently testing... (First ISO boots fine, i wonder why the generated label is only "ARCHISO_", then i saw that i have no pwgen on my machine ;-) Something for the depends of archiso PKGBUILD... But the build iso boots fine with ARCHISO_ label...
pwgen was the easiest way, install extra/pwgen.
Am Samstag, den 25.07.2009, 11:50 +0200 schrieb Thomas Bächler:
Gerhard Brauer schrieb:
Yes, i'm currently testing... (First ISO boots fine, i wonder why the generated label is only "ARCHISO_", then i saw that i have no pwgen on my machine ;-) Something for the depends of archiso PKGBUILD... But the build iso boots fine with ARCHISO_ label...
pwgen was the easiest way, install extra/pwgen.
Yes, i know ;-) Ok, ISO build and boots fine in virtualbox. I test now the usb image, have to reboot... Something to discuss (Thomas and myself are not common here): The patch from Thomas use a absolut unique label on each ISO/Img build. His argument was: We must make absolut sure that only the archiso image gets mounted/detected. The pwgen methode has rhe advantage that realy each image (i686,x86_64, core/netinstall, grub/isolinux has it's own label. My argument is: We don't need a pwgen generated label, IMHO it's enough to label the images by the current snapshot version, ex: ARCHISO-2009.08 This also has the clue that the image is nice identified if automounted on normal system or whatever... Maybe (not sure, not tested) we have a problem if user has 2 CDs or CD and USB-Stick in PC during boot, but IMHO this is absolute rare... I don't want this a long discussion, Thomas patch works and i could live with... Gerhard
Am Samstag, den 25.07.2009, 12:06 +0200 schrieb Gerhard Brauer:
Ok, ISO build and boots fine in virtualbox. I test now the usb image, have to reboot...
Ok, USB image also is fine... Gerhard
On Sat, 25 Jul 2009 11:37:00 +0200 Thomas Bächler <thomas@archlinux.org> wrote:
Thomas Bächler schrieb:
These two patches make image detection faster and less error-prone. Depending on a unique file system label, the /dev/archiso device is generated and archiso uses mkinitcpio's poll_device to wait for it.
Okay, my mails show up in the archive (subject screwed up), but I didn't get them on the mailing list. Did you get them?
I got them. Dieter
participants (3)
-
Dieter Plaetinck
-
Gerhard Brauer
-
Thomas Bächler