blob: 456f8206a0d5895a761c976678db40778637a8c9 [file] [log] [blame]
Bill Richardsona082f4e2010-07-24 01:20:581#!/bin/sh -ue
2# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5#
6# A script to locate the rootfs that corresponds to the kernel. Used in the
7# initramfs on the recovery image. The hard drive *should* be constant and so
8# won't need an initramfs.
9
10# Load functions and constants for chromeos-install.
11. "$(dirname "$0")/chromeos-common.sh" || exit 1
12
Bill Richardson68372332010-08-03 19:51:1713if [ "0" == $(id -u) ]; then
14 local sudo=""
15else
16 local sudo=sudo
17fi
18
Bill Richardsona082f4e2010-07-24 01:20:5819# Extract the kernel partition's UniqueGuid from the command line.
Bill Richardson68372332010-08-03 19:51:1720guid=$(sed 's/.*kern_guid=\([0-9a-fA-F-]\+\).*/\1/' /proc/cmdline)
Bill Richardsona082f4e2010-07-24 01:20:5821
22# Look through all the known devices to find that one partition.
Bill Richardson68372332010-08-03 19:51:1723kern_dev=$($sudo cgpt find -1 -u $guid)
Bill Richardsona082f4e2010-07-24 01:20:5824
25# That's the kernel, so increment the partition number to find the rootfs.
26base_dev=$(get_block_dev_from_partition_dev $kern_dev)
27kern_num=$(get_partition_number $kern_dev)
28root_num=$(expr $kern_num + 1)
29root_dev=$(make_partition_dev $base_dev $root_num)
30
31# done
32echo $root_dev