SD karta
Moderátoři: 9000peter, EnoSat, peter54
-
- Pokročilý
- Příspěvky: 70
- Registrován: 25 úno 2022 20:28
- Dal poděkování: 28 poděkování
- Dostal poděkování: 6 poděkování
SD karta
Ahoj, nevíte někdo jak rozdělit SD kartu v Octagonu 8008? Kdysi jsem měl na to script, nemůžu ho najít a moje děravá hlava už si nevzpomene, Díky
- peter54
- Moderátor
- Příspěvky: 651
- Registrován: 19 úno 2022 19:01
- Dal poděkování: 97 poděkování
- Dostal poděkování: 220 poděkování
Re: SD karta
Pokec nájdeš tu https://www.opena.tv/viewtopic.php?t=54235
Ale stačí si upraviť skript tuná a spustiť.
Ale stačí si upraviť skript tuná a spustiť.
Kód: Vybrat vše
#!/bin/sh
BOXIP=http://localhost
WGET=/usr/bin/wget
BOOT=/boot
DEV=sda
LOG_AND_BACKUPDIR=/home/root
LOGFILE=$LOG_AND_BACKUPDIR/mb-partitioning_on_device_$(date +%Y.%m.%d_%H-%M-%S).log
FLOAT=$(printf "%.1f\n" $(python -c "print (1)"))
### From here on the user variables can be set. ###
## With the following variable you can choose if you want to have an extra reserve of nearly 1gb for userdata Partition (default 1gb).
## If you don't want an extra reserve, change the following two lines to #RESERVE=1025050 and RESERVE=1050
RESERVE=1025050
#RESERVE=1050
## PLEASE NOTE !
## If a space is free after creating Partitions for Multiboot Slots, a userdata Partition will be created absolutely, indifferent.
## If you select an extra reserve or not, the question is only how large will the userdata Partition be.
## With the following variable you can select if you want to have the userdata Partition formatted in ext4 or fat32 (default = fat32).
## If you want to have the userdata Partition formatted in ext4 instead, change the following two lines to #USERDATA_FS=fat32 and USERDATA_FS=ext4
USERDATA_FS=fat32
#USERDATA_FS=ext4
## The following variable is to select the Mountpoint for the userdata Partition, for example: /media/usb or /media/sdcard (default = /media/userdata).
USERDATA_MOUNTPOINT=/media/userdata
## The following variable is to set a limit to the amount of Extra Multiboot Slots that you want to create.
EXTRA_MB_SLOTSLIMIT=15
## With the following variable you can set the size of the Multiboot Slots (Root partition): Small (1GB), Medium (1.5GB) or Large (2GB). (Default = Large)
#MULTIBOOT_SLOT_SIZE=Small
#MULTIBOOT_SLOT_SIZE=Medium
MULTIBOOT_SLOT_SIZE=Large
#########################################################
### From here on there is nothing to change for users ###
#########################################################
### mb_partitions2dev.sh version:1.5 ###
#########################################################
### Script to create additional Multiboot Slots on ###
### SD-card or USB-device. ###
#########################################################
STARTUP_END="rootwait blkdevparts=mmcblk0:1M(boot),1M(bootargs),1M(bootoptions),3M(baseparam),4M(pqparam),4M(logo),4M(deviceinfo),4M(softwareinfo),4M(loaderdb),32M(loader),8M(trustedcore),16M(linuxkernel1),16M(linuxkernel2),16M(linuxkernel3),16M(linuxkernel4),-(userdata)'"
IMG_RUN_CHECKFILE=$BOOT/STARTUP
IMG_ON_MEDIA=usb0
# the following cammand is to close the window of hotkey (or other plugin) first (you don't need it, because messages are shown in OSD messages, wait a bit after starting the script and then you will see the messages).
$WGET -q -O - $BOXIP/web/remotecontrol?command=174 && sleep 2
# General Logging.
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>$LOGFILE 2>&1
# OSD Startmessage incl. Start Date/Time.
STARTDATE="$(date +%a.%d.%b.%Y-%H:%M:%S)" && echo -e "\n\nJOB START -> $STARTDATE\n"
$WGET -O - -q "$BOXIP/web/message?text=Start%20Partitioning%20on%20${DEV}%20...%20->%20$STARTDATE&type=1&timeout=8" > /dev/null && sleep 3
# OSD Error Output.
osd_error_message() {
sleep 11
$WGET -O - -q "$BOXIP/web/message?text=ABORT%20---%20Details%20thereto%20in%3B%0A$LOGFILE%20&type=3" > /dev/null
echo ""
}
echo -e "\nCheck if a Flash memory Image is running,\nso that $0 may work.\n"
img_check="$(grep "boot" $IMG_RUN_CHECKFILE | awk '{print $2}' | cut -d "." -f1)"
if [ "$img_check" = "$IMG_ON_MEDIA" ] ; then
osd_error_message
echo -e "\n... ABBORT ...\nthis Script $0 runs only \nif you start it from a Flash memory Image (Slots 1-4).\n" && exit 1
fi
echo -e "ok, Image runs in the Flash memory,\n$0 may work."
echo -e "\nCheck if your Device /dev/$DEV (SD-Card or USB Device) has been initialized.\n"
CHECK_1="$(parted -s /dev/${DEV} unit KiB print free | awk '/^ 1/ { print $NF }')"
if [ "$CHECK_1" = "kernel2" ] ; then
CHECK_2="$(parted -s /dev/${DEV} unit KiB print free | awk '/^ 2/ { print $NF }')"
if [ "$CHECK_2" = "rootfs2" ] ; then
osd_error_message
echo -e "\n... ABORT ...\nDevice /dev/$DEV has to be formatted (initialize) first\nbefore you can create Multiboot Slot Partitions on it."
echo "you can do this via the GUI on your Box."
echo -e "... ATTENTION ... -> do not initialize the wrong Device.\n" && exit 1
fi
fi
echo -e "All ok -> Device /dev/$DEV (SD-Card or USB Device) is initialized.\n"
if [ "$MULTIBOOT_SLOT_SIZE" = "Small" ] ; then
ROOT_PART_SIZE=1048576
elif [ "$MULTIBOOT_SLOT_SIZE" = "Medium" ] ; then
ROOT_PART_SIZE=1572864
else
ROOT_PART_SIZE=2097152
fi
if [ $FLOAT = "1.0" ] ; then
SIZE_GB=$(printf "%.1f\n" $(python -c "print($ROOT_PART_SIZE/float(1048576))"))
else
SIZE_GB=$(printf "%.1f\n" $(python -c "print($ROOT_PART_SIZE/float(1048576))" | sed 's/\([0-9]\)\.\([0-9]\)/\1,\2/g'))
fi
echo -e "\n## User Settings ##\nRESERVE: $RESERVE\nUSERDATA_FS: $USERDATA_FS\nUSERDATA_MOUNTPOINT: $USERDATA_MOUNTPOINT\nEXTRA_MB_SLOTSLIMIT: $EXTRA_MB_SLOTSLIMIT\nMULTIBOOT_SLOT_SIZE: $MULTIBOOT_SLOT_SIZE (${SIZE_GB}GB)\n"
echo -e "\nCheck how much Slots are possible for Multiboot ...\n"
#DEV_SIZE="$(parted -s /dev/${DEV} unit KiB print free | sed '/^$/d' | grep -w "1" | awk '{print $3}' | tr -d '[:alpha:]')"
DEV_SIZE="$(parted -s /dev/${DEV} unit KiB print free | sed '/^$/d' | awk '/^ 1/ { print $3 }' | tr -d '[:alpha:]')"
DEV_SIZE=$((DEV_SIZE-$RESERVE))
echo "DEV_SIZE = $DEV_SIZE"
count=0
KERNEL_PART_SIZE=16384
SLOT_SIZE=$((ROOT_PART_SIZE+$KERNEL_PART_SIZE))
if [ "$EXTRA_MB_SLOTSLIMIT" -lt "1" ] ; then
EXTRA_MB_SLOTSLIMIT=1
fi
MB_PARTITIONSLIMIT=$EXTRA_MB_SLOTSLIMIT ; let ++MB_PARTITIONSLIMIT
while [ $DEV_SIZE -ge $SLOT_SIZE ] ; do
count=$((count+1))
SLOT_SIZE=$((ROOT_PART_SIZE+$KERNEL_PART_SIZE))
SLOT_SIZE=$((SLOT_SIZE*$count))
if [ $DEV_SIZE -lt $SLOT_SIZE ] ; then
break
elif [ "$count" = "$MB_PARTITIONSLIMIT" ] ; then
MB_PARTITIONSLIMIT=$((MB_PARTITIONSLIMIT-1))
echo -e "\nMultiboot Slots limit ($MB_PARTITIONSLIMIT) reached." && break
else
PARTITIONS+=( "$count" )
SLOTS+=( $((count+4)) )
fi
done
echo -e "Slots which are possible for Multiboot-> ${SLOTS[@]}\n\n"
mount_count=0
while mount | grep dev/${DEV}1 && [ "$?" = "0" ] ; do
mount_count=$((mount_count+1))
echo -e "\numount /dev/${DEV}1 ..."
umount /dev/${DEV}1
if [ "$?" = "0" ] ; then
echo -e "\numount /dev/${DEV}1 was successful.\n" && break
else
if [ "$mount_count" = "3" ] ; then
osd_error_message
echo -e "\n... ABORT ...\numount /dev/${DEV}1 has failed 3 times,\ntry to umount it manually and/or start $0 again.\n" && exit 1
fi
echo -e "\numount /dev/${DEV}1 has failed,\ntry it again in 3 seconds ..."
sleep 3
fi
done
echo -e "\nCreate Slots ${SLOTS[@]}\non a SD-Card or USB Device ..."
count=2
count_partitions=1
startkernel=1024
endkernel=17408
startrootfs=17408
if [ "$MULTIBOOT_SLOT_SIZE" = "Small" ] ; then
endrootfs=1065984
elif [ "$MULTIBOOT_SLOT_SIZE" = "Medium" ] ; then
endrootfs=1590272
else
endrootfs=2114560
fi
shiftsize=$((endrootfs-1024))
for i in ${PARTITIONS[@]} ; do
if [ "$i" = "1" ] ; then
echo -e "\nfor kernel${count} and rootfs${count} -> \$i must be similar to \$count_partitions"
echo -e "\$i = $i\ncount = $count\ncount_partitions = $count_partitions\nstartkernel = $startkernel"
echo -e "endkernel = $endkernel\nstartrootfs = $startrootfs\nendrootfs = $endrootfs\n"
parted -s /dev/${DEV} \
rm 1 \
mklabel gpt \
unit KiB mkpart kernel${count} $startkernel $endkernel \
unit KiB mkpart rootfs${count} ext4 $startrootfs $endrootfs \
print \
quit
echo -e "Continue ...\n\n"
continue
fi
count=$((count+1))
count_partitions=$((count_partitions+1))
startkernel=$((startkernel+shiftsize))
endkernel=$((endkernel+shiftsize))
startrootfs=$((startrootfs+shiftsize))
endrootfs=$((endrootfs+shiftsize))
if [ "$i" = "$count_partitions" ] ; then
echo "for kernel${count} and rootfs${count} -> \$i must be similar to \$count_partitions"
echo -e "\$i = $i\ncount = $count\ncount_partitions = $count_partitions\nstartkernel = $startkernel"
echo -e "endkernel = $endkernel\nstartrootfs = $startrootfs\nendrootfs = $endrootfs\n"
parted -s /dev/${DEV} \
unit KiB mkpart kernel${count} $startkernel $endkernel \
unit KiB mkpart rootfs${count} ext4 $startrootfs $endrootfs \
print \
quit
fi
done
DEV_SIZE="$(parted -s /dev/${DEV} unit KiB print free | sed '/^$/d' | awk 'END{print $2}' | tr -d '[:alpha:]')"
if [ $endrootfs -lt $DEV_SIZE ] ; then
USERDATA_PART=yes
echo -e "Create userdata Partition with the space which is left ...\n"
parted -s /dev/${DEV} \
unit KiB mkpart userdata $USERDATA_FS $endrootfs $DEV_SIZE \
print \
quit
fi
echo "All Partitions created."
echo -e "\nendrootfs = $endrootfs, DEV_SIZE = $DEV_SIZE\n" # to remove later
echo -e "\nnow format rootfs Partitions ...\n"
for i in ${PARTITIONS[@]} ; do
i=$((i+$i))
i=/dev/${DEV}${i}
sleep 2 && umount $i 2> /dev/null && sleep 1
mkfs.ext4 $i
if [ "$?" != "0" ] ; then
osd_error_message
echo -e "\n... ABORT ...\nFormatting partition $i has failed -> start $0 again."
echo -e "... BUT PLEASE NOTE ...\nyou need first to initialize your Device (/dev/${DEV}) again via GUI."
echo -e "... ATTENTION ... -> do not initialize the incorrectness Device.\n" && exit 1
else
echo -e "Formatting partition $i was successful.\n\n"
fi
done
FSTAB=/etc/fstab
create_new_line() {
if [ -n "$(tail -c 1 $FSTAB)" ] ; then echo -e "\nwrite blank line at the end in $FSTAB ...\n" && echo "" >> $FSTAB ; fi
}
if [ "$USERDATA_PART" = "yes" ] ; then
echo -e "and now format the userdata Partition ...\n"
USERDATA_PART_NUMBER=${#PARTITIONS[*]}
USERDATA_PART_NUMBER=$((USERDATA_PART_NUMBER*2+1))
USERDATA_PARTITION=/dev/${DEV}${USERDATA_PART_NUMBER}
sleep 3 && umount $USERDATA_PARTITION 2> /dev/null && sleep 2
if [ "$USERDATA_FS" = "fat32" ] ; then
mkfs.vfat $USERDATA_PARTITION
elif [ "$USERDATA_FS" = "ext4" ] ; then
mkfs.ext4 $USERDATA_PARTITION
fi
if [ "$?" != "0" ] ; then
$WGET -O - -q "$BOXIP/web/message?text=Please%20Note%20%21%20%20Formatting%20the%20userdata%20Partition%20has%20failed%2C%0Atry%20it%20manually%2E%0Athe%20other%20Job%20was%20full%20ok%2E&type=1&timeout=10" > /dev/null && sleep 10
echo -e "\n... IMPORTANT NOTICE ...\nFormatting the userdata Partition has failed,\ntry it manually.\n"
else
echo -e "\nFormatting the userdata Partition was successful.\n"
# Check /etc/fstab for an old mount for the USERDATA_PARTITION, and delete it, when found.
echo -e "\nCheck $FSTAB for an old mount for the ($DEV) USERDATA_PARTITION, and delete it, when found.\n"
sed -i "/### ${DEV}/d" $FSTAB && sed -i '/^$/d' $FSTAB
create_new_line
# Write userdata Mount in /etc/fstab.
echo -e "\nWriting userdata Partition ($USERDATA_PARTITION)\nin $FSTAB and mount it ...\n"
UUID="$(blkid -o value -s UUID $USERDATA_PARTITION)"
TYPE="$(blkid -o value -s TYPE $USERDATA_PARTITION)"
OPTS="defaults"
echo -e "## \$USERDATA_PARTITION DATA ##\nUSERDATA_PARTITION : $USERDATA_PARTITION\nUSERDATA_MOUNTPOINT : $USERDATA_MOUNTPOINT\nUUID : $UUID\nTYPE : $TYPE\nOPTS : $OPTS\n"
MOUNT_LINE="$(echo -e "UUID=$UUID\t$USERDATA_MOUNTPOINT\t$TYPE\t$OPTS\t0 0\t\t### ${DEV}${USERDATA_PART_NUMBER}")"
echo -e "Writing Mount for Userdata Partition;\n$MOUNT_LINE\nin $FSTAB ...\n"
echo -e "$MOUNT_LINE\n" >> $FSTAB
## finally delete potential empty lines in the /etc/fstab file, if necessary create a blank line at the end in the /etc/fstab file.
sed -i '/^$/d' $FSTAB
create_new_line
NEWUUID_CHECK="$(grep "$USERDATA_MOUNTPOINT" $FSTAB | awk '{print $1}' | cut -d '=' -f2)"
if [ "$NEWUUID_CHECK" = "$UUID" ] ; then
echo -e "Writing the userdata Partition ($USERDATA_PARTITION)\nin $FSTAB was successful.\n"
else
echo -e "\n... IMPORTANT NOTICE ...\nWriting the userdata Partition ($USERDATA_PARTITION) in"
echo -e "$FSTAB has failed, it's best to do this manually.\n"
fi
mkdir -p $USERDATA_MOUNTPOINT
mount -a
fi
fi
echo -e "\nCreate Startup Files ...\n"
count_startups=4
usb0_and_kernel_dev_count=-1
root_dev_count=0
for i in ${PARTITIONS[@]} ; do
count_startups=$((count_startups+1))
usb0_and_kernel_dev_count=$((usb0_and_kernel_dev_count+2))
root_dev_count=$((root_dev_count+2))
STARTUP="boot usb0.${DEV}$usb0_and_kernel_dev_count 'root=/dev/${DEV}$root_dev_count rootfstype=ext4 kernel=/dev/${DEV}$usb0_and_kernel_dev_count"
echo "$STARTUP $STARTUP_END" > $BOOT/STARTUP_${count_startups}
chmod 755 $BOOT/STARTUP_${count_startups}
if [ "$?" = "0" ] ; then
echo -e "File $BOOT/STARTUP_${count_startups} has been created.\n"
else
$WGET -O - -q "$BOXIP/web/message?text=Please%20Note%20%21%20%20Creating%20File%20$BOOT/STARTUP_${count_startups}%20has%20failed%2C%0Acreate%20it%20manually%2E%0Athe%20other%20Job%20was%20full%20ok%2E&type=1&timeout=10" > /dev/null && sleep 10
echo -e "\n... IMPORTANT NOTICE ...\nCreating File $BOOT/STARTUP_${count_startups} has failed,\ncreate it manually.\n"
fi
done
# OSD Endmessage incl. Start Date/Time.
ENDDATE="$(date +%a.%d.%b.%Y-%H:%M:%S)" && echo -e "\nJOB END -> $ENDDATE\n\n"
$WGET -O - -q "$BOXIP/web/message?text=Partitioning%20on%20${DEV}%20has%20been%20completed%20with%20success%20->%20$ENDDATE&type=1" > /dev/null
exit
f4t, sf8008, skylink, antiksat, 13, 16, 19, 23, 28, orange pi, rpi2b, odroid c4 
-
- Pokročilý
- Příspěvky: 70
- Registrován: 25 úno 2022 20:28
- Dal poděkování: 28 poděkování
- Dostal poděkování: 6 poděkování
- peter54
- Moderátor
- Příspěvky: 651
- Registrován: 19 úno 2022 19:01
- Dal poděkování: 97 poděkování
- Dostal poděkování: 220 poděkování
Re: SD karta
Pred 3 rokmi si zvládol, zvládneš zas.
f4t, sf8008, skylink, antiksat, 13, 16, 19, 23, 28, orange pi, rpi2b, odroid c4 
-
- Pokročilý
- Příspěvky: 70
- Registrován: 25 úno 2022 20:28
- Dal poděkování: 28 poděkování
- Dostal poděkování: 6 poděkování
-
- Pokročilý
- Příspěvky: 70
- Registrován: 25 úno 2022 20:28
- Dal poděkování: 28 poděkování
- Dostal poděkování: 6 poděkování
Re: SD karta
Tak se přece jen můj mozek na chvíli vzpamatoval a podařilo se mi to. Ještě jednou díky za radu a "podporu"
Kdo je online
Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 0 hostů