Initial commit from Ventoy@7cbdc5c
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
|
||||
search -f /EFI/VentoyLiveCD -s root
|
||||
configfile ($root)/EFI/boot/grub.cfg
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
VentoyLiveCD
|
||||
|
||||
https://www.ventoy.net
|
||||
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
|
||||
set timeout=3
|
||||
set default=LiveCD
|
||||
|
||||
clear
|
||||
|
||||
menuentry 'Ventoy xxx LiveCD' --id=LiveCD {
|
||||
linux /EFI/boot/vmlinuz64 quiet loglevel=0 superuser rdinit=/ventoy/init.sh
|
||||
initrd /EFI/ventoy/ventoy.gz /EFI/boot/corepure64.gz /EFI/boot/modules64.gz newc:ventoy.tar.gz:/EFI/ventoy/ventoy-xxx-linux.tar.gz
|
||||
boot
|
||||
}
|
||||
|
||||
menuentry 'Ventoy xxx LiveCD (Debug Mode)' {
|
||||
linux /EFI/boot/vmlinuz64 loglevel=10 multivt superuser rdinit=/ventoy/init.sh
|
||||
initrd /EFI/ventoy/ventoy.gz /EFI/boot/corepure64.gz /EFI/boot/modules64.gz newc:ventoy.tar.gz:/EFI/ventoy/ventoy-xxx-linux.tar.gz
|
||||
boot
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
|
||||
Ventoy LiveCD is Tinycore distro + Ventoy linux install package.
|
||||
|
||||
|
||||
vmlinuz and core.gz are downloaded from:
|
||||
http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/
|
||||
|
||||
MD5SUM:
|
||||
598db33adff41155f26e244e492916d0 corepure64.gz
|
||||
858a5b2524cc541efe2d22b11b271e52 modules64.gz
|
||||
ab3a8196df5a84889f16494fde188799 vmlinuz64
|
||||
|
||||
|
||||
VTOY/ventoy/tcz/*/tcz are downloaded from:
|
||||
http://distro.ibiblio.org/tinycorelinux/11.x/x86_64/tcz/
|
||||
|
||||
MD5SUM:
|
||||
803ac92b15e2ba58cddc58e1ff66446c dosfstools.tcz
|
||||
eaa8aafb285b3f3bdf89187a964436db glib2.tcz
|
||||
bbf81e97259faa73cbaf42b7e76c8685 libffi.tcz
|
||||
2cb278ef278a6b8819df52ec2e6bedc3 liblvm2.tcz
|
||||
0345a267ab49e711c596e21eaf721e3b ncursesw.tcz
|
||||
65e226c963e78a0174baf99bc9cafcfc parted.tcz
|
||||
ae78bbe0c5b7d79382cd1aeb08dc97bd readline.tcz
|
||||
dff3775dea468c31e517f5ec5f403ce0 udev-lib.tcz
|
||||
|
||||
|
||||
VTOY/ventoy/drivers/*.ko
|
||||
build kernel
|
||||
http://www.tinycorelinux.net/11.x/x86_64/release/src/kernel/
|
||||
config-5.4.3-tinycore64
|
||||
linux-5.4.3-patched.txz
|
||||
disable a wireless lan driver to avoid compile error
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef unsigned long long UINT64;
|
||||
|
||||
int GetHumanReadableGBSize(UINT64 SizeBytes)
|
||||
{
|
||||
int i;
|
||||
int Pow2 = 1;
|
||||
double Delta;
|
||||
double GB = SizeBytes * 1.0 / 1000 / 1000 / 1000;
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
if (Pow2 > GB)
|
||||
{
|
||||
Delta = (Pow2 - GB) / Pow2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Delta = (GB - Pow2) / Pow2;
|
||||
}
|
||||
|
||||
if (Delta < 0.05)
|
||||
{
|
||||
return Pow2;
|
||||
}
|
||||
|
||||
Pow2 <<= 1;
|
||||
}
|
||||
|
||||
return (int)GB;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
UINT64 value = strtoul(argv[1], NULL, 10);
|
||||
|
||||
printf("%d", GetHumanReadableGBSize(value * 512));
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
cat /ventoy/modlist | while read line; do
|
||||
if [ -e /ventoy/drivers/${line}.ko ]; then
|
||||
insmod /ventoy/drivers/${line}.ko
|
||||
fi
|
||||
done
|
||||
|
||||
sleep 5
|
||||
|
||||
echo "sh /ventoy/profile.sh" >> /root/.profile
|
||||
|
||||
ln -s /lib /lib64
|
||||
exec /init
|
||||
@@ -0,0 +1,25 @@
|
||||
scsi_transport_sas
|
||||
mptbase
|
||||
mptscsih
|
||||
mptsas
|
||||
yurex
|
||||
ezusb
|
||||
parport
|
||||
uss720
|
||||
usb4604
|
||||
usb3503
|
||||
sisusbvga
|
||||
usb251xb
|
||||
pi3usb30532
|
||||
usb-otg-fsm
|
||||
ums-realtek
|
||||
xhci-hcd
|
||||
xhci-pci
|
||||
xhci-plat-hcd
|
||||
usbip-core
|
||||
usbip-host
|
||||
vhci-hcd
|
||||
cdc-wdm
|
||||
cdc-acm
|
||||
usblp
|
||||
megaraid_sas
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
cd /
|
||||
tar -xf ventoy.tar.gz
|
||||
|
||||
cd /ventoy
|
||||
mkdir mnt
|
||||
for i in $(ls tcz/*.tcz); do
|
||||
mount $i mnt
|
||||
cp -a mnt/* /
|
||||
umount mnt
|
||||
done
|
||||
|
||||
ldconfig /usr/local/lib /usr/lib /lib
|
||||
|
||||
#workaround for swapon
|
||||
rm -f /sbin/swapon
|
||||
echo '#!/bin/sh' > /sbin/swapon
|
||||
chmod +x /sbin/swapon
|
||||
|
||||
sh /ventoy/ventoy.sh
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,298 @@
|
||||
#!/bin/sh
|
||||
|
||||
info() {
|
||||
echo -e "\033[32m$*\033[0m"
|
||||
}
|
||||
|
||||
warn() {
|
||||
echo -e "\033[33m$*\033[0m"
|
||||
}
|
||||
|
||||
err() {
|
||||
echo -e "\033[31m$*\033[0m"
|
||||
}
|
||||
|
||||
get_disk_size() {
|
||||
sec=$(cat /sys/block/$1/size)
|
||||
/ventoy/disksize $sec
|
||||
}
|
||||
|
||||
enum_disk() {
|
||||
id=1
|
||||
rm -f /device.list
|
||||
ls /sys/block/ | egrep 'd[a-z]|nvme|mmc|nbd' | while read dev; do
|
||||
if ! [ -b /dev/$dev ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
size=$(get_disk_size $dev)
|
||||
model=$(parted -s /dev/$dev p 2>/dev/null | grep Model | sed 's/Model: \(.*\)/\1/')
|
||||
printf " <%d> %-4s %3s GB %s\r\n" $id "$dev" "$size" "$model" >> /device.list
|
||||
id=$(expr $id + 1)
|
||||
done
|
||||
}
|
||||
|
||||
select_disk() {
|
||||
|
||||
echo "" > /dev/console
|
||||
echo "" > /dev/console
|
||||
|
||||
if [ -f /device.list ]; then
|
||||
lines=$(cat /device.list | wc -l)
|
||||
cat /device.list > /dev/console
|
||||
else
|
||||
echo -e "\033[31m !!! NO device detected !!!\033[0m" > /dev/console
|
||||
lines=0
|
||||
fi
|
||||
|
||||
echo "" > /dev/console
|
||||
echo " <a> Refresh device list <b> Reboot <c> Enter shell" > /dev/console
|
||||
echo "" > /dev/console
|
||||
|
||||
while true; do
|
||||
|
||||
if [ $lines -gt 0 ]; then
|
||||
read -p "Please select the disk to operator [1-$lines] " Answer
|
||||
else
|
||||
read -p "Please choose your operation [a-c] " Answer
|
||||
fi
|
||||
|
||||
if [ "$Answer" = "shell" ]; then
|
||||
echo 8888; return
|
||||
elif [ "$Answer" = "c" ] || [ "$Answer" = "C" ]; then
|
||||
echo 8888; return
|
||||
fi
|
||||
|
||||
if [ "$Answer" = "a" ] || [ "$Answer" = "A" ]; then
|
||||
echo 0; return
|
||||
elif [ "$Answer" = "b" ] || [ "$Answer" = "B" ]; then
|
||||
read -p "Do you really want to reboot? (y/n) " Ask
|
||||
if [ "$Ask" = "y" ] || [ "$Ask" = "Y" ]; then
|
||||
reboot
|
||||
else
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$Answer" ]; then
|
||||
if echo $Answer | grep -q "^[1-9][0-9]*$"; then
|
||||
if [ $Answer -gt 0 ] && [ $Answer -le $lines ]; then
|
||||
echo $Answer
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
get_dev_ventoy_ver() {
|
||||
if ! [ -b /dev/${1}2 ]; then
|
||||
echo "NO"; return
|
||||
fi
|
||||
|
||||
mount -t vfat -o ro /dev/${1}2 /ventoy/mnt >/dev/null 2>/dev/null
|
||||
if [ -e /ventoy/mnt/ventoy ] && [ -f /ventoy/mnt/grub/grub.cfg ]; then
|
||||
if grep -q 'set.*VENTOY_VERSION=' /ventoy/mnt/grub/grub.cfg; then
|
||||
grep 'set.*VENTOY_VERSION=' /ventoy/mnt/grub/grub.cfg | awk -F'"' '{print $2}'
|
||||
else
|
||||
echo 'NO'
|
||||
fi
|
||||
|
||||
umount /ventoy/mnt
|
||||
return
|
||||
fi
|
||||
|
||||
echo "NO"
|
||||
}
|
||||
|
||||
ventoy_configuration() {
|
||||
while true; do
|
||||
|
||||
if [ -f /preserve.txt ]; then
|
||||
SPACE=$(cat /preserve.txt)
|
||||
else
|
||||
SPACE=0
|
||||
fi
|
||||
|
||||
if [ -f /secureboot.txt ]; then
|
||||
SECURE=$(cat /secureboot.txt)
|
||||
else
|
||||
SECURE=Disable
|
||||
fi
|
||||
|
||||
if [ -f /partstyle.txt ]; then
|
||||
STYLE=$(cat /partstyle.txt)
|
||||
else
|
||||
STYLE=MBR
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e " <1> Preserve space (only for install) \033[32m[${SPACE}MB]\033[0m"
|
||||
echo -e " <2> Secure boot support \033[32m[$SECURE]\033[0m"
|
||||
echo -e " <3> Partition style (only for install) \033[32m[$STYLE]\033[0m"
|
||||
echo " <0> Back to previous menu"
|
||||
echo ""
|
||||
|
||||
while true; do
|
||||
read -p "Please choose your operation: " Answer
|
||||
if echo $Answer | grep -q "^[0-3]$"; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$Answer" = "0" ]; then
|
||||
break
|
||||
elif [ "$Answer" = "1" ]; then
|
||||
while true; do
|
||||
read -p "Please input the preserve space in MB: " Answer
|
||||
if echo $Answer | grep -q "^[0-9][0-9]*$"; then
|
||||
echo $Answer > /preserve.txt
|
||||
break
|
||||
fi
|
||||
done
|
||||
elif [ "$Answer" = "2" ]; then
|
||||
if [ "$SECURE" = "Disable" ]; then
|
||||
echo "Enable" > /secureboot.txt
|
||||
else
|
||||
echo "Disable" > /secureboot.txt
|
||||
fi
|
||||
else
|
||||
if [ "$STYLE" = "GPT" ]; then
|
||||
echo "MBR" > /partstyle.txt
|
||||
else
|
||||
echo "GPT" > /partstyle.txt
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
cd /
|
||||
VTPATH=$(ls -1 | grep ventoy-)
|
||||
VTVER=${VTPATH#*-}
|
||||
|
||||
cd $VTPATH
|
||||
|
||||
clear
|
||||
|
||||
echo ""
|
||||
info "**************************************************"
|
||||
vline=$(printf "* Ventoy LiveCD %6s *\r\n" "$VTVER")
|
||||
info "$vline"
|
||||
info "**************************************************"
|
||||
echo ""
|
||||
info "Scanning devices ......"
|
||||
sleep 5
|
||||
|
||||
enum_disk
|
||||
|
||||
while true; do
|
||||
sel=$(select_disk)
|
||||
|
||||
if [ $sel -eq 8888 ]; then
|
||||
break
|
||||
elif [ $sel -eq 0 ]; then
|
||||
enum_disk
|
||||
continue
|
||||
fi
|
||||
|
||||
DEV=$(sed -n "${sel}p" /device.list | awk '{print $2}')
|
||||
DevVtVer=$(get_dev_ventoy_ver $DEV)
|
||||
|
||||
|
||||
if [ "$DevVtVer" = "NO" ]; then
|
||||
|
||||
while true; do
|
||||
echo ""
|
||||
echo " <1> Install Ventoy to $DEV"
|
||||
echo " <2> Set Configuration"
|
||||
echo " <0> Back to previous menu"
|
||||
echo ""
|
||||
|
||||
while true; do
|
||||
read -p "Please choose your operation: " Answer
|
||||
if echo $Answer | grep -q "^[0-2]$"; then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$Answer" = "0" ]; then
|
||||
break
|
||||
elif [ "$Answer" = "2" ]; then
|
||||
ventoy_configuration
|
||||
else
|
||||
|
||||
opt=""
|
||||
if [ -f /preserve.txt ]; then
|
||||
opt="$opt -r $(cat /preserve.txt)"
|
||||
fi
|
||||
|
||||
if [ -f /secureboot.txt ] && grep -q "Enable" /secureboot.txt; then
|
||||
opt="$opt -s"
|
||||
fi
|
||||
|
||||
if [ -f /partstyle.txt ] && grep -q "GPT" /partstyle.txt; then
|
||||
opt="$opt -g"
|
||||
fi
|
||||
|
||||
info "Ventoy2Disk.sh $opt -i /dev/$DEV"
|
||||
sh Ventoy2Disk.sh $opt -i /dev/$DEV
|
||||
sync
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
info "Ventoy $DevVtVer detected in the device $DEV"
|
||||
|
||||
while true; do
|
||||
echo ""
|
||||
echo " <1> Update Ventoy in $DEV from $DevVtVer ==> $VTVER"
|
||||
echo " <2> Re-install Ventoy to $DEV"
|
||||
echo " <3> Set Configuration"
|
||||
echo " <0> Back to previous menu"
|
||||
echo ""
|
||||
|
||||
while true; do
|
||||
read -p "Please choose your operation: " Answer
|
||||
if echo $Answer | grep -q "^[0-3]$"; then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$Answer" = "0" ]; then
|
||||
break
|
||||
elif [ "$Answer" = "1" ]; then
|
||||
opt=""
|
||||
if [ -f /secureboot.txt ] && grep -q "Enable" /secureboot.txt; then
|
||||
opt="$opt -s"
|
||||
fi
|
||||
|
||||
info "Ventoy2Disk.sh $opt -u /dev/$DEV"
|
||||
sh Ventoy2Disk.sh $opt -u /dev/$DEV
|
||||
sync
|
||||
break
|
||||
elif [ "$Answer" = "2" ]; then
|
||||
opt=""
|
||||
if [ -f /preserve.txt ]; then
|
||||
opt="$opt -r $(cat /preserve.txt)"
|
||||
fi
|
||||
|
||||
if [ -f /secureboot.txt ] && grep -q "Enable" /secureboot.txt; then
|
||||
opt="$opt -s"
|
||||
fi
|
||||
|
||||
if [ -f /partstyle.txt ] && grep -q "GPT" /partstyle.txt; then
|
||||
opt="$opt -g"
|
||||
fi
|
||||
|
||||
info "Ventoy2Disk.sh $opt -I /dev/$DEV"
|
||||
sh Ventoy2Disk.sh $opt -I /dev/$DEV
|
||||
sync
|
||||
break
|
||||
else
|
||||
ventoy_configuration
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$1" = "CI" ]; then
|
||||
OPT='-dR'
|
||||
else
|
||||
OPT='-a'
|
||||
fi
|
||||
|
||||
VENTOY_PATH=$PWD/../
|
||||
|
||||
if ! [ -f $VENTOY_PATH/INSTALL/grub/grub.cfg ]; then
|
||||
echo "no grub.cfg detected"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version=$(grep 'set.*VENTOY_VERSION=' $VENTOY_PATH/INSTALL/grub/grub.cfg | awk -F'"' '{print $2}')
|
||||
|
||||
if ! [ -e $VENTOY_PATH/INSTALL/ventoy-${version}-linux.tar.gz ]; then
|
||||
echo "no ventoy-${version}-linux.tar.gz detected"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf ISO_TMP
|
||||
cp -a ISO ISO_TMP
|
||||
|
||||
cp -a VTOY VTOY_TMP
|
||||
|
||||
ls -la
|
||||
if ! [ -d ISO_TMP ]; then
|
||||
echo "Copy ISO_TMP failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -d VTOY_TMP ]; then
|
||||
echo "Copy VTOY_TMP failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p ISO_TMP/EFI/ventoy
|
||||
cd VTOY_TMP
|
||||
|
||||
gcc -O2 ./ventoy/disksize.c -o ./ventoy/disksize
|
||||
|
||||
rm -f ./ventoy/disksize.c
|
||||
|
||||
chmod +x ./ventoy/*.sh
|
||||
find . | cpio -o -H newc | gzip -c -9 > ../ISO_TMP/EFI/ventoy/ventoy.gz
|
||||
cd .. && rm -rf VTOY_TMP
|
||||
|
||||
|
||||
cp -a $VENTOY_PATH/INSTALL/ventoy-${version}-linux.tar.gz ISO_TMP/EFI/ventoy/
|
||||
cp -a GRUB/cdrom.img ISO_TMP/EFI/boot/
|
||||
cp -a GRUB/bootx64.efi ISO_TMP/EFI/boot/
|
||||
|
||||
|
||||
rm -rf efimnt
|
||||
rm -f efi.img
|
||||
mkdir -p efimnt
|
||||
|
||||
dd if=/dev/zero of=efi.img bs=1M count=2
|
||||
mkfs.vfat efi.img
|
||||
mount efi.img efimnt
|
||||
mkdir -p efimnt/EFI/boot
|
||||
cp $OPT GRUB/bootx64.efi efimnt/EFI/boot/
|
||||
umount efimnt
|
||||
|
||||
sync
|
||||
cp -a efi.img ISO_TMP/EFI/boot/
|
||||
|
||||
rm -rf efimnt
|
||||
rm -f efi.img
|
||||
|
||||
|
||||
cd ISO_TMP
|
||||
|
||||
sed "s/xxx/$version/g" -i EFI/boot/grub.cfg
|
||||
|
||||
rm -f ../ventoy-${version}-livecd.iso
|
||||
|
||||
xorriso -as mkisofs -allow-lowercase --sort-weight 0 / --sort-weight 1 /EFI -v -R -J -V 'VentoyLiveCD' -P 'VENTOY COMPATIBLE' -p 'https://www.ventoy.net' -sysid 'Ventoy' -A 'VentoyLiveCD' -b EFI/boot/cdrom.img --grub2-boot-info --grub2-mbr ../GRUB/boot_hybrid.img -c EFI/boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e EFI/boot/efi.img -no-emul-boot -append_partition 2 0xEF EFI/boot/efi.img -o ../ventoy-${version}-livecd.iso .
|
||||
|
||||
cd ../
|
||||
rm -rf ISO_TMP
|
||||
|
||||
Reference in New Issue
Block a user