mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-27 13:16:35 +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
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
|
|
||||||
msg_begin "Detecting disk device"
|
msg_begin "Detecting disk device"
|
||||||
root_part=$(cat /proc/cmdline | grep -oE 'root=[/a-z0-9]+' | cut -d '=' -f 2)
|
root_dev=$(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
|
if [[ "$root_dev" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
|
||||||
disk_dev=${BASH_REMATCH[1]}
|
disk_dev=${BASH_REMATCH[1]}
|
||||||
|
boot_dev=${disk_dev}p1
|
||||||
data_dev=${disk_dev}p3
|
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]}
|
disk_dev=${BASH_REMATCH[1]}
|
||||||
|
boot_dev=${disk_dev}1
|
||||||
data_dev=${disk_dev}3
|
data_dev=${disk_dev}3
|
||||||
else
|
else
|
||||||
msg_fail "unknown ($root_part)"
|
msg_fail "unknown ($root_dev)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
msg_done "$disk_dev"
|
msg_done "$disk_dev"
|
||||||
@ -21,10 +23,12 @@ test -b $data_dev && exit 0
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
msg_begin "Creating data partition"
|
msg_begin "Creating data partition"
|
||||||
|
root_end=$(partx -s -g -o END $root_dev)
|
||||||
|
data_start=$(($root_end + 1))
|
||||||
echo -e "n
|
echo -e "n
|
||||||
p
|
p
|
||||||
3
|
3
|
||||||
\n
|
${data_start}
|
||||||
\n
|
\n
|
||||||
w" | /sbin/fdisk $disk_dev 2>&1 >/dev/null | grep -v "Device or resource busy" | grep -v '^$'
|
w" | /sbin/fdisk $disk_dev 2>&1 >/dev/null | grep -v "Device or resource busy" | grep -v '^$'
|
||||||
partx -a $disk_dev &>/dev/null
|
partx -a $disk_dev &>/dev/null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user