Chromebooks with Linux offer convenient file sharing capabilities between the main ChromeOS environment and the Linux subsystem.
Key features:
/mnt/chromeos/MyFiles/
. Applications and command-line tools within Linux can read and write to these shared folders.These features make it simple to move files between ChromeOS and Linux applications while maintaining security and user control.
To access your ChromeOS files from within the Ubuntu container, you need to configure shared directories.
You can share directories using the ChromeOS Files application. Right-click on any directory and select Share with Linux.
If you share a ChromeOS directory, it appears in /mnt/chromeos/MyFiles/
in your Ubuntu container. For example, share your Downloads directory in ChromeOS and it is visible in Ubuntu:
ls /mnt/chromeos/MyFiles/Downloads/
You can also share Google Drive directories using the ChromeOS Files application. Use the same right-click and select Share with Linux.
If you share a Google Drive folder, it appears in /mnt/chromeos/GoogleDrive/MyDrive/
in your Ubuntu container. For example, share your AndroidAssets
directory in Google Drive and it is visible in Ubuntu:
ls /mnt/chromeos/GoogleDrive/MyDrive/AndroidAssets
Your shared folders appear in the Linux settings under Manage shared folders as shown below:
Shared folders
You can also share folders using the Termina shell.
Mount the entire ChromeOS file system to /mnt/chromeos
in the container:
lxc config device add ubuntu-main shared-chromeos disk source=/mnt/chromeos path=/mnt/chromeos
Share your ChromeOS Downloads folder with the container:
lxc config device add ubuntu-main downloads disk source=/mnt/chromeos/MyFiles/Downloads path=/home/username/Downloads
Share your ChromeOS Documents folder with the container:
lxc config device add ubuntu-main documents disk source=/mnt/chromeos/MyFiles/Documents path=/home/username/Documents
You can use the lxc file
command to copy files to and from a container from the Termina shell.
As an example, create a file named file1
:
echo "test file 1" >> /mnt/shared/MyFiles/Downloads/file1
Copy the file from your ChromeOS Downloads folder to the /tmp
directory in the container:
lxc file push file1 u1/tmp/file1
Copy the same file back to the Downloads directory with a new name:
lxc file pull u1/tmp/file1 file2
You now have the file in your Downloads directory with a new name.