Mounting External Storage within Crouton Chroot Automatically

Having installed crouton on my Acer C720 chromebook, I wanted a way to automatically mount some additional storage within the Linux environment, that could be used to store, for example, Steam or other games.

The 64GB Sandisk Ultra Fit USB3 drives seemed to fit the bill nicely, being compact enough to leave in place permanently, and offering fast read and write speeds compared to USB2 drives.

Plug the drive into the USB3 port, then enter your Crouton chroot environment. I chose to format the drive as EXT4, as this works with both the Linux and the ChromeOS environment. The easiest way to do this is to install gparted, which you can do with the following command: –

sudo apt-get update && sudo apt-get install gparted

Run gparted, select the 64GB USB drive (make sure you choose the right drive!) and unmount the partition if mounted (which you can do from within gparted).

Delete the existing FAT32 partition, then create a new primary partition, with EXT4 file system.

We cannot mount the USB drive using the normal methods (e.g. via fstab) as fstab is not used within the Linux chroot. I found some guides online using bash scripts that would execute upon loading the the desktop environment, but they need root permissions which requires typing the root password every time you enter the chroot, which is a pain.

A bit more digging around revealed that adding a mount command to etc/rc.local would be executed, with root permissions at startup. To ensure that the correct device is mounted I used the /dev/disk/by-uuid descriptor, rather than the normal /dev/sdx descriptor, just in case another storage device is connected and the disk locations change.

Browse to the disk/by-uuid folder: –

cd /dev/disk/by-uuid

ls -al
total 0
drwxr-xr-x 2 root root 140 Mar 11 21:52 .
drwxr-xr-x 8 root root 160 Mar 11 21:52 ..
lrwxrwxrwx 1 root root 10 Mar 11 21:52 5ac60ebc-c8d7-431f-abae-48c067b64f87 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Mar 11 21:52 7f1b2ecd-c11a-4031-ba96-199d08d27a52 -> ../../dm-1
lrwxrwxrwx 1 root root 10 Mar 11 21:52 9dff32a0-220f-449d-a401-c27eaab4452b -> ../../sda8
lrwxrwxrwx 1 root root 11 Mar 11 21:52 DAD8-4C47 -> ../../sda12
lrwxrwxrwx 1 root root 10 Mar 11 21:52 b1554480-e263-4ed5-9bb1-98ff83ab7301 -> ../../sda1

Look for the UUID associated with the device that correlates with the USB drive, in this case it’s 5ac60ebc-c8d7-431f-abae-48c067b64f87 -> ../../sdb1

Add the mount command in the appropriate place in /etc/rc.local: –

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
mount /dev/disk/by-uuid/5ac60ebc-c8d7-431f-abae-48c067b64f87 /home/andrew/external

exit 0

In the case above I’m mounting the USB drive in my home folder, within a folder named external.

We need to create this folder, which you can do within your file explorer, or with the following command: –

mkdir /home/user/external

Where user is your user name within the chroot environment.

Restart the chroot environment and you should now find the USB storage is mounted within the external folder within your home directory.

The last step is you will find the folder is owned by root currently, which will prevent applications, like Steam, using it.

Change the ownership of the external folder with the following command: –

sudo chown -R user:user /home/user/external

Where user is your username within the chroot environment.

You can use this folder to store larger downloads and games without using the limited storage available on the Chromebook’s internal SSD, within Steam you can add a folder within the external drive and then tell Steam to download games to this location.

When not mounted in the chroot environment it’s visible and available to use with ChromeOS too.

Screenshot 2015-03-11 at 23.16.41

Enjoy!

This entry was posted in ChromeOS, Linux, Technical. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *