ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
+blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
+vtDM=$(ventoy_find_dm_id ${blkdev_num})
+vtlog "blkdev_num=$blkdev_num vtDM=$vtDM ..."
+
+while [ -n "Y" ]; do
+ if [ -b /dev/$vtDM ]; then
+ break
+ else
+ sleep 0.3
+ fi
+done
+
if [ -n "$1" ]; then
- blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
- vtDM=$(ventoy_find_dm_id ${blkdev_num})
-
vtlog "ln -s /dev/$vtDM $1"
ln -s /dev/$vtDM "$1"
+else
+ vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
+ vtlog "vtLABEL is $vtLABEL"
+
+ if [ -z "$vtLABEL" ]; then
+ vtLABEL=$($SED "s/.*label=\([^ ]*\)/\1/" /proc/cmdline)
+ vtlog "vtLABEL is $vtLABEL from cmdline"
+ fi
+
+ ln -s /dev/$vtDM "/dev/disk/by-label/$vtLABEL"
fi
# OK finish
set_ventoy_hook_finish
-
vthookfile=/hooks/archiso
- if [ -e /hook/miso ]; then
+ if [ -e /hooks/miso ]; then
vthookfile=/hooks/miso
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$misodevice\"" -i /init
+ elif [ -e /hooks/artix ]; then
+ vthookfile=/hooks/artix
+ $SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$artixdevice\"" -i /init
else
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$archisodevice\"" -i /init
fi
elif [ "$1" = "-l" ]; then
shift
label=$1
+ elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
+ print_usage
+ exit 0
else
print_usage
exit 1
#!/bin/sh
+if [ -f ./ventoy/version ]; then
+ curver=$(cat ./ventoy/version)
+fi
echo ''
-echo '***********************************************************'
-echo '* Ventoy2Disk Script *'
-echo '* longpanda admin@ventoy.net *'
-echo '***********************************************************'
+echo '**********************************************'
+echo " Ventoy: $curver"
+echo " longpanda admin@ventoy.net"
+echo " https://www.ventoy.net"
+echo '**********************************************'
echo ''
OLDDIR=$PWD
#special process for deepin-live iso
if [ "$vt_chosen_size" = "403701760" ]; then
- if vt_str_begin $vt_chosen_path "/deepin-live"; then
+ if vt_str_str $vt_chosen_path "/deepin-live"; then
set ventoy_busybox_ver=64
fi
elif vt_str_begin $vt_volume_id "PHOTON_"; then
rm -rf $tmpdir
+cd ../LiveCD
+sh livecd.sh
+cd $CurDir
+
+mv ../LiveCD/ventoy*.iso ./
+
if [ -e ventoy-${curver}-windows.zip ] && [ -e ventoy-${curver}-linux.tar.gz ]; then
echo -e "\n ============= SUCCESS =================\n"
else
--- /dev/null
+tinycore follows the GPL-v2 License (see gpl-2.0.txt)\r
+\r
+Ventoy does not modify its source code, only its binraries are used.\r
+\r
--- /dev/null
+
+search -f /EFI/VentoyLiveCD -s root
+configfile ($root)/EFI/boot/grub.cfg
+
+
--- /dev/null
+VentoyLiveCD\r
+\r
+https://www.ventoy.net\r
--- /dev/null
+
+set timeout=3
+set default=LiveCD
+
+clear
+
+menuentry 'Ventoy xxx LiveCD' --id=LiveCD {
+ linux /EFI/boot/vmlinuz quiet loglevel=0 superuser rdinit=/ventoy/init.sh
+ initrd /EFI/ventoy/ventoy.gz /EFI/boot/core.gz /EFI/boot/modules.gz newc:ventoy.tar.gz:/EFI/ventoy/ventoy-xxx-linux.tar.gz
+ boot
+}
+
+menuentry 'Ventoy xxx LiveCD (Debug Mode)' {
+ linux /EFI/boot/vmlinuz loglevel=10 multivt superuser rdinit=/ventoy/init.sh
+ initrd /EFI/ventoy/ventoy.gz /EFI/boot/core.gz /EFI/boot/modules.gz newc:ventoy.tar.gz:/EFI/ventoy/ventoy-xxx-linux.tar.gz
+ boot
+}
--- /dev/null
+\r
+Ventoy LiveCD is Tinycore distro + Ventoy linux install package.\r
+\r
+\r
+vmlinuz and core.gz are downloaded from:\r
+http://www.tinycorelinux.net/11.x/x86/release/distribution_files/\r
+\r
+MD5SUM:\r
+0fd08c73e84b26aabbd0d12006d64855 core.gz\r
+a9c2e2abbf464517e681234fb4687aa1 vmlinuz\r
+\r
+\r
+\r
+VTOY/ventoy/tcz/*/tcz are downloaded from:\r
+http://distro.ibiblio.org/tinycorelinux/11.x/x86/tcz/\r
+\r
+MD5SUM:\r
+b6153a469d1d56e1e6895c6812a344cd dosfstools.tcz\r
+29a4585d38b34ad58f8a7cb2d09e065f glib2.tcz\r
+6812067a60165aee3cbcc07a75b6b1f4 libffi.tcz\r
+5120e0c9ee65f936dea8cb6a0a0a1ddd liblvm2.tcz\r
+92909db8fb3c4333a2a4a325ffbf4b50 ncursesw.tcz\r
+e2bb47c9da2abab62fa794d69aba97c0 parted.tcz\r
+0e6dfbebe816062a81aff6d3e5e7719b readline.tcz\r
+3cf996373ab01be269ea0efaf17ce0cd udev-lib.tcz\r
+\r
+\r
+VTOY/ventoy/drivers/*.ko\r
+build kernel\r
+http://www.tinycorelinux.net/11.x/x86/release/src/kernel/\r
+config-5.4.3-tinycore\r
+linux-5.4.3-patched.txz \r
+disable a wireless lan driver to avoid compile error\r
+\r
--- /dev/null
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+typedef unsigned long long UINT64;\r
+\r
+int GetHumanReadableGBSize(UINT64 SizeBytes)\r
+{\r
+ int i;\r
+ int Pow2 = 1;\r
+ double Delta;\r
+ double GB = SizeBytes * 1.0 / 1000 / 1000 / 1000;\r
+\r
+ for (i = 0; i < 12; i++)\r
+ {\r
+ if (Pow2 > GB)\r
+ {\r
+ Delta = (Pow2 - GB) / Pow2;\r
+ }\r
+ else\r
+ {\r
+ Delta = (GB - Pow2) / Pow2;\r
+ }\r
+\r
+ if (Delta < 0.05)\r
+ {\r
+ return Pow2;\r
+ }\r
+\r
+ Pow2 <<= 1;\r
+ }\r
+\r
+ return (int)GB;\r
+}\r
+\r
+int main(int argc, char **argv)\r
+{\r
+ UINT64 value = strtoul(argv[1], NULL, 10);\r
+ \r
+ printf("%d", GetHumanReadableGBSize(value * 512));\r
+ \r
+ return 0;\r
+}\r
--- /dev/null
+#!/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
+exec /init
--- /dev/null
+scsi_transport_sas
+mptbase
+mptscsih
+mptsas
+yurex
+ezusb
+parport
+uss720
+usb4604
+usb3503
+sisusbvga
+usb251xb
+pi3usb30532
+usb-otg-fsm
+usb-conn-gpio
+ulpi
+ums-realtek
+xhci-hcd
+xhci-pci
+xhci-plat-hcd
+usbip-core
+usbip-host
+vhci-hcd
+cdc-wdm
+cdc-acm
+usblp
+megaraid_sas
--- /dev/null
+#!/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
+
--- /dev/null
+#!/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/ | grep 'd[a-z]' | 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 "^[1-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 "Scaning 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
+
+
--- /dev/null
+#!/bin/bash
+
+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 && cd VTOY_TMP
+gcc -O2 -m32 ./ventoy/disksize.c -o ./ventoy/disksize
+rm -f ./ventoy/disksize.c
+find . | cpio -o -H newc | gzip -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 -a 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
+