Since the patch didn't make it in time for 18.04.3 but 18.04 is the
latest LTS release available before 20.04, I'd wager there'd be at least
a few others looking to create a persistent LTS USB drive facing this
issue. Also, I spent a few hours figuring this out so hopefully this
saves someone some time.

I've made a patched version of the "casper/initrd" file that one can
simply replace with in an already-created USB drive. Its SHA1 is
d70c6189ae6497422b704219c3f8dd1a8fba6fe6.

*Only works from bootable drives made from Ubuntu 18.04.3 ISO!*
https://drive.google.com/file/d/1X25ZafWhUn9ZpDNS1QHWmCaDS7Fl9sOT

If you do not trust a random binary, here are the steps required to
reproduce it:

1. Extract "casper/initrd" from the ISO or USB drive to a temporary directory
(You can use unmkinitramfs but let's extract manually.)
(Based on mwhudson's incantation a few comments up, but for LZMA used in 18.04.)

$ cd /path/to/temp/dir; (cpio -t; cpio -t; lzcat | cpio -i ) <
/path/to/casper/initrd

2. (Optional) Apply 0e52b46 so that the actual patch won't be offset
(This patch is not relevant for our case but precedes the patch we want to 
apply. It does fix a bug though!)
(Ignore the error about not finding "debian/changelog", it is only included in 
the casper package and not the initrd.)

$ wget -qO -
https://git.launchpad.net/~mwhudson/ubuntu/+source/casper/patch/?id=0e52b46ea2a0eff48e0e8b26cb6a7174989ceb27
| patch -tp1

3. Apply a452b0b, which is what we want
(Again, ignore the error about not finding "debian/changelog", it is only 
included in the casper package and not the initrd.)

$ wget -qO -
https://git.launchpad.net/~mwhudson/ubuntu/+source/casper/patch/?id=a452b0b0d5874ae48ee7ea742e500e48ffd8d0a4
| patch -tp1

4. Repackage into LZMA file
(Again based on mwhudson's incantation a few comments up, though gzip should 
probably work fine too.)

$ find . | LC_ALL=C sort | cpio -R 0:0 -o -H newc | lzma -c >
/tmp/initrd.new.lz

[Here, you should be able to use the new initrd for almost all cases by
replacing the one on your USB drive. However, the original initrd has
microcode embedded before the actual initrd, so it will be nice if we
can restore that.]

5. Here it gets tricky as we try to extract the microcode segment
(If you have binwalk installed, here's a command to automatically do this for 
you)

$ TGT_FILE=/path/to/casper/initrd; dd if=$TGT_FILE
of=/tmp/initrd.microcode bs=`binwalk $TGT_FILE | grep LZMA | head -1 |
cut -d ' ' -f1` count=1

(Else, you'll have to trust me when I tell you the segment spans from
0-2441216 for the official 18.04.3 ISO)

$ dd if=/path/to/casper/initrd of=/tmp/initrd.microcode bs=2441216
count=1

6. Put the files together to get the initrd that's identical in
structure to the original

$ cat /tmp/initrd.microcode /tmp/initrd.new.lz > /tmp/initrd

[You should now be able to replace the initrd in the casper directory on
your USB drive with the newly-built one in /tmp]

HTH

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1489855

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

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

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to