Merge lp:~noorez-kassam/ubuntu/utopic/initramfs-tools/fix-for-1317437 into lp:ubuntu/utopic/initramfs-tools

Proposed by Noorez
Status: Needs review
Proposed branch: lp:~noorez-kassam/ubuntu/utopic/initramfs-tools/fix-for-1317437
Merge into: lp:ubuntu/utopic/initramfs-tools
Diff against target: 30 lines (+11/-1)
2 files modified
debian/changelog (+7/-0)
scripts/local (+4/-1)
To merge this branch: bzr merge lp:~noorez-kassam/ubuntu/utopic/initramfs-tools/fix-for-1317437
Reviewer Review Type Date Requested Status
Noorez (community) Needs Resubmitting
Luke Yelavich (community) Needs Fixing
Review via email: mp+219927@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Noorez (noorez-kassam) wrote :

Can this be backported to trusty as well?

p.s. first ever ubuntu patch. (be mean)

Revision history for this message
Luke Yelavich (themuso) wrote :

Thanks for your work. I am not quite sure what you are trying to fix here. Could you please give some information as to why you want to change the behavior such that the loop mount can be remounted read-write? Is there a part of the update process that requires that?

Reading the report, it seems that lupin-install uses the correct version of GRUB. Should the fix instead be made elsewhere to make sure this gets done properly with grub?

Thanks again.

review: Needs Fixing
Revision history for this message
Noorez (noorez-kassam) wrote :

Here is what I was observing:

Without this fix, during boot, the message "Serious errors were found while searching for /" appears. While attempting to diagnose this problem, I attempted to boot into recovery mode. While in recovery I attempted to remount the the root filesystem (at this point the loop install) as rw but this failed.

The bug report indicates that changing the kernel option to 'rw' remedies this problem. And while in recovery mode, this also allows the loop device to be remounted as read-write/read-only at will.

After doing a quick search, it appears that once a loop device is created as read-only, it cannot be changed. The 'ro' option is given to the loop device (in a loop install the host file system is always mounted read-write) and so it seems that we cannot change it to read-write later on. If however we pre-configure the loop device in read-write mode, even though we initially mount the filesystem as read-only (the kernel option we pass in), we can then remount it as read-write and the system appears to boot correctly after this.

> Thanks for your work. I am not quite sure what you are trying to fix here.
> Could you please give some information as to why you want to change the
> behavior such that the loop mount can be remounted read-write? Is there a part
> of the update process that requires that?
>
> Reading the report, it seems that lupin-install uses the correct version of
> GRUB. Should the fix instead be made elsewhere to make sure this gets done
> properly with grub?
>
> Thanks again.

Revision history for this message
Noorez (noorez-kassam) wrote :

Is it possible to get further comments on this review?

review: Needs Resubmitting
Revision history for this message
bcbc (bcbc) wrote :

This is the way I understand this is and my testing is shown below:

Mounting and creating the loop device in the same step with the readonly option, makes it impossible to remount the loop device later as read-write.

By creating the loop device separately (which defaults to read-write capable unless the -r option is supplied), the loop device can then be mounted readonly, and later remounted as read-write.

This change is needed since release 14.04, which - for unknown reasons - now won't let the loop device be remounted read-write (perhaps it's passing the -r option to losetup internally and it's losetup which has started enforcing this?).

The end result is that Wubi installs cannot boot, because the remount read-write fails.

My tests confirm this:
Setup:
1. Create a file, format as ext4.
bcbc@neptune:~$ dd if=/dev/zero of=new.disk bs=1MB count=100
bcbc@neptune:~$ mkfs.ext4 -F new.disk

2. Old method, mount and create loop device as read only, then try to remount
bcbc@neptune:~$ sudo mount -r -t ext4 -o loop new.disk /mnt
bcbc@neptune:~$ sudo touch /mnt/test
touch: impossible de faire un touch «/mnt/test»: Système de fichiers accessible en lecture seulement
bcbc@neptune:~$ sudo mount -o remount,rw /mnt
mount : impossible de remonter périphérique bloc /dev/loop0 en lecture/écriture, est protégé en écriture
bcbc@neptune:~$ sudo umount /mnt

3. New method, first create loop device (defaults to read-write capable), then mount as read only, then try to remount read-write
bcbc@neptune:~$ sudo losetup /dev/loop0 new.disk
bcbc@neptune:~$ sudo mount -r -t ext4 /dev/loop0 /mnt
bcbc@neptune:~$ sudo touch /mnt/test
touch: impossible de faire un touch «/mnt/test»: Système de fichiers accessible en lecture seulement
bcbc@neptune:~$ sudo mount -o remount,rw /mnt
bcbc@neptune:~$ sudo touch /mnt/test
bcbc@neptune:~$ sudo umount /mnt
bcbc@neptune:~$ sudo losetup -d /dev/loop0

4. To confirm it's probably passing -r to losetup
bcbc@neptune:~$ sudo losetup -r /dev/loop0 new.disk
bcbc@neptune:~$ sudo mount -r -t ext4 /dev/loop0 /mnt
bcbc@neptune:~$ sudo touch /mnt/test
touch: impossible de faire un touch «/mnt/test»: Système de fichiers accessible en lecture seulement
bcbc@neptune:~$ sudo mount -o remount,rw /mnt
mount : impossible de remonter périphérique bloc /dev/loop0 en lecture/écriture, est protégé en écriture
bcbc@neptune:~$ sudo umount /mnt
bcbc@neptune:~$ sudo losetup -d /dev/loop0

Conclusion:
This fix is appropriate and required for loop mounted installs

Revision history for this message
hakuna_matata (hakuna-matata) wrote :

> Should the fix instead be made elsewhere to make sure this gets done properly with grub?
IMHO busybox has needed the feature of remounting for unknown reasons since first version for 14.04. busybox (1:1.20.0-8.1ubuntu1) for 13.10 was the last version which worked.

As bcbc showed there is no easy way of remounting if you mount a loop device with old method. So I think it is easier to change the way of first mounting than to change later processing.

Naturally, it is also possible to mount a loop device with kernel option rw in GRUB but this could be a problem if you need recovery mode.

Conclusion:
I don't know a better solution for this issue.

Unmerged revisions

281. By Noorez

Setup the loop device so that the loop filesystem can be
remounted as read-write (LP: #1317437)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-05-06 21:30:41 +0000
+++ debian/changelog 2014-05-17 03:33:27 +0000
@@ -1,3 +1,10 @@
1initramfs-tools (0.103ubuntu7) UNRELEASED; urgency=medium
2
3 * Setup the loop device so that the loop filesystem can be
4 remounted as read-write (LP: #1317437)
5
6 -- Noorez Kassam <kassan1@kassan1> Fri, 16 May 2014 21:18:01 -0600
7
1initramfs-tools (0.103ubuntu6) utopic; urgency=medium8initramfs-tools (0.103ubuntu6) utopic; urgency=medium
29
3 * Create /bin/egrep -> busybox symlink, because initramfs-tools10 * Create /bin/egrep -> busybox symlink, because initramfs-tools
411
=== modified file 'scripts/local'
--- scripts/local 2011-07-12 07:22:11 +0000
+++ scripts/local 2014-05-17 03:33:27 +0000
@@ -135,7 +135,10 @@
135 modprobe ${FSTYPE}135 modprobe ${FSTYPE}
136136
137 # FIXME This has no error checking137 # FIXME This has no error checking
138 mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "/host/${LOOP#/}" ${rootmnt}138 loopdev=`losetup -f`
139 losetup ${loopdev} "/host/${LOOP#/}"
140 mount ${roflag} -t ${FSTYPE} ${LOOPFLAGS} ${loopdev} ${rootmnt}
141
139142
140 if [ -d ${rootmnt}/host ]; then143 if [ -d ${rootmnt}/host ]; then
141 mount -o move /host ${rootmnt}/host144 mount -o move /host ${rootmnt}/host

Subscribers

People subscribed via source and target branches

to all changes: