#!/bin/bash # SPDX-License-Identifier: LicenseRef-Unisoc-General-1.0 # # Copyright 2016-2023 Unisoc (Shanghai) Technologies Co., Ltd # # Licensed under the Unisoc General Software License, version 1.0 (the License); # you may not use this file except in compliance with the License. You may obtain a copy of the License at # # https://www.unisoc.com/en_us/license/UNISOC_GENERAL_LICENSE_V1.0-EN_US # # Software distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OF ANY KIND, either express or implied. # See the Unisoc General Software License, version 1.0 for more details. # MOUNT_POINT="rootfs" function mnt() { mkdir -p ${MOUNT_POINT} sudo mount -t ext4 -o loop $2 ${MOUNT_POINT} sudo cp /usr/bin/qemu-aarch64-static ${MOUNT_POINT}/usr/bin/ cp /etc/resolv.conf ~/ sudo mount -t proc /proc ${MOUNT_POINT}/proc sudo mount -t sysfs /sys ${MOUNT_POINT}/sys sudo mount -o bind /dev ${MOUNT_POINT}/dev sudo mount -o bind /dev/pts ${MOUNT_POINT}/dev/pts sudo mount -o bind ${HOME} ${MOUNT_POINT}/mnt sudo chroot ${MOUNT_POINT} } function umnt() { sudo umount ${MOUNT_POINT}/mnt sudo umount ${MOUNT_POINT}/proc sudo umount ${MOUNT_POINT}/sys sudo umount ${MOUNT_POINT}/dev/pts sudo umount ${MOUNT_POINT}/dev sudo umount ${MOUNT_POINT} } if [ "$1" == "-m" ] && [ -n "$2" ] ; then mnt $1 $2 elif [ "$1" == "-u" ] ; then umnt $1 else echo "1'st parameter can be one of these: -m(mount) OR -u(umount)" echo "2'nd parameter is ubuntu.ext4" echo "" echo "For example: ch-mount -m ubuntu.ext4" echo "" echo 1st parameter : ${1} echo 2nd parameter : ${2} fi