]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
1.0.12 release v1.0.12
authorlongpanda <admin@ventoy.net>
Sat, 30 May 2020 12:13:04 +0000 (20:13 +0800)
committerlongpanda <admin@ventoy.net>
Sat, 30 May 2020 12:13:09 +0000 (20:13 +0800)
17 files changed:
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c
IMG/cpio/ventoy/hook/android/ventoy-disk.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/android/ventoy-hook.sh [new file with mode: 0644]
IMG/cpio/ventoy/ventoy.sh
INSTALL/CreatePersistentImg.sh [new file with mode: 0644]
INSTALL/EFI/BOOT/grubx64_real.efi
INSTALL/Ventoy2Disk.exe
INSTALL/grub/grub.cfg
INSTALL/grub/i386-pc/core.img
INSTALL/tool/VentoyWorker.sh
INSTALL/tool/ventoy_lib.sh
INSTALL/ventoy/ventoy.cpio
INSTALL/ventoy_pack.sh
README.md
Ventoy2Disk/Ventoy2Disk/PhyDrive.c
Ventoy2Disk/Ventoy2Disk/Utility.c
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c

index 28133ce2b1b50ffd461e1b6b0c54e8914881385a..1e795c3cdf9bd464cb6ed3200669bd354b5e28a3 100644 (file)
@@ -686,6 +686,8 @@ static grub_uint32_t ventoy_linux_get_override_chunk_size(void)
 static void ventoy_linux_fill_override_data(    grub_uint64_t isosize, void *override)
 {
     initrd_info *node;
+    grub_uint32_t mod;
+    grub_uint32_t newlen;
     grub_uint64_t sector;
     ventoy_override_chunk *cur;
 
@@ -699,13 +701,20 @@ static void ventoy_linux_fill_override_data(    grub_uint64_t isosize, void *ove
             continue;
         }
 
+        newlen = (grub_uint32_t)(node->size + g_ventoy_cpio_size);
+        mod = newlen % 4; 
+        if (mod > 0)
+        {
+            newlen += 4 - mod;
+        }
+
         if (node->iso_type == 0)
         {
             ventoy_iso9660_override *dirent = (ventoy_iso9660_override *)node->override_data;
 
             node->override_length   = sizeof(ventoy_iso9660_override);
             dirent->first_sector    = (grub_uint32_t)sector;
-            dirent->size            = (grub_uint32_t)(node->size + g_ventoy_cpio_size);
+            dirent->size            = newlen;
             dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
             dirent->size_be         = grub_swap_bytes32(dirent->size);
 
@@ -716,7 +725,7 @@ static void ventoy_linux_fill_override_data(    grub_uint64_t isosize, void *ove
             ventoy_udf_override *udf = (ventoy_udf_override *)node->override_data;
             
             node->override_length = sizeof(ventoy_udf_override);
-            udf->length   = (grub_uint32_t)(node->size + g_ventoy_cpio_size);
+            udf->length   = newlen;
             udf->position = (grub_uint32_t)sector - node->udf_start_block;
 
             sector += (udf->length + 2047) / 2048;
diff --git a/IMG/cpio/ventoy/hook/android/ventoy-disk.sh b/IMG/cpio/ventoy/hook/android/ventoy-disk.sh
new file mode 100644 (file)
index 0000000..a9aee8d
--- /dev/null
@@ -0,0 +1,42 @@
+#!/ventoy/busybox/sh
+#************************************************************************************
+# Copyright (c) 2020, longpanda <admin@ventoy.net>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# 
+#************************************************************************************
+
+. /ventoy/hook/ventoy-hook-lib.sh
+
+if is_ventoy_hook_finished; then
+    exit 0
+fi
+
+vtdiskname=$(get_ventoy_disk_name)
+if [ "$vtdiskname" = "unknown" ]; then
+    vtlog "ventoy disk not found"
+    PATH=$VTPATH_OLD
+    exit 0
+fi
+
+ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
+
+if ! [ -e $VTOY_DM_PATH ]; then
+    blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
+    mknod -m 0666 $VTOY_DM_PATH b $blkdev_num
+fi
+
+# OK finish
+set_ventoy_hook_finish
+
diff --git a/IMG/cpio/ventoy/hook/android/ventoy-hook.sh b/IMG/cpio/ventoy/hook/android/ventoy-hook.sh
new file mode 100644 (file)
index 0000000..4a315be
--- /dev/null
@@ -0,0 +1,27 @@
+#!/ventoy/busybox/sh
+#************************************************************************************
+# Copyright (c) 2020, longpanda <admin@ventoy.net>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# 
+#************************************************************************************
+
+. $VTOY_PATH/hook/ventoy-os-lib.sh
+
+if ! [ -d /dev ]; then
+    $BUSYBOX_PATH/mkdir /dev
+fi
+
+$SED "1a\export ROOT=/dev/mapper/ventoy"  -i /init
+$SED "/check_root \$device/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/android/ventoy-disk.sh"  -i /init
index e64a4a76039c03cb4c92c995c2294a2354df48f7..edab7e8c80d0e3d725c6ddd3ae40876c48097170 100644 (file)
@@ -184,6 +184,10 @@ ventoy_get_os_type() {
         fi
     fi
     
+    if $GREP -q 'android.x86' /proc/version; then
+        echo 'android'; return
+    fi 
+    
     echo "default"
 }
 
diff --git a/INSTALL/CreatePersistentImg.sh b/INSTALL/CreatePersistentImg.sh
new file mode 100644 (file)
index 0000000..83f1e7e
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+size=1024
+fstype=ext4
+label=casper-rw
+
+print_usage() {
+    echo 'Usage:  CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ]'
+    echo '  OPTION: (optional)'
+    echo '   -s size in MB, default is 1024'
+    echo '   -t filesystem type, default is ext4  ext2/ext3/ext4/xfs are supported now'
+    echo '   -l label, default is casper-rw'
+    echo ''
+}
+
+while [ -n "$1" ]; do
+    if [ "$1" = "-s" ]; then
+        shift
+        size=$1
+    elif [ "$1" = "-t" ]; then
+        shift
+        fstype=$1
+    elif [ "$1" = "-l" ]; then
+        shift
+        label=$1
+    else
+        print_usage
+        exit 1
+    fi
+    shift
+done
+
+
+# check label
+if [ -z "$label" ]; then
+    echo "The label can NOT be empty."
+    exit 1
+fi
+
+# check size
+if echo $size | grep -q "^[0-9][0-9]*$"; then
+    if [ $size -le 1 ]; then
+        echo "Invalid size $size"
+        exit 1
+    fi
+else
+    echo "Invalid size $size"
+    exit 1
+fi
+
+
+# check file system type
+# nodiscard must be set for ext2/3/4
+# -K must be set for xfs 
+if echo $fstype | grep -q '^ext[234]$'; then
+    fsopt='-E nodiscard'
+elif [ "$fstype" = "xfs" ]; then
+    fsopt='-K'
+else
+    echo "unsupported file system $fstype"
+    exit 1
+fi
+
+# 00->ff avoid sparse file
+dd if=/dev/zero  bs=1M count=$size | tr '\000' '\377' > persistence.img
+sync
+
+freeloop=$(losetup -f)
+
+losetup $freeloop persistence.img
+
+mkfs -t $fstype $fsopt -L $label $freeloop 
+
+sync
+
+losetup -d $freeloop
+
index 0323fce74000e63df435744fd67bb685a112926f..e6ba9bb6da0370018c44637c13b2fefa0f48eebf 100644 (file)
Binary files a/INSTALL/EFI/BOOT/grubx64_real.efi and b/INSTALL/EFI/BOOT/grubx64_real.efi differ
index ded8b1093c1449e1da400a26edd8b5aad6a34bf9..2ed82b7936120d9e12aa31a23d16625125a10235 100644 (file)
Binary files a/INSTALL/Ventoy2Disk.exe and b/INSTALL/Ventoy2Disk.exe differ
index 2a2175d314d9e6734169bf3ef4cc104d73deed61..b1ef9b0a5e46d30cc417a75443d4d7a909ab1eca 100644 (file)
@@ -17,7 +17,7 @@
 #************************************************************************************
 
 function ventoy_power {
-    configfile ${vtoy_path}/grub/power.cfg
+    configfile ($root)/grub/power.cfg
 }
 
 function get_os_type {
@@ -117,9 +117,11 @@ function distro_specify_initrd_file_phase2 {
         vt_linux_specify_initrd_file /boot/iniramfs.igz
     elif [ -f (loop)/initrd-x86_64 ]; then
         vt_linux_specify_initrd_file /initrd-x86_64
-    elif [ -f (loop)/live/initrd.img ]; then
+    elif [ -f (loop)/live/initrd.img ]; then 
         vt_linux_specify_initrd_file /live/initrd.img
-        
+    elif [ -f (loop)/initrd.img ]; then 
+        vt_linux_specify_initrd_file /initrd.img
+
     fi
 }
 
index 83dd21673ba87a5e23bf5692b32a416cd9448029..424bb76acd228fd2093e971a2cbc0b638ddd6fbe 100644 (file)
Binary files a/INSTALL/grub/i386-pc/core.img and b/INSTALL/grub/i386-pc/core.img differ
index 224ddf8c9dfe3581101419112f4e283d7766b0b5..817a149f3464272d89dd5954e143e9b560bbda3e 100644 (file)
@@ -266,6 +266,16 @@ else
     
     dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=440
     
+    PART1_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=446 status=none | ./tool/hexdump -n1 -e  '1/1 "%02X"')
+    PART2_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=462 status=none | ./tool/hexdump -n1 -e  '1/1 "%02X"')
+    
+    vtdebug "PART1_ACTIVE=$PART1_ACTIVE  PART2_ACTIVE=$PART2_ACTIVE"
+    if [ "$PART1_ACTIVE" = "00" ] && [ "$PART2_ACTIVE" = "80" ]; then
+        vtdebug "change 1st partition active, 2nd partition inactive ..."
+        echo -en '\x80' | dd of=$DISK conv=fsync bs=1 count=1 seek=446 status=none
+        echo -en '\x00' | dd of=$DISK conv=fsync bs=1 count=1 seek=462 status=none
+    fi
+    
     ./tool/xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1  
 
     disk_sector_num=$(cat /sys/block/${DISK#/dev/}/size) 
index dd9e09594166cb7b29251c640eae64fe11e5f79b..80dea30add52c36a2b871138665adc9f36a2add4 100644 (file)
@@ -216,7 +216,7 @@ format_ventoy_disk() {
             unit s \
             mkpart primary ntfs $part1_start_sector $part1_end_sector \
             mkpart primary fat16 $part2_start_sector $part2_end_sector \
-            set 2 boot on \
+            set 1 boot on \
             quit
 
         sync
@@ -243,7 +243,7 @@ t
 2
 ef
 a
-2
+1
 w
 EOF
     fi
index d8bac6aa9aee2c8fe9cf9105b8f547cb99e45e19..a45afff76da90f9a863af03baf93037ccd8ac9ac 100644 (file)
Binary files a/INSTALL/ventoy/ventoy.cpio and b/INSTALL/ventoy/ventoy.cpio differ
index 6701dc97765f66243035f68bbee210ed4584e629..9e3b48411880588dff38f144b40f3cb93c76282a 100644 (file)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 dos2unix -q ./tool/ventoy_lib.sh
+dos2unix -q ./tool/VentoyWorker.sh
 
 . ./tool/ventoy_lib.sh
 
@@ -30,7 +31,7 @@ while ! grep -q 524288 /sys/block/${LOOP#/dev/}/size 2>/dev/null; do
     sleep 1
 done
 
-format_ventoy_disk $LOOP 
+format_ventoy_disk $LOOP fdisk
 
 $GRUB_DIR/sbin/grub-bios-setup  --skip-fs-probe  --directory="./grub/i386-pc"  $LOOP
 
@@ -77,8 +78,9 @@ xz --check=crc32 $tmpdir/boot/core.img
 
 cp -a ./tool $tmpdir/
 cp -a Ventoy2Disk.sh $tmpdir/
-
+cp -a CreatePersistentImg.sh $tmpdir/
 dos2unix -q $tmpdir/Ventoy2Disk.sh
+dos2unix -q $tmpdir/CreatePersistentImg.sh
 
 #32MB disk img
 dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector
@@ -119,4 +121,5 @@ else
     exit 1
 fi
 
+rm -f log.txt
 
index 64e689e472c44b97d563568e085875664579b815..5d7a94949e60e88fa0184f252c0aa156f43c158e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -15,13 +15,15 @@ See https://www.ventoy.net for detail.
 * Legacy + UEFI supported in the same way
 * UEFI Secure Boot supported (since 1.0.07+)
 * Persistence supported (since 1.0.11+)
+* WIM files boot supported (Legacy + UEFI) (1.0.12+)
+* Auto installation supported (1.0.09+)
 * ISO files larger than 4GB supported
 * Native boot menu style for Legacy & UEFI
 * Most type of OS supported, 200+ iso files tested
 * Not only boot but also complete installation process
+* ISO files can be listed in List mode/TreeView mode
 * "Ventoy Compatible" concept
 * Plugin Framework
-* Auto installation supported (1.0.09+)
 * Readonly to USB drive during boot
 * USB normal use unaffected
 * Data nondestructive during version upgrade
@@ -43,6 +45,7 @@ Title | Link
 **Customize Theme** | [https://www.ventoy.net/en/plugin_theme.html](https://www.ventoy.net/en/plugin_theme.html)  
 **Auto Installation** | [https://www.ventoy.net/en/plugin_autoinstall.html](https://www.ventoy.net/en/plugin_autoinstall.html)  
 **Persistence Support** | [https://www.ventoy.net/en/plugin_persistence.html](https://www.ventoy.net/en/plugin_persistence.html)  
+**Boot WIM file** | [https://www.ventoy.net/en/plugin_wimboot.html](https://www.ventoy.net/en/plugin_wimboot.html)  
 **Memdisk Mode** | [https://www.ventoy.net/en/doc_memdisk.html](https://www.ventoy.net/en/doc_memdisk.html)  
 **TreeView Mode** | [https://www.ventoy.net/en/doc_treeview.html](https://www.ventoy.net/en/doc_treeview.html)  
 **Disk Layout** | [https://www.ventoy.net/en/doc_disk_layout.html](https://www.ventoy.net/en/doc_disk_layout.html)  
index 535e1a91be73b9d6c19063f7478f7d7699645c0e..7e90421e8abd18e4316f83e672833c67fbc70056 100644 (file)
@@ -1591,6 +1591,18 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
         Log("Write Boot Image ret:%u dwSize:%u Error:%u", bRet, dwSize, LASTERR);
     }
 
+    if (0x00 == MBR.PartTbl[0].Active && 0x80 == MBR.PartTbl[1].Active)
+    {
+        Log("Need to chage 1st partition active and 2nd partition inactive.");
+
+        MBR.PartTbl[0].Active = 0x80;
+        MBR.PartTbl[1].Active = 0x00;
+
+        SetFilePointer(hDrive, 0, NULL, FILE_BEGIN);
+        bRet = WriteFile(hDrive, &MBR, 512, &dwSize, NULL);
+        Log("Write NEW MBR ret:%u dwSize:%u Error:%u", bRet, dwSize, LASTERR);
+    }
+
     //Refresh Drive Layout
     DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL);
 
index 356b4ab73dd8ce8da61a4e92ae1a1423c3b84583..a1023fad70224da881dda00508fe56ee7f685598 100644 (file)
@@ -449,7 +449,7 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR)
     PartSectorCount = DiskSectorCount - VENTOY_EFI_PART_SIZE / 512 - PartStartSector;
     VentoyFillLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl);
 
-    pMBR->PartTbl[0].Active = 0x00;
+    pMBR->PartTbl[0].Active = 0x80; // bootable
     pMBR->PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS
 
     //Part2
@@ -457,7 +457,7 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR)
     PartSectorCount = VENTOY_EFI_PART_SIZE / 512;
     VentoyFillLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl + 1);
 
-    pMBR->PartTbl[1].Active = 0x80; // bootable
+    pMBR->PartTbl[1].Active = 0x00; 
     pMBR->PartTbl[1].FsFlag = 0xEF; // EFI System Partition
 
     pMBR->Byte55 = 0x55;
index 0a84ce2ff771129b0dad18f1fe6ead9a9874f2ec..e4da211083371a530e503edbbe77979e327db4e8 100644 (file)
@@ -140,8 +140,7 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes)
     PartStartSector = (UINT32)((SizeBytes - VENTOY_EFI_PART_SIZE) / 512);
     PartSectorCount = VENTOY_EFI_PART_SIZE / 512;
 
-    if (MBR.PartTbl[1].Active != 0x80 ||
-        MBR.PartTbl[1].FsFlag != 0xEF ||
+    if (MBR.PartTbl[1].FsFlag != 0xEF ||
         MBR.PartTbl[1].StartSectorId != PartStartSector ||
         MBR.PartTbl[1].SectorCount != PartSectorCount)
     {
@@ -149,6 +148,12 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes)
         return FALSE;
     }
 
+    if (MBR.PartTbl[0].Active != 0x80 && MBR.PartTbl[1].Active != 0x80)
+    {
+        Log("Part1 and Part2 are both NOT active 0x%x 0x%x", MBR.PartTbl[0].Active, MBR.PartTbl[1].Active);
+        return FALSE;
+    }
+
     Log("PhysicalDrive%d is ventoy disk", PhyDrive);
     return TRUE;
 }