mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
Revert "create_virtualimage: extend script with:"
This reverts commit 467914e8fde4828f5bee79c13f2fff4fa1e8da00. needs rework: - $4 (system part size?) should be optional - /dev/loopXpX don't work on many distros. 'losetup -o' should be used
This commit is contained in:
parent
9d92ab174e
commit
00243d7dde
@ -20,56 +20,46 @@
|
|||||||
# http://www.gnu.org/copyleft/gpl.html
|
# http://www.gnu.org/copyleft/gpl.html
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# usage: sudo ./create_virtualmachine <path> <size(MB)> [<type>] [system partition size(MB)]
|
# usage: sudo ./create_virtualmachine <path> <size(MB)> [<type>]
|
||||||
# example: sudo ./create_virtualmachine /home/test/VM 512 [vdi] [128]
|
# example: sudo ./create_virtualmachine /home/test/VM 512 [vdi]
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
clear
|
clear
|
||||||
echo "##############################################################"
|
echo "###########################################################"
|
||||||
echo "# please execute with 'sudo' or -DANGEROUS!!!- as root #"
|
echo "# please execute with 'sudo' or -DANGEROUS!!!- as root #"
|
||||||
echo "# example: #"
|
echo "# example: #"
|
||||||
echo "# sudo ./create_virtualmachine <path> <size(MB)> [<type>] #"
|
echo "# sudo ./create_virtualmachine <path> <size(MB)> [<type>] #"
|
||||||
echo "##############################################################"
|
echo "###########################################################"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$1" -o -z "$2" ]; then
|
if [ -z "$1" -o -z "$2" ]; then
|
||||||
clear
|
clear
|
||||||
echo "##############################################################"
|
echo "###########################################################"
|
||||||
echo "# please execute as follows #"
|
echo "# please execute as follows #"
|
||||||
echo "# example: #"
|
echo "# example: #"
|
||||||
echo "# sudo ./create_virtualmachine <path> <size(MB)> [<type>] #"
|
echo "# sudo ./create_virtualmachine <path> <size(MB)> [<type>] #"
|
||||||
echo "##############################################################"
|
echo "###########################################################"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$1" ]; then
|
|
||||||
clear
|
|
||||||
echo "##############################################################"
|
|
||||||
echo "# please create target directory #"
|
|
||||||
echo "# example: #"
|
|
||||||
echo "# mkdir <path> #"
|
|
||||||
echo "##############################################################"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$2" -lt "200" -o "$2" -gt "2048" ]; then
|
if [ "$2" -lt "200" -o "$2" -gt "2048" ]; then
|
||||||
clear
|
clear
|
||||||
echo "##############################################################"
|
echo "#########################################################"
|
||||||
echo "# use a value between 200MB and 2048MB (2GB) #"
|
echo "# use a value between 200MB and 2048MB (2GB) #"
|
||||||
echo "# example: #"
|
echo "# example: #"
|
||||||
echo "# sudo ./create_virtualmachine /home/test/VM 512 #"
|
echo "# sudo ./create_virtualmachine /home/test/VM 512 #"
|
||||||
echo "##############################################################"
|
echo "#########################################################"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$3" -a "$3" != "vdi" -a "$3" != "vmdk" ]; then
|
if [ ! -z "$3" -a "$3" != "vdi" -a "$3" != "vmdk" ]; then
|
||||||
clear
|
clear
|
||||||
echo "##############################################################"
|
echo "#########################################################"
|
||||||
echo "# only vdi or vmdk types are supported #"
|
echo "# only vdi or vmdk types are supported #"
|
||||||
echo "# example: #"
|
echo "# example: #"
|
||||||
echo "# sudo ./create_virtualmachine /home/test/VM 512 [vdi] #"
|
echo "# sudo ./create_virtualmachine /home/test/VM 512 [vdi] #"
|
||||||
echo "##############################################################"
|
echo "#########################################################"
|
||||||
exit 1
|
exit 1
|
||||||
elif [ "$3" = "vdi" ]; then
|
elif [ "$3" = "vdi" ]; then
|
||||||
TYPE="vdi"
|
TYPE="vdi"
|
||||||
@ -77,21 +67,9 @@ elif [ -z "$3" -o "$3" = "vmdk" ]; then
|
|||||||
TYPE="vmdk"
|
TYPE="vmdk"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$4" -lt "128" -o "$4" -gt "1024" -o "$4" -gt "$2" ]; then
|
|
||||||
clear
|
|
||||||
echo "##############################################################"
|
|
||||||
echo "# use a value between 128MB and 1024MB #"
|
|
||||||
echo "# example: #"
|
|
||||||
echo "# sudo ./create_virtualmachine /home/test/VM 512 [vdi] [256] #"
|
|
||||||
echo "##############################################################"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
DISK="$1/OpenELEC.img"
|
DISK="$1/OpenELEC.img"
|
||||||
IMAGE="$1/OpenELEC.$TYPE"
|
IMAGE="$1/OpenELEC.$TYPE"
|
||||||
LOOP=$(losetup -f)
|
LOOP=$(losetup -f)
|
||||||
SYSTEM_PART_SIZE=$(( $4 / 8 ))
|
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo "#########################################################"
|
echo "#########################################################"
|
||||||
@ -123,22 +101,6 @@ echo "#########################################################"
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# this is needed to create a bootloader
|
|
||||||
which extlinux > /dev/null
|
|
||||||
if [ "$?" = "1" ]; then
|
|
||||||
clear
|
|
||||||
echo "#########################################################"
|
|
||||||
echo "# #"
|
|
||||||
echo "# OpenELEC.tv missing tool - Installation will quit #"
|
|
||||||
echo "# #"
|
|
||||||
echo "# We can't find the required tool \"extlinux\" #"
|
|
||||||
echo "# on your system. #"
|
|
||||||
echo "# Please install it via your package manager. #"
|
|
||||||
echo "# #"
|
|
||||||
echo "#########################################################"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# this is needed by syslinux
|
# this is needed by syslinux
|
||||||
which mcopy > /dev/null
|
which mcopy > /dev/null
|
||||||
if [ "$?" = "1" ]; then
|
if [ "$?" = "1" ]; then
|
||||||
@ -223,7 +185,7 @@ echo "#########################################################"
|
|||||||
|
|
||||||
# create an image
|
# create an image
|
||||||
echo "creating new empty harddisk image: $DISK..."
|
echo "creating new empty harddisk image: $DISK..."
|
||||||
dd if=/dev/zero of="$DISK" bs=1M count="$2"
|
dd if=/dev/zero of="$DISK" bs=1M count=1024
|
||||||
|
|
||||||
# write a disklabel
|
# write a disklabel
|
||||||
echo "creating new partition table: $DISK..."
|
echo "creating new partition table: $DISK..."
|
||||||
@ -232,11 +194,11 @@ echo "#########################################################"
|
|||||||
|
|
||||||
# create partition1
|
# create partition1
|
||||||
echo "creating partition1 on $DISK..."
|
echo "creating partition1 on $DISK..."
|
||||||
parted -s "$LOOP" unit cyl mkpart primary ext2 -- 0 "$SYSTEM_PART_SIZE"
|
parted -s "$LOOP" unit cyl mkpart primary ext2 -- 0 16
|
||||||
|
|
||||||
# create partition2
|
# create partition2
|
||||||
echo "creating partition2 on $DISK..."
|
echo "creating partition2 on $DISK..."
|
||||||
parted -s "$LOOP" unit cyl mkpart primary ext2 -- "$(( $SYSTEM_PART_SIZE + 1 ))" -2
|
parted -s "$LOOP" unit cyl mkpart primary ext2 -- 16 -2
|
||||||
|
|
||||||
# make partition1 active (bootable)
|
# make partition1 active (bootable)
|
||||||
echo "marking partition1 active..."
|
echo "marking partition1 active..."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user