sfdisk -c /dev/mmcblk0 26
echo "/dev/mmcblk1p1 /home/user/MyDocs vfat $fat_opts 0 0" >> $tmp_fstab
/bin/mount /home/user/MyDocs
if [ $# = 1 ]; then
DEV=/dev/mmcblk1p1
STR=`cat $LUN0`
if [ "x$STR" = "x" ]; then
# echo $1 > $LUN0
echo $DEV > $LUN0
else
echo $1 > $LUN1
fi
fi
exit 0
mount /home/user/MyDocs exit 0

| The Following 4 Users Say Thank You to iDont For This Useful Post: | ||

start on MYDOCS_REPLACED
description "unmounts normal MyDocs filesystem and replaces it with the SD card"
# Runs afer rcS-late has mounted everything
start on MOUNTS_OK
console none
script
# Alter the next six lines if necessary for your system
MYDOCS_DEVICE=/dev/mmcblk0p1
SD_DEVICE=/dev/mmcblk1p1
MYDOCS_MOUNTPOINT=/home/user/MyDocs
MYDOCS_FILESYSTEM=vfat
SD_MOUNTPOINT=/media/mmc1
SD_FILESYSTEM=vfat
# Check that MyDocs hasn't already been replaced
if [ ! -z "`mount | grep $MYDOCS_MOUNTPOINT | grep $SD_DEVICE`" ]
then
# Already mounted.
normal exit 0
fi
# It can take a few seconds for MyDocs to actually mount after rsS-late
# has finished, so we'll watch for it
i=0
while [ -z "`mount | grep $MYDOCS_MOUNTPOINT`" -o -z "`mount | grep $SD_MOUNTPOINT`" ]
do
i=$(($i+1))
if [ $i -eq 120 ]
then
# If it hasn't mounted within two minutes, something's gone
# horribly wrong, so we may as well give up
normal exit 0
fi
sleep 1
done
# Get mount options from the fstab file
OPTS=`grep $MYDOCS_MOUNTPOINT /etc/fstab | awk ' { print $4 } '`
# Unmount the SD card
umount $SD_MOUNTPOINT
# Check it unmouted OK
if [ $? -eq 0 ]
then
# Unmount the MyDocs filesystem
umount $MYDOCS_MOUNTPOINT
# Check it unmounted OK
if [ $? -eq 0 ]
then
# Mount the SD on MyDocs
mount $SD_DEVICE -t $SD_FILESYSTEM -o "$OPTS" $MYDOCS_MOUNTPOINT
if [ $? -ne 0 ]
then
# Failed to mount the SD so fall back to original
mount $MYDOCS_DEVICE -t $MYDOCS_FILESYSTEM -o "$OPTS" $MYDOCS_MOUNTPOINT
else
initctl emit MYDOCS_REPLACED
fi
fi
fi
end script
normal exit 0
description "unmounts normal MyDocs filesystem and replaces it with the SD card"
# Runs afer rcS-late has mounted everything
start on MOUNTS_OK
console none
script
MYDOCS_DEVICE=/dev/mmcblk0p1
SD_DEVICE=/dev/mmcblk1p1
MYDOCS_MOUNTPOINT=/home/user/MyDocs
MYDOCS_FILESYSTEM=vfat
SD_MOUNTPOINT=/media/mmc1
SD_FILESYSTEM=ext3
# Check that MyDocs hasn't already been replaced
if [ ! -z "`mount | grep $MYDOCS_MOUNTPOINT | grep $SD_DEVICE`" ]
then
# Already mounted.
normal exit 0
fi
# It can take a few seconds for MyDocs to actually mount after rsS-late
# has finished, so we'll watch for it
i=0
if [ $SD_FILESYSTEM == "vfat" ]
then
# The SD will auto-mount if if's vfat, but won't otherwise. So if it's vfat
# we want to wait until it's been mounted so we don't interrupt
while [ "`mount | grep $SD_MOUNTPOINT`" ]
do
i=$(($i+1))
if [ $i -eq 120 ]
then
# If it hasn't mounted within two minutes, something's gone
# horribly wrong, so we may as well give up
normal exit 0
fi
sleep 1
done
fi
i=0
while [ -z "`mount | grep $MYDOCS_MOUNTPOINT`" ]
do
i=$(($i+1))
if [ $i -eq 120 ]
then
# If it hasn't mounted within two minutes, something's gone
# horribly wrong, so we may as well give up
normal exit 0
fi
sleep 1
done
if [ $SD_FILESYSTEM == "vfat" ]
then
# Get mount options from the fstab file
OPTS=`grep $MYDOCS_MOUNTPOINT /etc/fstab | awk ' { print $4 } '`
else
# We don't want the mount options from fstab, as some are invalid for
# other filesystems.
OPTS="noauto,nodev,nosuid,noatime,nodiratime"
fi
if [ $SD_FILESYSTEM == "vfat" ]
then
# Unmount the SD card
umount $SD_MOUNTPOINT
# Check it unmouted OK
if [ $? -ne 0 ]
then
exit
fi
fi
# Unmount the MyDocs filesystem
umount $MYDOCS_MOUNTPOINT
# Check it unmounted OK
if [ $? -eq 0 ]
then
# Mount the SD on MyDocs
mount $SD_DEVICE -t $SD_FILESYSTEM -o "$OPTS" $MYDOCS_MOUNTPOINT
if [ $? -ne 0 ]
then
# Failed to mount the SD so fall back to original
mount $MYDOCS_DEVICE -t $MYDOCS_FILESYSTEM -o "$OPTS" $MYDOCS_MOUNTPOINT
else
initctl emit MYDOCS_REPLACED
fi
fi
end script
normal exit 0

if [ $# = 1 ]; then
umount /home/user/MyDocs
STR=`cat $LUN0`
if [ "x$STR" = "x" ]; then
echo $1 > $LUN0
else
echo $1 > $LUN1
fi
fi
exit 0
mount /home/user/MyDocs exit 0