that implement 'savefolder' using symbolic links instead of 'mount -o bind'.
Patch 1) "init" script in "initrd.gz":
Code: Select all
--- init.orig 2014-10-04 01:58:54.960910335 +1000
+++ init 2014-10-04 02:26:50.898497667 +1000
@@ -1078,7 +1078,10 @@
;;
esac
fi
- if [ "$CRYPTO" != "" ] ; then
+ if [ -d /mnt/dev_save$PUPSAVEFILE ]; then
+ rm -r -f $CREATEPUPSAVE2FS
+ ln -s /mnt/dev_save${PUPSAVEFILE} $CREATEPUPSAVE2FS
+ elif [ "$CRYPTO" != "" ] ; then
echo "" >/dev/console
echo "Mounting encrypted $PUPSAVEFILE..." > /dev/console
while true; do
@@ -1124,8 +1127,6 @@
losetup -d /dev/loop1
fi
done
- elif [ -d /mnt/dev_save$PUPSAVEFILE ]; then
- mount -o bind /mnt/dev_save${PUPSAVEFILE} $CREATEPUPSAVE2FS
else #pupsave not encrypted.
# if pupsave increase requested
if [ -f /mnt/dev_save/pupsaveresizenew.txt ];then #131225 changed to function
@@ -1967,6 +1968,12 @@
do
mount -o move $ONEMNT /pup_new/initrd${ONEMNT}
done
+if [ ${PUPSAVEFILE} -a -d /pup_new/initrd/mnt/dev_save${PUPSAVEFILE} ]; then
+ if [ ${CREATEPUPSAVE2FS} -a -L ${CREATEPUPSAVE2FS} ]; then
+ rm -r -f /pup_new/initrd${CREATEPUPSAVE2FS}
+ ln -s ./mnt/dev_save${PUPSAVEFILE} /pup_new/initrd${CREATEPUPSAVE2FS}
+ fi
+fi
#v4.02 bring back, but allocate more space (/4 instead of /8)....
#v3.97 a problem can run out of /tmp space, remove...
To provide direct access to the save directory after the switch root, "/pup_new/initrd/pup_rw" is changed to be a symbolic link to the save directory.
Fortunately 'aufs' cooperates nicely, when the specified branch is a symbolic link, it follows the link and uses the real path to the directory.
Code: Select all
# cat /sys/fs/aufs/si_*/br0
/initrd/mnt/dev_save/tahr/tahrsave=rw
Code: Select all
if savefile is encrypted #assume is a file
else if savefile is a directory #assume no encryption
else #is unencrypted file
Code: Select all
if savefile is a directory #could include encrypted option
else if savefile is encrypted #must be a file
else #is unencrypted file
Code: Select all
--- rc.shutdown.orig 2014-08-28 06:07:44.000000000 +1000
+++ rc.shutdown 2014-10-04 02:04:09.922537392 +1000
@@ -440,12 +440,11 @@
[ "`echo -n "$SAVEFILE" | grep "2fs"`" != "" ] && FILEFS="ext2"
[ "`echo -n "$SAVEFILE" | grep "4fs"`" != "" ] && FILEFS="ext4" #120427 01micko
- if [ "$CRYPTO" = "" ];then
- if [ -d $SMNTPT$SAVEFILE ]; then
- mount -o bind $SMNTPT$SAVEFILE /tmp/save1stpup
- else
- mount -t $FILEFS -o noatime,rw,loop $SMNTPT$SAVEFILE /tmp/save1stpup
- fi
+ if [ -d $SMNTPT$SAVEFILE ]; then
+ rm -r -f /tmp/save1stpup
+ ln -s $SMNTPT$SAVEFILE /tmp/save1stpup
+ elif [ "$CRYPTO" = "" ];then
+ mount -t $FILEFS -o noatime,rw,loop $SMNTPT$SAVEFILE /tmp/save1stpup
else
#note: loop2 is kept available for scripts to use. but, do this to find free one...
DEVLOOP="`losetup-FULL -f`"
@@ -488,7 +487,7 @@
[ "$BASENAME" = "root" ] && cp -a $ONEDIR/.[0-9a-zA-Z]* /tmp/save1stpup/${BASENAME}/ #v2.16exp4
done
sync
- umount /tmp/save1stpup
+ [ -L /tmp/save1stpup ] || umount /tmp/save1stpup
#w481 if low-ram, save-file is on a fast media, and no swap file/partition, then create one...
swapfile_func $SMNTPT $SAVEPART
@@ -675,8 +674,10 @@
sync
fi
fi
- busybox mount -t $SAVEFS -o remount,ro $SAVEDEV /initrd${SAVE_LAYER} 2>/dev/null
- umount-FULL -i -n -l /initrd${SAVE_LAYER} 2>/dev/null #-l is lazy unmount.
+ if [ $SAVEDEV ]; then
+ busybox mount -t $SAVEFS -o remount,ro $SAVEDEV /initrd${SAVE_LAYER} 2>/dev/null
+ umount-FULL -i -n -l /initrd${SAVE_LAYER} 2>/dev/null #-l is lazy unmount.
+ fi
fi
#v2.16 try one more thing for ntfs... lazy unmount, suggested by GuestToo...
After prepending the dummy rw layer to the aufs stack, only do the mount commands for a savefile, there is no mount corresponding to a savefolder.
Note: If only we had implemented it this way in the first place, we might have avoided the headaches caused by 'mount -o bind'.
gyro
Edit: The code above is a fix to the 'savefolder' facility that already exists in TahrPup. I intend to provide an example for a puppy with no existing 'savefolder' facility.
Edit2: An "initrd.gz" for TahrPup 5.8.4.sfs can be downloaded from here http://www.fishprogs.software/puppy/tahr/initrd.gz
A ydrv for TahrPup containing "rc.shutdown" and "sfs_load" can be downloaded from here http://www.fishprogs.software/puppy/tah ... _5.8.4.sfs