[Bug 1489855] Re: Change to mount sequence order breaks persistence on casper-rw partitions

Akeo pete at akeo.ie
Fri Apr 19 18:04:05 UTC 2019


This is a pretty serious and rather obvious bug, once you understand
what's going on.

As pointed out by @DC-THINK, whom I will mostly be paraphrasing here,
the gist of it is: /usr/share/initramfs-tools/scripts/casper-helpers may
unmount a previously mounted device, that it should *NOT* leave
unmounted on exit.

The following is an alternate description of what happens, so that it
may helps dev assess the seriousness of the issue:

For this example, I will assume that you have extracted the installation
media on a vfat image (say /dev/sdb1). It actually doesn't matter if you
actually have a persistent partition or not, as it will fail even with a
single vfat partition (which I tested with GPT/FAT32 single partition
drive and ubuntu-19.04-desktop-amd64.iso after adding 'persistent' to
the "Try Ubuntu without installing" in grub.cfg:

1. /dev/sdb1 is *ALREADY mounted (as /cdrom) when we enter find_cow_device(), as it was mounted during the init process.
2. As we are processing all (non floppy) block devices, we start processing /dev/sdb*, and therefore start to look at /dev/sdb1.
3. Because we are processing the vfat partition, we don't find label 'casper-rw', so we proceed to look for a 'casper-rw' file.
4. To look for that file, the first thing that the script issues is 'try_mount' which succeeds at remounting /dev/sdb1 "rw".
5. We now look for a 'casper-rw' on the newly mounted /dev/sdb1, and don't find it, since it doesn't exist.
6. [HERE IS THE BUG] /dev/sdb1 is now **UNCONDITIONALLY** unmounted... instead of being remounted to the mountpoint it was using (/cdrom) when we entered the function call.
7. Because /cdrom has become unavailable, all kind of bad things happen, starting with the casper script complaining...

In other words, the bug is: find_cow_device() can and DOES unmount
legitimate devices it has no business of unmounting.

Ergo, find_cow_device() must be fixed, possibly by keeping history of
already mounted devices in try_mount() and using a new restore_mount()
call instead of the unconditional umount currently used.

Alternatively, try_mount device should not degrade write access (i.e. it
may do ro -> rw but not rw -> ro) and optionally return the existing
mountpoint of an already mounted devices, so that find_cow_device() can
determine if it should umount the device or not.

Hope this helps. Note that this bug is indeed very problematic for
Windows users, and will become even more so as the current Windows
recommended tool for Ubuntu installtion media (Rufus) is about to
introduce persistent partition [Disclaimer: I am the author of Rufus].

-- 
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/1489855

Title:
  Change to mount sequence order breaks persistence on casper-rw
  partitions

Status in casper package in Ubuntu:
  Confirmed

Bug description:
  the system boots fine when using a casper-rw FILE but drops to a
  busybox when using a partition

  
  the short log would be:
  ___________________________________________________
  Begin: Running /scripts/casper-premount ... done.
  done.
  umount: can't umount /cdrom: Device or resource busy
  Warning: Unable to find the persistent home medium
  umount: can't umount /cdrom: Device or resource busy
  Warning: Impossible to include the casper-sn Snapshot
  umount: can't umount /cdrom: Device or resource busy
  Warning: Impossible to include the home-sn Snapshot
  done.
  ___________________________________________________

  removing the "persistence" keyword from the syslinux.cfg works and the live usb drive boots just fine.
  using a persistence file instead of the partition and the usb drive boots just fine.

  i found older bug reports concerning the same problem but the fix
  proposed in 2010 is already integrated into the script "casper".

  so i started the flashdrive with the casper debug= option and i see
  the following (after probing several other devices it finally finds
  the right device and partition (sdb3)

  ___________________________________________________

  + cow_backing_mp=/cdrom
  + [ -e /cdrom/casper-rw ]
  + umount /cdrom
  + sys2dev /sys/block/sdb/sdb3
  + sysdev=/block/sdb/sdb3
  + udevadm info -q name -p /block/sdb/sdb3
  + echo /dev/sdb3
  + devname=/dev/sdb3
  + /sbin/blkid -s LABEL -o value /dev/sdb3
  + [ casper-rw = casper-rw ]
  + echo /dev/sdb3
  + return
  + cowprobe=/dev/sdb3
  + [ -b /dev/sdb3 ]
  + cowdevice=/dev/sdb3
  + get_fstype /dev/sdb3
  + local FSTYPE
  + local FSSIZE
  + fstype
  + eval FSTYPE=ext4 FSSIZE=8458862592
  + FSTYPE=ext4 FSSIZE=8458862592
  + [ ext4 != unknown ]
  + echo ext4
  + return 0
  + cow_fstype=ext4
  + cow_mountopt=rw,noatime
  + mount -t ext4 -o rw,noatime /dev/sdb3 /cow
  + [ ! -d /cow/upper ]
  + mkdir -p /cow/upper
  + continue
  + continue
  + mkdir -p /cow/work
  + [ -f /cow/format ]
  + [ DEFAULT = DEFAULT ]
  + modprobe -q -b overlay
  + grep -q ^overlay$
  + cut -f2 /proc/filesystems
  + UNIONFS=overlay
  + break
  ___________________________________________________

  this looks fine to me.. it looks like it recognizes everything .. it's
  ext4 .. label casper-rw.. it's mounting it...

  a little bit further down in the loooong log file it states the
  following:

  ______________________________________________

  + cow_backing_mp=/home-rw-backing
  + [ -e /home-rw-backing/home-rw ]
  + umount /home-rw-backing
  + sys2dev /sys/block/sdb/sdb3
  + sysdev=/block/sdb/sdb3
  + udevadm info -q name -p /block/sdb/sdb3
  + echo /dev/sdb3
  + devname=/dev/sdb3
  + /sbin/blkid -s LABEL -o value /dev/sdb3
  + [ casper-rw = home-rw ]
  + get_fstype /dev/sdb3
  + local FSTYPE
  + local FSSIZE
  + fstype
  + eval FSTYPE=ext4 FSSIZE=8458862592
  + FSTYPE=ext4 FSSIZE=8458862592
  + [ ext4 != unknown ]
  + echo ext4
  + return 0
  + [ ext4 = vfat ]
  + homecow=
  + [ -b ]
  + [ n != y ]
  + log_warning_msg Unable to find the persistent home medium
  + _log_msg Warning: Unable to find the persistent home medium\n
  + [ n = y ]
  + printf Warning: Unable to find the persistent home medium\n
  Warning: Unable to find the persistent home medium
  __________________________________________________________

  
  a warning about the home medium is shown in both cases (file and partition) but the persistence file works never the less..

  
  my system:  

  kubuntu linux 15.10 beta1

  uname -a
  Linux wald 4.1.0-3-generic #3-Ubuntu SMP Tue Jul 28 12:25:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/casper/+bug/1489855/+subscriptions



More information about the foundations-bugs mailing list