mirror of
https://github.com/ventoy/Ventoy.git
synced 2024-11-04 06:00:13 +00:00
Add -o option in CreatePersistentImg.sh (#903)
This commit is contained in:
parent
93996cf7e2
commit
d07aa6ce07
@ -4,6 +4,7 @@ size=1024
|
|||||||
fstype=ext4
|
fstype=ext4
|
||||||
label=casper-rw
|
label=casper-rw
|
||||||
config=''
|
config=''
|
||||||
|
outputfile=persistence.dat
|
||||||
|
|
||||||
print_usage() {
|
print_usage() {
|
||||||
echo 'Usage: CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ]'
|
echo 'Usage: CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ]'
|
||||||
@ -12,6 +13,7 @@ print_usage() {
|
|||||||
echo ' -t filesystem type, default is ext4 ext2/ext3/ext4/xfs are supported now'
|
echo ' -t filesystem type, default is ext4 ext2/ext3/ext4/xfs are supported now'
|
||||||
echo ' -l label, default is casper-rw'
|
echo ' -l label, default is casper-rw'
|
||||||
echo ' -c configfile name inside the persistence file. File content is "/ union"'
|
echo ' -c configfile name inside the persistence file. File content is "/ union"'
|
||||||
|
echo ' -o outputfile name, default is persistence.dat'
|
||||||
echo ''
|
echo ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +30,9 @@ while [ -n "$1" ]; do
|
|||||||
elif [ "$1" = "-c" ]; then
|
elif [ "$1" = "-c" ]; then
|
||||||
shift
|
shift
|
||||||
config=$1
|
config=$1
|
||||||
|
elif [ "$1" = "-o" ]; then
|
||||||
|
shift
|
||||||
|
outputfile=$1
|
||||||
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||||
print_usage
|
print_usage
|
||||||
exit 0
|
exit 0
|
||||||
@ -69,13 +74,17 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$outputdir" != "persistence.dat" ]; then
|
||||||
|
mkdir -p "$(dirname "$outputfile")"
|
||||||
|
fi
|
||||||
|
|
||||||
# 00->ff avoid sparse file
|
# 00->ff avoid sparse file
|
||||||
dd if=/dev/zero bs=1M count=$size | tr '\000' '\377' > persistence.dat
|
dd if=/dev/zero bs=1M count=$size | tr '\000' '\377' > "$outputfile"
|
||||||
sync
|
sync
|
||||||
|
|
||||||
freeloop=$(losetup -f)
|
freeloop=$(losetup -f)
|
||||||
|
|
||||||
losetup $freeloop persistence.dat
|
losetup $freeloop "$outputfile"
|
||||||
|
|
||||||
mkfs -t $fstype $fsopt -L $label $freeloop
|
mkfs -t $fstype $fsopt -L $label $freeloop
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user