mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-24 11:46:30 +00:00
datapart init script: automatically detect data partition start
This commit is contained in:
parent
4157dcfdba
commit
6bb71ef9da
@ -3,15 +3,17 @@
|
||||
test -n "$os_version" || source /etc/init.d/base
|
||||
|
||||
msg_begin "Detecting disk device"
|
||||
root_part=$(cat /proc/cmdline | grep -oE 'root=[/a-z0-9]+' | cut -d '=' -f 2)
|
||||
if [[ "$root_part" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
|
||||
root_dev=$(cat /proc/cmdline | grep -oE 'root=[/a-z0-9]+' | cut -d '=' -f 2)
|
||||
if [[ "$root_dev" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
|
||||
disk_dev=${BASH_REMATCH[1]}
|
||||
boot_dev=${disk_dev}p1
|
||||
data_dev=${disk_dev}p3
|
||||
elif [[ "$root_part" =~ ^([/a-z0-9]+)([0-9])$ ]]; then # e.g. /dev/sdc2
|
||||
elif [[ "$root_dev" =~ ^([/a-z0-9]+)([0-9])$ ]]; then # e.g. /dev/sdc2
|
||||
disk_dev=${BASH_REMATCH[1]}
|
||||
boot_dev=${disk_dev}1
|
||||
data_dev=${disk_dev}3
|
||||
else
|
||||
msg_fail "unknown ($root_part)"
|
||||
msg_fail "unknown ($root_dev)"
|
||||
exit 1
|
||||
fi
|
||||
msg_done "$disk_dev"
|
||||
@ -21,10 +23,12 @@ test -b $data_dev && exit 0
|
||||
case "$1" in
|
||||
start)
|
||||
msg_begin "Creating data partition"
|
||||
root_end=$(partx -s -g -o END $root_dev)
|
||||
data_start=$(($root_end + 1))
|
||||
echo -e "n
|
||||
p
|
||||
3
|
||||
\n
|
||||
${data_start}
|
||||
\n
|
||||
w" | /sbin/fdisk $disk_dev 2>&1 >/dev/null | grep -v "Device or resource busy" | grep -v '^$'
|
||||
partx -a $disk_dev &>/dev/null
|
||||
|
Loading…
x
Reference in New Issue
Block a user