mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-08-28 00:11:15 +00:00
1.0.12 release
This commit is contained in:
77
INSTALL/CreatePersistentImg.sh
Normal file
77
INSTALL/CreatePersistentImg.sh
Normal file
@@ -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
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
}
|
||||
|
||||
|
Binary file not shown.
@@ -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)
|
||||
|
@@ -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
|
||||
|
Binary file not shown.
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user