DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Mounting A Virtual Filesystem

  • submit to reddit
        Source: <a href="">Tutorials Linux opt on loopback - WebOS Internals</a> []
# Create a directory on the USB drive portion to hold the virtual file system
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 file system
mkfs.ext3 -F /media/internal/vfs/optware.img
# Create a temporary mount point
mkdir /tmp/opt
# Mount newly created virtual file system
mount -o loop /media/internal/vfs/optware.img  /tmp/opt
# Populate new virtual file system.
# Must be in the source directory.
cd /opt
tar cvf - . |  (cd /tmp/opt; tar xf -)
cd /
# Unmount virtual file system
umount /tmp/opt
# Unbind /var/opt from /opt
umount /opt
# If no errors, mount virtual file system 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
# If no errors noted with the Optware apps, 
# remove files/directories from /var/opt
rm -r /var/opt