#======================================# mountSystem#--------------------------------------function mountSystem () { retval=0 OLDIFS=$IFS IFS=$IFS_ORIG mountDevice=$imageRootDevice if test ! -z $1;then mountDevice=$1 fi if test ! -z $UNIONFS_CONFIG;then roDir=/ro_branch rwDir=/rw_branch xiDir=/xino for dir in $roDir $rwDir $xiDir;do mkdir -p $dir done rwDevice=`echo $UNIONFS_CONFIG | cut -d , -f 1` roDevice=`echo $UNIONFS_CONFIG | cut -d , -f 2` unionFST=`echo $UNIONFS_CONFIG | cut -d , -f 3` echo $rwDevice | grep -q ram if [ $? = 0 ];then # /.../ # write part is a ram location, use tmpfs for ram # disk data storage # ---- mount -t tmpfs tmpfs $rwDir >/dev/null 2>&1 || retval=1 else # /.../ # write part is not a ram disk, create ext2 filesystem on it # check and mount the filesystem # ---- if test $LOCAL_BOOT = "no" && test $systemIntegrity = "clean";then if test "$RELOAD_IMAGE" = "yes" || \ ! mount $rwDevice $rwDir >/dev/null 2>&1 then Echo "Checking filesystem for RW data on $rwDevice..." e2fsck -y -f $rwDevice >/dev/null 2>&1 if test "$RELOAD_IMAGE" = "yes" || \ ! mount $rwDevice $rwDir >/dev/null 2>&1 then Echo "Creating filesystem for RW data on $rwDevice..." if ! mke2fs $rwDevice >/dev/null 2>&1;then Echo "Failed to create ext2 filesystem" retval=1; return $retval fi tune2fs -m 0 $rwDevice >/dev/null 2>&1 Echo "Checking EXT2 write extend..." e2fsck -y -f $rwDevice >/dev/null 2>&1 fi else umount $rwDevice fi fi if ! mount $rwDevice $rwDir >/dev/null 2>&1;then retval=1 fi fi if ! mount -t squashfs $roDevice $roDir >/dev/null 2>&1;then if ! mount $roDevice $roDir >/dev/null 2>&1;then retval=1 fi fi if [ $unionFST = "aufs" ];then mount -t tmpfs tmpfs $xiDir >/dev/null 2>&1 || retval=1 mount -t aufs \ -o dirs=$rwDir=rw:$roDir=ro,xino=$xiDir/.aufs.xino none /mnt \ >/dev/null 2>&1 || retval=1 else mount -t unionfs \ -o dirs=$rwDir=rw:$roDir=ro none /mnt >/dev/null 2>&1 || retval=1 fi usleep 500000 else if ! mount $mountDevice /mnt >/dev/null 2>&1;then mount -t squashfs $mountDevice /mnt >/dev/null 2>&1 fi retval=$? fi IFS=$OLDIFS return $retval}