FreeBSD version of Ventoy

There is a Linux installation for Ventoy available


which I'm trying to get working on FreeBSD. The installation consists of a shell script Ventoy2Disk.sh which I hope can be amended to work on FreeBSD
Bash:
#!/bin/sh

OLDDIR=$(pwd)

if ! [ -f ./tool/ventoy_lib.sh ]; then
    if [ -f ${0%Ventoy2Disk.sh}/tool/ventoy_lib.sh ]; then
        cd ${0%Ventoy2Disk.sh}   
    fi
fi

if [ -f ./ventoy/version ]; then
    curver=$(cat ./ventoy/version)
fi

if uname -m | grep -E -q 'aarch64|arm64'; then
    export TOOLDIR=aarch64
elif uname -m | grep -E -q 'x86_64|amd64'; then
    export TOOLDIR=x86_64
elif uname -m | grep -E -q 'mips64'; then
    export TOOLDIR=mips64el
else
    export TOOLDIR=i386
fi
export PATH="./tool/$TOOLDIR:$PATH"


echo ''
echo '**********************************************'
echo "      Ventoy: $curver  $TOOLDIR"
echo "      longpanda admin@ventoy.net"
echo "      https://www.ventoy.net"
echo '**********************************************'
echo ''


if ! [ -f ./boot/boot.img ]; then
    if [ -d ./grub ]; then
        echo "Don't run Ventoy2Disk.sh here, please download the released install package, and run the script in it."
    else
        echo "Please run under the correct directory!"
    fi
    exit 1
fi

echo "############# Ventoy2Disk $* [$TOOLDIR] ################" >> ./log.txt
date >> ./log.txt

#decompress tool
echo "decompress tools" >> ./log.txt
cd ./tool/$TOOLDIR

ls *.xz > /dev/null 2>&1
if [ $? -eq 0 ]; then
    [ -f ./xzcat ] && chmod +x ./xzcat

    for file in $(ls *.xz); do
        echo "decompress $file" >> ./log.txt
        xzcat $file > ${file%.xz}
        [ -f ./${file%.xz} ] && chmod +x ./${file%.xz}
        [ -f ./$file ] && rm -f ./$file
    done
fi

cd ../../
chmod +x -R ./tool/$TOOLDIR


if [ -f /bin/bash ]; then
    /bin/bash ./tool/VentoyWorker.sh $*
else
    ash ./tool/VentoyWorker.sh $*
fi

if [ -n "$OLDDIR" ]; then
    CURDIR=$(pwd)
    if [ "$CURDIR" != "$OLDDIR" ]; then
        cd "$OLDDIR"
    fi
fi

Apart from amending /bin/bash and changing drive id's I hope it should be doable.

One problem I have at the moment is that I get an error @ chmod +x -R ./tool/$TOOLDIR round about line 65, which ought to be easy to resolve, but it's evading me at the moment. It would be nice to have a native FreeBSD version of Ventoy for creating a multiboot USB drive.
 
Looking through ventoy-1.0.95/tool/VentoyWorker.sh, I'm trying to figure out how Linux (possibly under bash) interprets this:-

Code:
if ! [ -b "$DISK" ]; then
    vterr "Disk $DISK does not exist"
    exit 1
fi

I get this for both

./Ventoy2Disk.sh -l /dev/sd1

./Ventoy2Disk.sh -l /dev/ada0

What does [-b * ] check ?
 
How could I test for the existence of a disk, ie /dev/da0 using [-x /dev/*da0] in a shell script on FreeBSD?

Or is there a better way?
 
Try sysctl kern.disks and check if it's in there, e.g.:
Code:
$ sysctl kern.disks
kern.disks: nda2 nda1 nda0
$ sysctl kern.disks | grep -qw nda0 && echo found || echo not found
found
$ sysctl kern.disks | grep -qw nda3 && echo found || echo not found
not found
 
Use brandelf(1) to mark hexdump as a Linux binary.
Actually, I found that Ventoy comes with a number of Linux programs such as hexdump, archived in it's tools sub-directory and these are first decompressed and this directory is prepended to the $PATH. If I append it, then the native (FreeBSD) programs, if they exist, are used instead so such errors disappear.

Unfortunately some Ventoy specific programs, such as vtoycli are also required. The source is provided, but building them is beyond my current ability at the moment.

Not exactly sure what vtoycli does... but maybe gpart is capable of performing the same functions...
 
Back
Top