Comment 7 for bug 274076

Revision history for this message
James Westby (james-w) wrote :

Hi,

I've followed the code through some and I see the following steps
happen (with root persistence, something similar probably happens
with home persistence)

  1) It finds the live image and mounts that at /cdrom, then finds
      the squashfs within, loop mounts it, and remembers the mount
      point for the ro part of the aufs mount.

  2) It finds the device with casper-rw on it, and mounts this at
      /casper-rw-backing.

  3) It loop mounts casper-rw and then mounts that at /cow

  4) It then sets up the aufs mount to combine the two parts.

  5) It then attempts to mount the home persistence. This could
      cause the issue as well, but as it tries to remount with rw then
      it may not as it doesn't need to change anything.

  6) It then attempts to look for the snapshots. This calls find_files
      which in turn causes try_mount with "ro", which tries to remount
      already mounted filesystems, causing this issue.

find_files has a "# FIXME: merge with above function ", referring to
find_cow_device, which could possibly fix this. I'm not too sure how this
would be done though.

How about this as a hack in try mount?
     if where_is_mounted ${dev} > /dev/null; then
- mount -o remount,"${opts}" ${dev} $(where_is_mounted ${dev}) || panic "Remounting failed"
+ if [ "${opts}" != "ro" ]; then
+ mount -o remount,"${opts}" ${dev} $(where_is_mounted ${dev}) || panic "Remounting failed"
+ fi
         mount -o bind $(where_is_mounted ${dev}) ${mountp} || panic "Cannot bind-mount"

as there is no point remounting read-only for the uses that are made of try_mount.

Alternatively the attached may be slightly more palatable. It just re-uses the existing
mount if there is one, as all it wants to do is copy files from it.

I'm sure you will come up with something far more elegant to solve the problem
though.