initial data partition creation no longer requires two boots

This commit is contained in:
Calin Crisan 2015-11-09 01:53:28 +02:00
parent 1d93edc67d
commit 2f8a10dcf9
6 changed files with 16 additions and 43 deletions

View File

@ -37,7 +37,6 @@ rm -f $TARGET/sbin/fdformat
rm -f $TARGET/sbin/ctrlaltdel
rm -f $TARGET/bin/findmnt
rm -f $TARGET/usr/bin/colcrt
rm -f $TARGET/usr/sbin/partx
rm -f $TARGET/sbin/fsfreeze
rm -f $TARGET/usr/bin/colrm
rm -f $TARGET/usr/sbin/addpart

View File

@ -1,11 +1,11 @@
# /etc/fstab: static file system information.
#
# <file system> <mount pt> <type> <options> <dump> <pass>
/dev/mmcblk0p1 /boot vfat ro,defaults 0 0
/dev/mmcblk0p3 /data auto defaults,noatime 0 0
/dev/mmcblk0p3 /data ext4 defaults,noatime 0 0
proc /proc proc defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs mode=0777 0 0
tmpfs /tmp tmpfs mode=1777 0 0
sysfs /sys sysfs defaults 0 0
/data/output /home/ftp/sdcard rbind rbind 0 0
/data/media /home/ftp/storage rbind rbind 0 0

View File

@ -2,20 +2,13 @@
DISK_DEV="/dev/mmcblk0"
DATA_DEV="${DISK_DEV}p3"
set +e
# don't execute the script if kernel cmdline has "nodatapart" keyword
if /bin/cat /proc/cmdline | /bin/grep "nodatapart"; then
exit;
fi
start() {
echo "Setting up data partition"
# if the partition is not present, allocate it and issue a reboot
# if the data partition is not present, create and format it
if ! [ -b $DATA_DEV ]; then
echo "Allocating data partition"
echo "Creating data partition"
echo -e "n
p
3
@ -24,18 +17,15 @@ start() {
w
" | /sbin/fdisk $DISK_DEV
sync
sleep 1
echo b > /proc/sysrq-trigger
fi
partx -a $DISK_DEV &>/dev/null
# if the filesystem is not valid (not yet formatted), format it
if /usr/sbin/debugfs -R 'lcd /' $DATA_DEV 2>&1 | grep 'Bad magic'; then
echo "Formatting data partition"
mkfs.ext4 $DATA_DEV
echo "Mounting data partition"
mount /data
fi
if df /dev/mmcblk0p3 >/dev/null 2>&1; then
# make sure required directories exist
mkdir -p /data/etc
@ -45,6 +35,9 @@ start() {
chmod 775 /data/output
chmod 775 /data/media
# mount any partitions depending on data folders
mount -a
# make sure a localtime symlink exists
if ! [ -e /data/etc/localtime ]; then
ln -s /usr/share/zoneinfo/UTC /data/etc/localtime
@ -78,10 +71,6 @@ start() {
sed -r -i 's/root:([^:]+):[[:digit:]]+:/root:\1::/' /data/etc/shadow # removes pwd expiration
sed -r -i 's/admin:([^:]+):[[:digit:]]+:/admin:\1::/' /data/etc/shadow # removes pwd expiration
# mount binds
mount --rbind /data/output /home/ftp/sdcard
mount --rbind /data/media /home/ftp/storage
# copy common sys config files
if [ -f /etc/watch.conf ] && ! [ -f /data/etc/watch.conf ]; then
cp /etc/watch.conf /data/etc/watch.conf
@ -89,30 +78,17 @@ start() {
fi
}
stop() {
echo -n
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
true
;;
*)
echo "Usage: $0 {start|stop|restart}"
echo "Usage: $0 {start|stop}"
exit 1
esac

View File

@ -15,9 +15,7 @@ link_nego_timeout=10
eth=eth0
wlan=wlan0
if [ -f $watch_conf ]; then
source $watch_conf
fi
test -r $watch_conf && source $watch_conf
if [ -f $sys_static_conf ] && ! [ -f $static_conf ]; then
mkdir -p $(dirname $static_conf)

View File

@ -6,7 +6,6 @@ conf="/etc/sshd_config"
[ -f /usr/bin/ssh-keygen ] || exit 0
# Create any missing keys
mkdir -p /data/etc/ssh
/usr/bin/ssh-keygen -A
umask 077

View File

@ -1,6 +1,7 @@
#!/bin/bash
set +e
/bin/sync
(sleep 10 && /usr/bin/killall -STOP watchdog) &
/bin/busybox reboot