Sharing Files Between Ubuntu Flash Drive and Windows

Linux OS Topics
Post Reply
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Sharing Files Between Ubuntu Flash Drive and Windows

Post by Neo » Sat Oct 10, 2009 8:12 am

How to Share Files Between your USB Ubuntu Flash Drive install and Windows. In the following tutorial, you will learn how to modify the casper script to allow you to mount your USB Flash Drive as read/write. By default the script only allows the root user to gain full access t the drive, preventing the live user from saving files back to the fat formatted device. This tutorial allows for the default Ubuntu user to have the same read and write access.

Upon completion, you will be able to save files back to the root of your Flash Drive (which is 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 should work for Ubuntu, Kubuntu, Linux Mint etc. Pretty much any Ubuntu derived compilation.

How to edit the Casper script to allow read and write access to the entire USB device:
  1. Boot from your previously created USB Ubuntu 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 gzip -dc /cdrom/casper/initrd.gz | cpio -i (to extract the initrd.gz)
  6. Type gedit scripts/casper (to edit the casper script)
  7. From gedit, find the following section of code:

    Code: Select all

    home_snapshot_label="home-sn"
  8. Just below it add the following code:

    Code: Select all

    mountmode="ro,noatime"
  9. Now find the following section of code:

    Code: Select all

    IGNORE_UUID="Yes" ;;
  10. Just below it add the following code:

    Code: Select all

    # New command line parameter to select the base device mount mode
    basemountmode=*)
    mountmode="${x#basemountmode=}";;
  11. Now find the following section of code:

    Code: Select all

    if is_supported_fs ${fstype}; then
  12. and (as a single line of code) change the next line to:

    Code: Select all

    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.gz (to zip the new initrd.gz file)
  15. Type cp initrd.gz /cdrom/casper
  16. Type gedit /cdrom/syslinux/text.cfg
  17. On the first append line, replace the following section:

    Code: Select all

    initrd=/casper/initrd.gz
  18. With the following section (as a single line):

    Code: Select all

    initrd=/casper/initrd.gz 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.
Post Reply

Return to “Linux”