summaryrefslogtreecommitdiffstats
path: root/scripts/mount-image.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mount-image.sh')
-rwxr-xr-xscripts/mount-image.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/mount-image.sh b/scripts/mount-image.sh
new file mode 100755
index 0000000..434530d
--- /dev/null
+++ b/scripts/mount-image.sh
@@ -0,0 +1,55 @@
1#!/bin/sh
2############################################################################
3##
4## Copyright (C) 2016 The Qt Company Ltd.
5## Contact: https://www.qt.io/licensing/
6##
7## This file is part of the Boot to Qt meta layer.
8##
9## $QT_BEGIN_LICENSE:GPL$
10## Commercial License Usage
11## Licensees holding valid commercial Qt licenses may use this file in
12## accordance with the commercial license agreement provided with the
13## Software or, alternatively, in accordance with the terms contained in
14## a written agreement between you and The Qt Company. For licensing terms
15## and conditions see https://www.qt.io/terms-conditions. For further
16## information use the contact form at https://www.qt.io/contact-us.
17##
18## GNU General Public License Usage
19## Alternatively, this file may be used under the terms of the GNU
20## General Public License version 3 or (at your option) any later version
21## approved by the KDE Free Qt Foundation. The licenses are as published by
22## the Free Software Foundation and appearing in the file LICENSE.GPL3
23## included in the packaging of this file. Please review the following
24## information to ensure the GNU General Public License requirements will
25## be met: https://www.gnu.org/licenses/gpl-3.0.html.
26##
27## $QT_END_LICENSE$
28##
29############################################################################
30
31set -e
32
33if [ $# -ne 1 ]; then
34 echo "Usage: $0 <image>"
35 echo "Mount the two partitions (boot and rootfs) from the image to current folder"
36 exit 1
37fi
38
39IMAGE=$1
40
41if [ ! -f "${IMAGE}" ]; then
42 echo "Image '${IMAGE}' not found"
43 exit 1
44fi
45
46mkdir -p boot
47mkdir -p root
48
49sudo umount boot root || true
50
51OFFSET=$(parted "${IMAGE}" unit B print | grep "^ 1" | awk {'print $2'} | cut -d B -f 1)
52sudo mount -o loop,offset=${OFFSET} "${IMAGE}" boot
53
54OFFSET=$(parted "${IMAGE}" unit B print | grep "^ 2" | awk {'print $2'} | cut -d B -f 1)
55sudo mount -o loop,offset=${OFFSET} "${IMAGE}" root