+ rofsstring=""
+ for dir in $(mount -t squashfs | cut -d\ -f 3); do
+ rofsstring="$dir=ro:$rofsstring"
+ done
+ rofsstring=${rofsstring%:}
+
+ mkdir -p /cow
+
+ if grep -q persistent /proc/cmdline; then
+ i=0
+ # We love udev and the kernel!
+ while [ "$i" -lt 300 ]; do
+ cowdevice=$(find_cow_device)
+ if [ -b "$cowdevice" ]; then
+ mount -t $(get_fstype "$cowdevice") -o rw "$cowdevice" /cow || panic "Can not mount $cowdevice on /cow"
+ break
+ fi
+ sleep 0.1
+ i=$(( $i + 1 ))
+ done
+ else
+ mount -t tmpfs tmpfs /cow
+ fi
+
+ mount -t unionfs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt"
+
+ for d in $(mount -t squashfs | cut -d\ -f 3); do
+ mkdir -p "${rootmnt}/casper/${d}"
+ mount -o bind "${d}" "${rootmnt}/${d}"
+ umount "${d}"
+ done
+
+ if grep -q show-cow /proc/cmdline; then
+ mkdir -p "$rootmnt/cow"
+ mount -o bind /cow "$rootmnt/cow"