[Bug 653633] Re: live-media=<device> is no more supported in casper
phl
653633 at bugs.launchpad.net
Mon Oct 24 09:43:22 UTC 2011
Here is my udev based live-device recognition system. Diff from 10.10
release
--1----------------------------------------------------------------------------------------------------
EXTLINUX config :
kernel ../casper/vmlinuz1
append initrd=../casper/initramfs-USB-UDEV boot=casper livecasper-dev=udev=UUID=fc0e5af3-e635-4ef9-831d-0ea4f4e70a60 livehome-dev=udev=UUID=695d19b0-78d9-4dc3-ab3f-6f0cf2f315b4
------------------
/etc/udev/rules.d/61-casper-usb.rules:
# Used to make casper event driven instead of repeatedly scan all block devices
# With this rule finding live-media device is mainly udev's job
# Does not work when named 60-xxx.rules but does work whan named 61-xxx.rules
ENV{ID_USB_DRIVER}!="usb-storage", GOTO="end_usb-casper.rules"
ACTION!="add|change", GOTO="end_usb-casper.rules"
IMPORT{cmdline}="livecasper-dev=udev=UUID"
ENV{ID_FS_UUID}!="",\
PROGRAM=="/bin/sh -c 'test $env{livecasper-dev=udev=UUID}=$env{ID_FS_UUID}'",SYMLINK+=".livecasper"
IMPORT{cmdline}="livehome-dev=udev=UUID"
ENV{ID_FS_UUID}!="", \
PROGRAM=="/bin/sh -c 'test $env{livehome-dev=udev=UUID} = $env{ID_FS_UUID}'",SYMLINK+=".livehome"
--2---------------------------------------------------------------------------------------------------
--- casper_1.248_i386.deb.d/usr/share/initramfs-tools/scripts/casper 2010-09-16 01:34:18.000000000 +0200
+++ ~/usr/share/initramfs-tools/scripts/casper 2010-11-11 18:52:50.000000000 +0100
@@ -1,5 +1,10 @@
#!/bin/sh
+# make udev does most of the search
+# -1- livecasper-dev=udev=UUID
+# a) ln -s xxx /dev/.livecasper
+# b) ln -s yyy /dev/.livehome
+# -2- suppress snapshots
# set -e
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
@@ -31,7 +36,7 @@
parse_cmdline() {
for x in $(cat /proc/cmdline); do
- case $x in
+ case $x in
showmounts|show-cow)
export SHOWMOUNTS='Yes' ;;
persistent)
@@ -50,6 +55,28 @@
export STATICIP ;;
ignore_uuid)
IGNORE_UUID="Yes" ;;
+ livecasper-dev=*)
+ LIVE_CASPER_DEV="${x#livecasper-dev=}"
+ export LIVE_CASPER_DEV
+ echo "export LIVE_CASPER_DEV=\"$LIVE_CASPER_DEV\"" >> /etc/casper.conf
+ case ${LIVE_CASPER_DEV} in
+ udev=UUID=*)
+ LIVE_CASPER_UDEV_UUID="${LIVE_CASPER_DEV#udev=UUID=}"
+ export LIVE_CASPER_UDEV_UUID
+ echo "export LIVE_CASPER_UDEV_UUID=\"$LIVE_CASPER_UDEV_UUID\"" >> /etc/casper.conf ;;
+ esac
+ ;;
+ livehome-dev=*)
+ LIVE_HOME_DEV="${x#livehome-dev=}"
+ export LIVE_HOME_DEV
+ echo "export LIVE_HOME_DEV=\"$LIVE_HOME_DEV\"" >> /etc/casper.conf
+ case ${LIVE_HOME_DEV} in
+ udev=UUID=*)
+ LIVE_HOME_UDEV_UUID="${LIVE_HOME_DEV#udev=UUID=}"
+ export LIVE_HOME_UDEV_UUID
+ echo "export LIVE_HOME_UDEV_UUID=\"$LIVE_HOME_UDEV_UUID\"" >> /etc/casper.conf ;;
+ esac
+ ;;
live-media-path=*)
LIVE_MEDIA_PATH="${x#live-media-path=}"
export LIVE_MEDIA_PATH
@@ -295,7 +322,7 @@
}
try_snap ()
-{
+{ return 1
# Look for $snap_label.* in block devices and copy the contents to $snap_mount
# and remember the device and filename for resync on exit in casper.init
@@ -463,7 +490,7 @@
if [ -n "${SHOWMOUNTS}" ]; then
for d in ${rofslist}; do
mkdir -p "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}"
- case d in
+ case $d in
*.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}"
;;
*)
@@ -541,6 +568,12 @@
find_livefs() {
timeout="${1}"
# first look at the one specified in the command line
+ if [ ! -z "${LIVE_CASPER_UDEV_UUID}" ] ; then
+ livecasper_FROM_UDEV=$( readLinkWait .livecasper )
+ if check_dev "null" /dev/"${livecasper_FROM_UDEV}" "skip_uuid_check"; then
+ return 0
+ fi
+ fi
if [ ! -z "${LIVEMEDIA}" ]; then
if check_dev "null" "${LIVEMEDIA}" "skip_uuid_check"; then
return 0
--3----------------------------------------------------------------------------------------------------------------------
--- casper_1.248_i386.deb.d/usr/share/initramfs-tools/scripts/casper-helpers 2010-09-16 01:34:18.000000000 +0200
+++ ~/usr/share/initramfs-tools/scripts/casper-helpers 2010-11-11 20:46:32.000000000 +0100
@@ -1,5 +1,22 @@
## Casper helper functions, used by casper on boot and by casper-snapshot
+# readLinkWait
+# suppress ntfs
+
+# first, a short wait, just in case link is made by udev after first readlink but before first inotifywait
+
+readLinkWait() {
+ local link=/dev/$1
+ readlink $link || {
+ touch $link
+ inotifywait -qq -e ATTRIB --timeout 1 $link
+ readlink $link
+ } || {
+ inotifywait -qq -e ATTRIB --timeout 10 $link
+ readlink $link
+ }
+}
+
if [ "${BUILD_SYSTEM}" = "Debian" ] || [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then
MP_QUIET="-q"
else
@@ -182,6 +199,14 @@
find_cow_device() {
pers_label="${1}"
+ [ ${pers_label} = casper-rw ] && return 1
+
+ if [ ! -z "${LIVE_HOME_UDEV_UUID}" ] ; then
+ livehome_FROM_UDEV=$(readLinkWait .livehome)
+ echo /dev/"${livehome_FROM_UDEV}"
+ return
+ fi
+
cow_backing="/${pers_label}-backing"
if [ -z "${PERSISTENT_PATH}" ]; then
@@ -190,7 +215,7 @@
pers_fpath=${cow_backing}/${PERSISTENT_PATH}/${pers_label}
fi
- for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do
+ for sysblock in $(echo /sys/block/* | tr ' ' '\n' | egrep -v '/(loop|ram|sr|fd)'); do
for dev in $(subdevices "${sysblock}"); do
devname=$(sys2dev "${dev}")
if [ "$(/sbin/blkid -s LABEL -o value $devname 2>/dev/null)" = "${pers_label}" ]; then
---4 ---------------------------------------------------------------------------------------------------
--- casper_1.248_i386.deb.d/usr/share/initramfs-tools/hooks/casper 2010-09-16 01:34:18.000000000 +0200
+++ ~/usr/share/initramfs-tools/hooks/casper 2010-10-15 17:16:04.000000000 +0200
@@ -72,8 +74,8 @@
# integrity check
copy_exec /usr/lib/casper/casper-md5check /bin
-cp /usr/share/initramfs-tools/scripts/casper-functions $DESTDIR/scripts
-cp /usr/share/initramfs-tools/scripts/casper-helpers $DESTDIR/scripts
+#cp /usr/share/initramfs-tools/scripts/casper-functions $DESTDIR/scripts
+#cp /usr/share/initramfs-tools/scripts/casper-helpers $DESTDIR/scripts
auto_add_modules net
---------------------------------------------------------------------------------------------------------
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to casper in Ubuntu.
https://bugs.launchpad.net/bugs/653633
Title:
live-media=<device> is no more supported in casper
Status in “casper” package in Ubuntu:
Won't Fix
Bug description:
Binary package hint: casper
From Changelog:
casper (1.77+debian-1) unstable; urgency=low
+
+ ......
+ * Added boot parameter "live-media=<device>" to force trying to boot from
+ a specified device.
From man casper (casper_1.246_i386.deb)
{live-media|bootfrom}=DEVICE
If you specify one of this two equivalent forms, casper will first try to find this device for the "/casper" directory where the read-only root filesystem should reside. If it did not find something usable, the normal scan for block devices is performed.
But from some time ago, this feature has disappeared.
In /usr/share/initramfs-tools/scripts/casper, in the function
parse_cmdline ()
{
PRESEEDS=
# looking for casper specifics options as kernel parameters
for x in $(cat /proc/cmdline); do
case $x in
these two lines are no more here
bootfrom=*|live-media=*)
export LIVEMEDIA=${x#*=} ;;
But it seems that support for this feature still exists partially:
find_livefs() {
timeout="${1}"
# first look at the one specified in the command line
if [ ! -z "${LIVEMEDIA}" ]; then
if check_dev "null" "${LIVEMEDIA}" "skip_uuid_check"; then
return 0
fi
fi
# don't start autodetection before timeout has expired
if [ -n "${LIVEMEDIA_TIMEOUT}" ]; then
Actually, more often, this interesting feature never worked well
because the misplaced timeout make the only one try to use
${LIVEMEDIA} too early, before USB are ready, so few people noticed
its disappearance.
I suggest restoring parse_cmdline () and moving check_dev "null"
"${LIVEMEDIA}" after time-out
Ph.L.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/casper/+bug/653633/+subscriptions
More information about the foundations-bugs
mailing list