]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/CreatePersistentImg.sh
9 echo 'Usage: CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ]'
10 echo ' OPTION: (optional)'
11 echo ' -s size in MB, default is 1024'
12 echo ' -t filesystem type, default is ext4 ext2/ext3/ext4/xfs are supported now'
13 echo ' -l label, default is casper-rw'
14 echo ' -c configfile name inside the persistence file. File content is "/ union"'
19 if [ "$1" = "-s" ]; then
22 elif [ "$1" = "-t" ]; then
25 elif [ "$1" = "-l" ]; then
28 elif [ "$1" = "-c" ]; then
31 elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
43 if [ -z "$label" ]; then
44 echo "The label can NOT be empty."
49 if echo $size | grep -q "^[0-9][0-9]*$"; then
50 if [ $size -le 1 ]; then
51 echo "Invalid size $size"
55 echo "Invalid size $size"
60 # check file system type
61 # nodiscard must be set for ext2/3/4
62 # -K must be set for xfs
63 if echo $fstype | grep -q '^ext[234]$'; then
65 elif [ "$fstype" = "xfs" ]; then
68 echo "unsupported file system $fstype"
72 # 00->ff avoid sparse file
73 dd if=/dev
/zero bs
=1M count
=$size | tr '\000' '\377' > persistence.dat
76 freeloop
=$(losetup -f)
78 losetup
$freeloop persistence.dat
80 mkfs
-t $fstype $fsopt -L $label $freeloop
84 if [ -n "$config" ]; then
85 if [ -d .
/persist_tmp_mnt
]; then
86 rm -rf .
/persist_tmp_mnt
89 mkdir .
/persist_tmp_mnt
90 if mount
$freeloop .
/persist_tmp_mnt
; then
91 echo '/ union' > .
/persist_tmp_mnt
/$config
93 umount .
/persist_tmp_mnt
95 rm -rf .
/persist_tmp_mnt