diff options
| author | Samuli Piippo <samuli.piippo@qt.io> | 2016-11-04 12:56:13 +0200 |
|---|---|---|
| committer | Samuli Piippo <samuli.piippo@qt.io> | 2016-11-04 12:26:14 +0000 |
| commit | 54b5310b4b32c1412840fe595a6cad5b88132c24 (patch) | |
| tree | c1671970a2089dcd27d5a37211e55a402672e532 /scripts/mount-image.sh | |
| parent | 54e2ff14df39882fbb09861bb90b035eba4ee64c (diff) | |
| download | meta-boot2qt-54b5310b4b32c1412840fe595a6cad5b88132c24.tar.gz | |
Add helper script to mount partitions from images
Change-Id: Iefd2a7fce7ae074dfa305da52e1efea1073331a9
Reviewed-by: Risto Avila <risto.avila@qt.io>
Diffstat (limited to 'scripts/mount-image.sh')
| -rwxr-xr-x | scripts/mount-image.sh | 55 |
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 | |||
| 31 | set -e | ||
| 32 | |||
| 33 | if [ $# -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 | ||
| 37 | fi | ||
| 38 | |||
| 39 | IMAGE=$1 | ||
| 40 | |||
| 41 | if [ ! -f "${IMAGE}" ]; then | ||
| 42 | echo "Image '${IMAGE}' not found" | ||
| 43 | exit 1 | ||
| 44 | fi | ||
| 45 | |||
| 46 | mkdir -p boot | ||
| 47 | mkdir -p root | ||
| 48 | |||
| 49 | sudo umount boot root || true | ||
| 50 | |||
| 51 | OFFSET=$(parted "${IMAGE}" unit B print | grep "^ 1" | awk {'print $2'} | cut -d B -f 1) | ||
| 52 | sudo mount -o loop,offset=${OFFSET} "${IMAGE}" boot | ||
| 53 | |||
| 54 | OFFSET=$(parted "${IMAGE}" unit B print | grep "^ 2" | awk {'print $2'} | cut -d B -f 1) | ||
| 55 | sudo mount -o loop,offset=${OFFSET} "${IMAGE}" root | ||
