Sharing Files Between Ubuntu and Windows

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.

  1. Boot from your previously created Ubuntu bootable USB Flash Drive
  2. Open a terminal and type sudo su (to become root)
  3. Type mkdir /projectaccess (to make our project directory)
  4. Type cd /projectaccess (to change to the project directory)
  5. Type lzma -dc -S .lz /cdrom/casper/initrd.lz | cpio -id (to extract the initrd.lz)
  6. Type gedit scripts/casper (to edit the casper script)
  7. From gedit, find the following section of code:

    home_snapshot_label="home-sn"

  8. Just below it add the following code:

    mountmode="ro,noatime"

  9. 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="" ;;

  10. Just below it add the following code:

    basemountmode=*)
    mountmode="${x#basemountmode=}";;

  11. Now find the following section of code:

    if is_supported_fs ${fstype}; then

  12. and (as a single line of code) change the first occurrence of mount line to:

    mount -t ${fstype} -o ${mountmode} "${devname}" $mountpoint || continue

  13. Save the file and return to the open terminal
  14. From the terminal type find . | cpio -o -H newc | gzip -9 > initrd.lz (to zip the new initrd.lz file)
  15. Type cp initrd.lz  /cdrom/casper
  16. Type gedit /cdrom/syslinux/txt.cfg ( text.cfg if using Ubuntu 10.04)
  17. On the first append line, replace the following section:

    initrd=/casper/initrd.lz

  18. With the following section (as a single line):

    initrd=/casper/initrd.lz basemountmode=ro,noatime,uid=999,gid=999

  19. Save the file and exit the editor
  20. 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.