-
-
Save DennisLfromGA/b9e8715e6c6851bb827e to your computer and use it in GitHub Desktop.
| # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| description "mount CHRUBUNTU on /var/ChrUbuntu-sda7" | |
| author "[email protected] & [email protected]" | |
| start on starting boot-services | |
| task | |
| script | |
| # Exits the script with return code $1, spitting out message $@ to stderr | |
| error() { | |
| local ecode="$1" | |
| shift | |
| echo "$*" 1>&2 | |
| exit "$ecode" | |
| } | |
| # Find the root device | |
| # Sets: | |
| # - $ROOTDEVICE as the root device (e.g. /dev/sda or /dev/mmcblk0) | |
| # - $ROOTDEVICEPREFIX as a prefix for partitions (/dev/sda, /dev/mmcblk0p) | |
| findrootdevice() { | |
| ROOTDEVICE="`rootdev -d -s`" | |
| if [ -z "$ROOTDEVICE" ]; then | |
| error 1 "Cannot find root device." | |
| fi | |
| if [ ! -b "$ROOTDEVICE" ]; then | |
| error 1 "$ROOTDEVICE is not a block device." | |
| fi | |
| # If $ROOTDEVICE ends with a number (e.g. mmcblk0), partitions are named | |
| # ${ROOTDEVICE}pX (e.g. mmcblk0p1). If not (e.g. sda), they are named | |
| # ${ROOTDEVICE}X (e.g. sda1). | |
| ROOTDEVICEPREFIX="$ROOTDEVICE" | |
| if [ "${ROOTDEVICE%[0-9]}" != "$ROOTDEVICE" ]; then | |
| ROOTDEVICEPREFIX="${ROOTDEVICE}p" | |
| fi | |
| } | |
| # Define CHRUBUNTU mountpoint | |
| MOUNTCHRUBUNTU='/var/chrubuntu' | |
| # Try to mount the ChrUbuntu partition, if it exists, on $MOUNTCHRUBUNTU. | |
| mountchrubuntu() { | |
| if [ -z "$ROOTDEVICE" ]; then | |
| findrootdevice | |
| fi | |
| local chrubuntupart="`sudo cgpt find -n -l ROOT-C "$ROOTDEVICE"`" | |
| if [ -z "$chrubuntupart" ]; then | |
| return 1 | |
| elif [ ! "`sudo cgpt show -i "$chrubuntupart" -s "$ROOTDEVICE"`" -gt 1 ]; then | |
| return 1 | |
| fi | |
| PRIOR=' now' | |
| # Check if chrubuntu is mounted already | |
| if grep -q "^${ROOTDEVICEPREFIX}$chrubuntupart " /proc/mounts; then | |
| # If mounted, it must be mounted to $mountpoint | |
| if ! grep -q "^${ROOTDEVICEPREFIX}$chrubuntupart $MOUNTCHRUBUNTU " \ | |
| /proc/mounts; then | |
| error 1 "Error: CHRUBUNTU partition is not mounted on $MOUNTCHRUBUNTU." | |
| else | |
| PRIOR=' already' | |
| fi | |
| else | |
| sudo mkdir -p "$MOUNTCHRUBUNTU" || error 1 "Cannot create $MOUNTCHRUBUNTU." | |
| sudo mount "${ROOTDEVICEPREFIX}$chrubuntupart" "$MOUNTCHRUBUNTU" || \ | |
| error 1 "Cannot mount $MOUNTCHRUBUNTU" | |
| fi | |
| return 0 | |
| } | |
| # Now mount the CHRUBUNTU partition | |
| mountchrubuntu | |
| end script |
Thanks. Works perfectly. For Upstart noobs, might want to doc it's needed placement in /etc/init, and that it can be tested without reboot with "sudo start mnt-chrubuntu". In any case, once again, hugely helpful!
Thanks. Works perfectly. For Upstart noobs, might want to doc it's needed placement in /etc/init, and that it can be tested without reboot with "sudo start mnt-chrubuntu". In any case, once again, hugely helpful!
How do I place this script in the folder? Would really appreciate if you could help me out.
@CarlitoisLoco, You'll need to make the rootfs read-writable first by running:
sudo /usr/libexec/debugd/helpers/dev_features_rootfs_verification
Then reboot and place the mnt-chrubuntu.conf script in /etc/init. Then it will mount the partition each time you boot up.
Note tho that after each update you need to again make the rootfs read-writable and copy the script into /etc/init.
But, like @PCRyan mentioned, you can just start the script by itself or launching it in your .bashrc, etc. if you like.
Moved ChrUbuntu mountpoint to a rw area.