ini 用于在引导时挂载ChrUbuntu分区(#7 / ROOT-C)的Chromebook init脚本。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ini 用于在引导时挂载ChrUbuntu分区(#7 / ROOT-C)的Chromebook init脚本。相关的知识,希望对你有一定的参考价值。

# 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 /mnt/ChrUbuntu-sda7"
author          "DennisLfromGA@github.com & drinkcat@github.com"

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

以上是关于ini 用于在引导时挂载ChrUbuntu分区(#7 / ROOT-C)的Chromebook init脚本。的主要内容,如果未能解决你的问题,请参考以下文章

如何安装Centos

Linux系统分区是啥格式的?

磁盘管理

用于挂载EFS存储的ECS容器实例的引导用户数据

安装linux系统必要的分区是啥?

怎么挂载efi分区