Sharing Files Between Ubuntu and Windows. Want to share files between Linux and Windows using a bootable USB drive? By default, Ubuntu’s casper
script mounts the USB drive in read only mode for non root users. This prevents saving files to the USB while running Ubuntu live from a flash drive, whereas we want to be able to access USB from Windows and Linux.
However, with a simple tweak to the casper script, you can enable full read and write access; even for the default "live" user. This allows you to easily copy, move, and share files between Ubuntu and Windows using the same USB stick.
Easily Sharing files Between Ubuntu and Windows
In this simple tutorial, you’ll learn how to modify the initrd.lz
file to allow saving files from Ubuntu back to the USB drive, and how to access those files again from Windows or Linux.
This method of sharing files between Ubuntu and Windows should work on Ubuntu 11.10, 11.04, 10.10, and 10.04, as well as compatible distributions like Kubuntu, Linux Mint, and other Debian based remixes that use casper
.
How Sharing Files Works
Ubuntu’s boot process uses a compressed initramfs (initrd.lz
) that includes a casper
script for mounting and managing devices. By editing this script, you can change the USB mount parameters, enabling full access for the default user. This means you can:
- Save and access files on
/cdrom
(USB root) - Share files between sessions
- Add files from Windows and retrieve them later in Linux
Prerequisites for Sharing Files Between Linux and Windows
Before starting, you’ll need:
- A working bootable USB with Ubuntu
- Basic familiarity with terminal commands
- Time to reboot and test changes
How to Enable Read/Write USB Access in Ubuntu Live
- Boot into Ubuntu from your USB Flash Drive
- Open a terminal and type:
sudo su
- Create a working directory:
mkdir /projectaccess
cd /projectaccess
- Extract the initrd.lz file:
lzma -dc -S .lz /cdrom/casper/initrd.lz | cpio -id
- Edit the casper script:
gedit scripts/casper
- In gedit, find:
home_snapshot_label="home-sn"
Add below it:
mountmode="ro,noatime"
- Then find (based on your version):
- For Ubuntu 10.04 or 10.10:
IGNORE_UUID="Yes" ;;
- For Ubuntu 11.04 or 11.10:
UUID="" ;;
Add below it:
basemountmode=*)
mountmode="${x#basemountmode=}";; - For Ubuntu 10.04 or 10.10:
- Now find:
if is_supported_fs ${fstype}; then
Change the mount line directly below it to:
mount -t ${fstype} -o ${mountmode} "${devname}" $mountpoint || continue
- Save the file and return to the terminal
- Rebuild the initrd.lz file:
find . | cpio -o -H newc | gzip -9 > initrd.lz
- Copy the new file back:
cp initrd.lz /cdrom/casper
- Edit the boot configuration:
gedit /cdrom/syslinux/txt.cfg
- Locate the first
append
line and replace:
initrd=/casper/initrd.lz
With:
initrd=/casper/initrd.lz basemountmode=ro,noatime,uid=999,gid=999
- Note: On Ubuntu 10.04, the file might be named
text.cfg
- Save and exit
- Reboot and boot again from your USB
What You Can Do Now
- Save documents, media, or configs from Linux to your USB
- Access files added in Windows from Linux
- Create persistent like storage without needing a separate casper-rw partition
Troubleshooting Tips
- Not saving to /cdrom? Double check your mountmode and
casper
edits. - Permission issues? Ensure you're using
uid=999,gid=999
for the default user. - File system not writable? Make sure the USB is formatted FAT32 or a supported writable file system.
Frequently Asked Questions
- Can I use a bootable USB to transfer files between Ubuntu and Windows?
- Yes, by modifying the
casper
script, you can enable read/write access and use your USB drive to allow for sharing files between both operating systems. - Why can't I write files to the Ubuntu USB drive?
- By default, Ubuntu Live mounts the USB drive in read only mode for non root users. This guide shows how to change that behavior and enable write support.
- Is this method better than persistence for sharing files?
- Yes, especially for quick file transfers. It allows simple sharing between Windows and Linux without the need for a separate
casper-rw
persistence partition. - Does this work with Linux Mint or other Ubuntu-based systems?
- Yes. This method works with Linux Mint, Kubuntu, and most Debian-based distributions that use the
casper
boot system.
Final Thoughts
With this modified casper setup, your Ubuntu Live USB now acts as both a bootable OS and a file sharing medium. This gives you true flexibility to carry files across systems, tweak configs on the fly, or simply back up your data. Kudos to Julian Chennales for submitting the original technique of sharing files to Pendrive Linux, which has since been kept updated by Lance.
Bonus Tips: Want persistence too? Try YUMI exFAT to boot multiple ISOs and retain settings between sessions. Learn more about the casper boot system options from the official Ubuntu documentation.