Difference between revisions of "Tutorials Linux opt on loopback"
UltraBlack (talk | contribs) m (→To Do's) |
UltraBlack (talk | contribs) m (→To Do's) |
||
Line 175: | Line 175: | ||
Create a method to safely unmount Virtual FileSystem when selecting USB Drive and Media Sync modes (under development). | Create a method to safely unmount Virtual FileSystem when selecting USB Drive and Media Sync modes (under development). | ||
− | + | ||
+ | See start/stop script above for now. In the future this will be wrapped inside a homebrew GUI. | ||
=Credits= | =Credits= |
Revision as of 01:59, 5 August 2009
Introduction
Background & Purpose
The Palm Pre's 8GB HD is configured with three partitions:
1) /dev/mmcblk0p1 defined as a Linux/PA-RISC boot partition is only 4MB 2) /dev/mmcblk0p2 defined as a Linux partition and is 32MB mounted as /boot 3) /dev/mmcblk0p3 defined as a Linux LVM partition is 7.62GB
The /dev/mmcblk0p3 partition is a Linux Volume Group that is sliced into six Logical Volumes:
/dev/store/root mounted on / (root) 456 MB /dev/store/var mounted on /var 256MB /dev/store/update mounts on /var/lib/update 56MB (not mounted) /dev/store/log/ mounted on /var/log 40MB /dev/store/media mounted /media/internal 6.69GB /dev/store/swap linux swap 128MB
It has been observed that if /var or / (root) usage is greater than or equal to 90% than the FAILED_NOT_ENOUGH_INSTALL_SPACE error is generated. "Builtin" applications reside on the root filesystem in /usr/palm/applications. Downloaded apps and those installed with palm-install reside on the /var filesystem in /var/usr/palm/applications. Also for rooted Pre's the opt-ware linux-based apps are stored in /var/opt.
One fix for a rooted Pre is to create a virtual linux filesystem using a portion of the space allocated to /media/internal using a procedure similar to this one:
Linux Online - Using a file instead of a partition
Then mount the virtual filesystem on /opt vs binding /var/opt to /opt. Then relocating the files/directories under /var/opt to the new virtual filesystem.
NOTE: The /dev/store/update is mounted when you run the Update process. It would seem that the updates are stored here (at least some of them) prior to installation.
Requirements
You must be root to perform this process. It is assumed that you followed the procedure to install opt-ware apps in /var/opt and linked /var/opt to /opt with the "mount -o bind /var/opt /opt" command and there is an equivalent entry in the /etc/fstab file.
Procedure
Creating Linux Virtual Filesystem
Do NOT do this if you want to connect your Pre to your computer in USB Drive or MediaSync mode.
The following commands will move all your optware to an ext3 1GB loopback image that resides on /media/internal. <source lang="bash">
- Create a directory on the USB drive portion to hold the virtual filesystem
mkdir /media/internal/vfs
- Create a 1GB file (adjust size (bs*count) as needed, the minimum size should be 256MB)
dd if=/dev/zero of=/media/internal/vfs/optware.img bs=1024 count=1024k
- Create linux ext3 filesystem
mkfs.ext3 -F /media/internal/vfs/optware.img
- Create a temporary mount point
mkdir /tmp/opt
- Mount newly created virtual filesystem
mount -o loop /media/internal/vfs/optware.img /tmp/opt
- Populate new virtual filesystem.
- Must be in the source directory.
cd /opt tar cvf - . | (cd /tmp/opt; tar xf -) cd /
- Unmount virtual filesystem
umount /tmp/opt
- Unbind /var/opt from /opt
umount /opt
- If no errors, mount virtual filesystem on /opt
- otherwise skip
mount -o loop /media/internal/vfs/optware.img /opt/
- Add the following line to /etc/fstab to automount (without the #).
- /media/internal/vfs/optware.img /opt/ ext3 loop,noatime 1 2
- Comment out the /var/opt entry, should be similar to next line
- /var/opt /opt bind defaults,bind 0 0
- reboot your phone, if error noted when attempting to unmount /opt
reboot
- If no errors noted with the opt-ware apps,
- remove files/directories from /var/opt
rm -r /var/opt </source>
Start/Stop Script
A work in progress. Needs to be bullet-proofed. Ideally should be wrapped around a WebOS GUI app. This script is a work-a-round to allow using the Palm Pre's USB Drive and Media Sync modes.
<source lang="bash">
- !/bin/sh
- List of Optware applications to start/stop
- in conjunction with mounting/unmounting VFS
- Edit to suit environment
APPS="optware-openssh optware-dropbear"
- An entry in /etc/fstab must exist filename
FSVFS=`/bin/grep "/opt" /etc/fstab|grep loop` if [ "$FSVFS" != "" ] then
# Complete FileName of VFS to mount/unmount LVFSFN=`echo $FSVFS|/usr/bin/awk '{print $1}'` # VFS Mount Point LVFSMP=`echo $FSVFS|/usr/bin/awk '{print $2}'` # VFS Filesystem Type LVFSTP=`echo $FSVFS|/usr/bin/awk '{print $3}'`
else
echo "**** No /etc/fstab entry" exit 1
fi
- Determine if VFS is mounted
VFSMTD=`/bin/df|/bin/grep "$LVFSMP"|/bin/grep "^/dev/loop"` if [ "$VFSMTD" != "" ] then
LVFSDV=`echo $VFSMTD|/usr/bin/awk '{print $1}'`
fi
case $1 in
"on" ) if [ -e "$LVFSFN" -a -d "$LVFSMP" -a "$VFSMTD" = "" ] then echo '**** Mounting Linux VFS' /bin/mount "$LVFSFN" echo '**** Starting Applications' for x in $APPS do if [ -f /etc/event.d/"$x" ] then /sbin/initctl start "$x" fi done echo '**** Linux VFS Enabled' else echo '**** Error mounting VFS' exit 1 fi ;; "off" ) if [ "$VFSMTD" != "" -a "$LVFSDV" != "" ] then echo '**** Stopping Applications' for x in $APPS do if [ -f /etc/event.d/"$x" ] then /sbin/initctl stop "$x" fi done echo '**** Unmounting Linux VFS' /bin/umount "$LVFSMP" /sbin/losetup -d $LVFSDV echo '**** Linux VFS Disabled' else echo '**** Error unmounting VFS' exit 1 fi ;; * ) echo "Usage: `/usr/bin/basename $0` on|off" ;;
esac </source>
Caveats
Currently this procedure will disable USB Drive and Media Sync modes.
To Do's
Create a method to safely unmount Virtual FileSystem when selecting USB Drive and Media Sync modes (under development).
See start/stop script above for now. In the future this will be wrapped inside a homebrew GUI.
Credits
PuffTheMagic - Initial process 1lnxraider - Expanded and modified tutorial, is working on fixing caveats ultraBlack - Found and helped confirm caveat that disables Media Sync and USB modes NetWhiz - Gave warning that this process disables USB Drive/Media Sync