Sharing Files Between Ubuntu and Windows. In the following tutorial, I cover how to modify the casper script to allow you to mount your USB Flash Drive with read/write access. By default casper only allows the root user to gain full access to the drive, preventing the live user from saving files back to a fat formatted device. This tutorial allows for the default Ubuntu user to also have the same read and write access. Enabling you to share files between Linux and Windows.
Upon completion, you will be able to save files back to the root of your Flash Drive (mounted as /cdrom) while your running from Ubuntu. Save your documents, photos, movies, mp3's, special configuration files etc... back to the Flash drive. In addition you can add files while running from Windows and then access those files again while running from Linux or vice versa.
The following solution was tested tp work on Ubuntu, Kubuntu, Linux Mint, and other "Ubuntu 11.10/11.04/10.04/10.10". based compilations.
How to edit the Casper Script to allow Sharing Files
The following process explains the process of editing Ubuntu's Casper script to allow read and write access to the USB device. This makes it so that you can save files back to the USB drive while running from within Ubuntu booted from USB.
- Boot from your previously created Ubuntu bootable USB Flash Drive
- Open a terminal and type sudo su (to become root)
- Type mkdir /projectaccess (to make our project directory)
- Type cd /projectaccess (to change to the project directory)
- Type lzma -dc -S .lz /cdrom/casper/initrd.lz | cpio -id (to extract the initrd.lz)
- Type gedit scripts/casper (to edit the casper script)
- From gedit, find the following section of code:
home_snapshot_label="home-sn"
- Just below it add the following code:
mountmode="ro,noatime"
- Now for 10.04 or 10.10, find the following section of code:
IGNORE_UUID="Yes" ;;
Or if using 11.04 or 11.10 find the following section of code instead:
UUID="" ;;
- Just below it add the following code:
basemountmode=*)
mountmode="${x#basemountmode=}";; - Now find the following section of code:
if is_supported_fs ${fstype}; then
- and (as a single line of code) change the first occurrence of mount line to:
mount -t ${fstype} -o ${mountmode} "${devname}" $mountpoint || continue
- Save the file and return to the open terminal
- From the terminal type find . | cpio -o -H newc | gzip -9 > initrd.lz (to zip the new initrd.lz file)
- Type cp initrd.lz /cdrom/casper
- Type gedit /cdrom/syslinux/txt.cfg ( text.cfg if using Ubuntu 10.04)
- On the first append line, replace the following section:
initrd=/casper/initrd.lz
- With the following section (as a single line):
initrd=/casper/initrd.lz basemountmode=ro,noatime,uid=999,gid=999
- Save the file and exit the editor
- Reboot your computer and proceed to boot from your USB Flash Drive again
If all goes well, you should now be able to save files to /cdrom (the root of your Flash Drive) from within Ubuntu and access those files from within Linux or Windows. This concludes the process of sharing Files Between Ubuntu and Windows. Casper should now allow read and write access to the entire USB. Enabling you to save files back to the device while running Ubuntu from USB.
Kudos goes out to Julian Chennales who submitted the base information for this fix to pendrivelinux for posting.