]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/CreatePersistentImg.sh
8 echo 'Usage: CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ]'
9 echo ' OPTION: (optional)'
10 echo ' -s size in MB, default is 1024'
11 echo ' -t filesystem type, default is ext4 ext2/ext3/ext4/xfs are supported now'
12 echo ' -l label, default is casper-rw'
17 if [ "$1" = "-s" ]; then
20 elif [ "$1" = "-t" ]; then
23 elif [ "$1" = "-l" ]; then
35 if [ -z "$label" ]; then
36 echo "The label can NOT be empty."
41 if echo $size | grep -q "^[0-9][0-9]*$"; then
42 if [ $size -le 1 ]; then
43 echo "Invalid size $size"
47 echo "Invalid size $size"
52 # check file system type
53 # nodiscard must be set for ext2/3/4
54 # -K must be set for xfs
55 if echo $fstype | grep -q '^ext[234]$'; then
57 elif [ "$fstype" = "xfs" ]; then
60 echo "unsupported file system $fstype"
64 # 00->ff avoid sparse file
65 dd if=/dev
/zero bs
=1M count
=$size | tr '\000' '\377' > persistence.img
68 freeloop
=$(losetup -f)
70 losetup
$freeloop persistence.img
72 mkfs
-t $fstype $fsopt -L $label $freeloop