mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2026-01-27 18:22:13 +00:00
Merge pull request #68 from jnealtowns/new_partitions
New Partition and Mount Management
This commit is contained in:
@@ -130,6 +130,9 @@ do_handle_disk()
|
||||
return 0
|
||||
}
|
||||
|
||||
ONL_CONFIG_TARBALL=/tmp/onl_config.tgz
|
||||
ONL_CONFIG_MOUNTPOINT=/mnt/onl_config_partition
|
||||
|
||||
do_handle_partitions()
|
||||
{
|
||||
local part start end sz fs label flags
|
||||
@@ -143,8 +146,16 @@ do_handle_partitions()
|
||||
|
||||
installer_say "Examining $DEV part $part"
|
||||
|
||||
|
||||
case "$label" in
|
||||
ONL-CONFIG)
|
||||
installer_say "Preserving the contents of the existing ONL-CONFIG partition..."
|
||||
rm -rf $ONL_CONFIG_MOUNTPOINT
|
||||
mkdir -p $ONL_CONFIG_MOUNTPOINT
|
||||
mount $DEV$part $ONL_CONFIG_MOUNTPOINT
|
||||
tar -C $ONL_CONFIG_MOUNTPOINT -cvzf $ONL_CONFIG_TARBALL .
|
||||
umount $ONL_CONFIG_MOUNTPOINT
|
||||
parted $DEV rm $part || return 1
|
||||
;;
|
||||
ONIE-BOOT|GRUB-BOOT|*-DIAG)
|
||||
installer_say "Partition $DEV$part: $label: Preserving..."
|
||||
;;
|
||||
@@ -184,10 +195,15 @@ partition_gpt()
|
||||
{
|
||||
local start end part
|
||||
|
||||
installer_say "Creating 128MB for Open Network Linux boot"
|
||||
start=$1; shift
|
||||
|
||||
############################################################
|
||||
#
|
||||
# ONL Boot Partition.
|
||||
#
|
||||
############################################################
|
||||
installer_say "Creating 128MB for ONL Boot partition..."
|
||||
end=$(( $start + 128 ))
|
||||
echo "start=$start end=$end"
|
||||
|
||||
parted -s $DEV unit mb mkpart "ONL-BOOT" ext4 ${start} ${end} || return 1
|
||||
if ! part=$(get_part_number $DEV "ONL-BOOT"); then
|
||||
@@ -198,23 +214,59 @@ partition_gpt()
|
||||
mkfs.ext4 -L "ONL-BOOT" ${DEV}${part}
|
||||
start=$(( $end + 1 ))
|
||||
|
||||
installer_say "Creating /mnt/flash"
|
||||
end=$(( $start + 128 ))
|
||||
|
||||
parted -s $DEV unit mb mkpart "FLASH" fat32 ${start} ${end} || return 1
|
||||
if ! part=$(get_part_number $DEV "FLASH"); then
|
||||
|
||||
############################################################
|
||||
#
|
||||
# ONL Configuration Partition.
|
||||
#
|
||||
############################################################
|
||||
installer_say "Creating 128MB ONL Configuration partition..."
|
||||
end=$(( $start + 128 ))
|
||||
parted -s $DEV unit mb mkpart "ONL-CONFIG" ext4 ${start} ${end} || return 1
|
||||
if ! part=$(get_part_number $DEV "ONL-CONFIG"); then
|
||||
return 1
|
||||
fi
|
||||
mkfs.vfat -n "FLASH" ${DEV}${part}
|
||||
|
||||
mkfs.ext4 -L "ONL-CONFIG" ${DEV}${part}
|
||||
start=$(( $end + 1 ))
|
||||
|
||||
installer_say "Allocating remainder for /mnt/flash2"
|
||||
parted -s $DEV unit mb mkpart "FLASH2" fat32 ${start} "100%" || return 1
|
||||
if ! part=$(get_part_number $DEV "FLASH2"); then
|
||||
if [ -f $ONL_CONFIG_TARBALL ]; then
|
||||
installer_say "Restoring the contents of the ONL-CONFIG partition..."
|
||||
rm -rf $ONL_CONFIG_MOUNTPOINT
|
||||
mkdir -p $ONL_CONFIG_MOUNTPOINT
|
||||
mount $DEV$part $ONL_CONFIG_MOUNTPOINT
|
||||
tar -C $ONL_CONFIG_MOUNTPOINT -xvzf $ONL_CONFIG_TARBALL
|
||||
umount $ONL_CONFIG_MOUNTPOINT
|
||||
fi
|
||||
|
||||
############################################################
|
||||
#
|
||||
# ONL Image Partition.
|
||||
#
|
||||
############################################################
|
||||
installer_say "Creating 1G ONL Image partition..."
|
||||
end=$(( $start + 1024 ))
|
||||
|
||||
parted -s $DEV unit mb mkpart "ONL-IMAGES" ext4 ${start} ${end} || return 1
|
||||
if ! part=$(get_part_number $DEV "ONL-IMAGES"); then
|
||||
return 1
|
||||
fi
|
||||
mkfs.vfat -n "FLASH2" ${DEV}${part}
|
||||
mkfs.ext4 -L "ONL-IMAGES" ${DEV}${part}
|
||||
start=$(( $end + 1 ))
|
||||
|
||||
|
||||
|
||||
############################################################
|
||||
#
|
||||
# ONL Root Partition.
|
||||
#
|
||||
############################################################
|
||||
installer_say "Creating the ONL Data partition..."
|
||||
parted -s $DEV unit mb mkpart "ONL-DATA" ext4 ${start} "100%" || return 1
|
||||
if ! part=$(get_part_number $DEV "ONL-DATA"); then
|
||||
return 1
|
||||
fi
|
||||
mkfs.ext4 -L "ONL-DATA" ${DEV}${part}
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -231,8 +283,8 @@ installer_standard_gpt_install()
|
||||
mkdir "$workdir/mnt"
|
||||
|
||||
if [ -f "${installer_dir}/boot-config" ]; then
|
||||
installer_say "Installing boot-config"
|
||||
mount LABEL="FLASH" "$workdir/mnt"
|
||||
installer_say "Installing boot-config..."
|
||||
mount LABEL="ONL-BOOT" "$workdir/mnt"
|
||||
cp "${installer_dir}/boot-config" "$workdir/mnt/boot-config"
|
||||
umount "$workdir/mnt"
|
||||
fi
|
||||
@@ -244,7 +296,7 @@ installer_standard_gpt_install()
|
||||
SWIDST="$(basename ${SWISRC})"
|
||||
fi
|
||||
installer_say "Installing Open Network Linux Software Image (${SWIDST})..."
|
||||
mount LABEL="FLASH2" "$workdir/mnt"
|
||||
mount LABEL="ONL-IMAGES" "$workdir/mnt"
|
||||
cp "${SWISRC}" "$workdir/mnt/${SWIDST}"
|
||||
umount "$workdir/mnt"
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NETDEV=ma1
|
||||
NETAUTO=dhcp
|
||||
BOOTMODE=SWI
|
||||
SWI=flash2::latest
|
||||
SWI=images::latest
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NETDEV=ma1
|
||||
NETAUTO=dhcp
|
||||
BOOTMODE=SWI
|
||||
SWI=flash2::latest
|
||||
SWI=images::latest
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- sh -*-
|
||||
######################################################################
|
||||
#
|
||||
# lib.sh
|
||||
@@ -122,11 +123,12 @@ installer_partition_format() {
|
||||
local blockdev=$1
|
||||
local partno=$2
|
||||
local mkfs=$3
|
||||
local options=$4
|
||||
local partition="$1$2"
|
||||
|
||||
installer_say "Format ${partition}..."
|
||||
installer_create_device_file ${blockdev} ${partno}
|
||||
"${mkfs}" "${installer_df}"
|
||||
"${mkfs}" ${options} "${installer_df}"
|
||||
installer_say "Format ${partition} complete."
|
||||
rm "${installer_df}"
|
||||
}
|
||||
@@ -158,26 +160,60 @@ installer_umount_blockdev() {
|
||||
# installer_blockdev_format <blockdev> <p1size> <p2size> <p3size>
|
||||
#
|
||||
# <blockdev> The block device name.
|
||||
# <p1size> The size of the first partition.
|
||||
# <p2size> The size of the second partition.
|
||||
# <p3size> [Optional] The size of the third partition.
|
||||
# If p3size is unset, the remainder of the device will be used
|
||||
# for the third partition.
|
||||
# <p1size> The size of the boot partition.
|
||||
# <p2size> The size of the config partition.
|
||||
# <p3size> The size of the image partition.
|
||||
# <p4size> [Optional] The size of the data partition.
|
||||
# If p4size is unset, the remainder of the device will be used
|
||||
# for the data partition.
|
||||
#
|
||||
############################################################
|
||||
ONL_CONFIG_TARBALL=/tmp/onl_config.tgz
|
||||
ONL_CONFIG_MOUNTPOINT=/mnt/onl_config_partition
|
||||
|
||||
installer_blockdev_format() {
|
||||
local blockdev=$1
|
||||
local partition1size=$2
|
||||
local partition2size=$3
|
||||
local partition3size=$4
|
||||
local partition4size=$5
|
||||
|
||||
onl_config_partition=$(blkid | grep ONL-CONFIG | awk '{print $1}' | tr -d ':')
|
||||
|
||||
#
|
||||
# If an ONL-CONFIG partition exists, we need to save and restore its contents.
|
||||
#
|
||||
if [ -n "$onl_config_partition" ]; then
|
||||
installer_say "Preserving the contents of the existing ONL-CONFIG partition..."
|
||||
rm -rf $ONL_CONFIG_MOUNTPOINT
|
||||
mkdir -p $ONL_CONFIG_MOUNTPOINT
|
||||
echo mount "$onl_config_partition" $ONL_CONFIG_MOUNTPOINT
|
||||
mount "$onl_config_partition" $ONL_CONFIG_MOUNTPOINT
|
||||
tar -C $ONL_CONFIG_MOUNTPOINT -cvzf $ONL_CONFIG_TARBALL .
|
||||
umount $ONL_CONFIG_MOUNTPOINT
|
||||
fi
|
||||
|
||||
|
||||
|
||||
installer_umount_blockdev ${blockdev}
|
||||
installer_say "Formatting ${blockdev} as ${partition1size}:${partition2size}:${partition3size}."
|
||||
echo -e "o\nn\np\n1\n\n+${partition1size}\nn\np\n2\n\n+${partition2size}\nn\np\n3\n\n${partition3size}\np\nw\n" | fdisk /dev/${blockdev}
|
||||
installer_partition_format ${blockdev} 1 mkdosfs
|
||||
installer_partition_format ${blockdev} 2 mkdosfs
|
||||
installer_partition_format ${blockdev} 3 mkdosfs
|
||||
installer_say "Formatting ${blockdev} as ${partition1size}:${partition2size}:${partition3size}:${partition4size}."
|
||||
echo -e "o\nn\np\n1\n\n+${partition1size}\nn\np\n2\n\n+${partition2size}\nn\np\n3\n\n+${partition3size}\nn\np\n4\n\n${partition4size}\np\nw\n" | fdisk /dev/${blockdev}
|
||||
installer_partition_format ${blockdev} 1 mkfs.ext2 "-L ONL-BOOT"
|
||||
installer_partition_format ${blockdev} 2 mkfs.ext2 "-L ONL-CONFIG"
|
||||
installer_partition_format ${blockdev} 3 mkfs.ext2 "-L ONL-IMAGES"
|
||||
installer_partition_format ${blockdev} 4 mkfs.ext2 "-L ONL-DATA"
|
||||
|
||||
if [ -f $ONL_CONFIG_TARBALL ]; then
|
||||
installer_say "Restoring the contents of the existing ONL-CONFIG partition..."
|
||||
installer_create_device_file ${blockdev} 2
|
||||
mkdir -p "${installer_df}.mount"
|
||||
mount "${installer_df}" "${installer_df}.mount"
|
||||
tar -C "${installer_df}.mount" -xvzf $ONL_CONFIG_TARBALL
|
||||
umount "${installer_df}.mount"
|
||||
rm "${installer_df}"
|
||||
rmdir "${installer_df}.mount"
|
||||
rm $ONL_CONFIG_TARBALL
|
||||
fi
|
||||
}
|
||||
|
||||
############################################################
|
||||
@@ -311,15 +347,16 @@ installer_standard_blockdev_install () {
|
||||
local p1size=$2
|
||||
local p2size=$3
|
||||
local p3size=$4
|
||||
local p4size=$5
|
||||
|
||||
# Standard 3-partition format for loader, /mnt/flash, and /mnt/flash2
|
||||
installer_blockdev_format "${blockdev}" "${p1size}" "${p2size}" "${p3size}"
|
||||
installer_blockdev_format "${blockdev}" "${p1size}" "${p2size}" "${p3size}" "${p4size}"
|
||||
|
||||
# Copy the platform loader to the first partition.
|
||||
installer_platform_loader "${blockdev}" 1
|
||||
|
||||
# Set the boot-config file
|
||||
installer_platform_bootconfig "${blockdev}" 2
|
||||
installer_platform_bootconfig "${blockdev}" 1
|
||||
|
||||
# Copy the packaged SWI to the third partition.
|
||||
installer_platform_swi "${blockdev}" 3
|
||||
|
||||
@@ -110,7 +110,7 @@ fw_setenv_f_s "${envf}"
|
||||
installer_say "Install finished. Rebooting to Open Network Linux."
|
||||
sleep 3
|
||||
reboot
|
||||
exit
|
||||
exit 0
|
||||
|
||||
# Do not add any additional whitespace after this point.
|
||||
PAYLOAD_FOLLOWS
|
||||
|
||||
19
builds/any/rootfs/jessie/common/overlay/etc/mtab.yml
Normal file
19
builds/any/rootfs/jessie/common/overlay/etc/mtab.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
mounts:
|
||||
ONL-IMAGES:
|
||||
mount: r
|
||||
dir: /mnt/onl/images
|
||||
fsck: true
|
||||
|
||||
ONL-DATA:
|
||||
mount: w
|
||||
dir: /mnt/onl/data
|
||||
|
||||
ONL-CONFIG:
|
||||
mount: r
|
||||
dir: /mnt/onl/config
|
||||
fsck: true
|
||||
|
||||
ONL-BOOT:
|
||||
mount: false
|
||||
dir: /mnt/onl/boot
|
||||
fsck: false
|
||||
19
builds/any/rootfs/wheezy/common/overlay/etc/mtab.yml
Normal file
19
builds/any/rootfs/wheezy/common/overlay/etc/mtab.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
mounts:
|
||||
ONL-IMAGES:
|
||||
mount: r
|
||||
dir: /mnt/onl/images
|
||||
fsck: true
|
||||
|
||||
ONL-DATA:
|
||||
mount: w
|
||||
dir: /mnt/onl/data
|
||||
|
||||
ONL-CONFIG:
|
||||
mount: r
|
||||
dir: /mnt/onl/config
|
||||
fsck: true
|
||||
|
||||
ONL-BOOT:
|
||||
mount: false
|
||||
dir: /mnt/onl/boot
|
||||
fsck: false
|
||||
@@ -12,6 +12,8 @@ if [ -d /sys/class/ubi ]; then
|
||||
fi
|
||||
( cd /sys/class/net; for d in *; do /sbin/initnetdev $d add; done )
|
||||
|
||||
initmounts
|
||||
|
||||
log_action_end_msg 0
|
||||
|
||||
log_action_begin_msg "Mounting filesystems"
|
||||
initmounts -q
|
||||
log_action_end_msg 0
|
||||
|
||||
@@ -26,8 +26,6 @@ packages:
|
||||
summary: Open Network Linux System Loader Common Initscripts
|
||||
|
||||
files:
|
||||
src/bin/initblockdev : /sbin/
|
||||
src/bin/initmounts : /sbin/
|
||||
src/bin/initnetdev : /sbin/
|
||||
|
||||
changelog: Change changes changes.,
|
||||
|
||||
@@ -23,9 +23,9 @@ field "$ONL_PLATFORM" " Platform: $ONL_PLATFORM"
|
||||
field "MA1_ADDR" " ma1: $MA1_ADDR"
|
||||
echo "*"
|
||||
echo "************************************************************"
|
||||
if [ -f /mnt/flash/boot-config ]; then
|
||||
if [ -f /etc/onl/boot-config ]; then
|
||||
msg_info "boot-config"
|
||||
cat /mnt/flash/boot-config
|
||||
cat /etc/onl/boot-config
|
||||
else
|
||||
|
||||
if [ -f /bin/boot-config.py ]; then
|
||||
|
||||
@@ -49,7 +49,7 @@ Usage: $0 [-h|--help] [-t|--testonly] [--rootfs ROOTFS] --cache LOCATION [SWI]
|
||||
format of the SWI argument:
|
||||
|
||||
DEV:PATH
|
||||
/mnt/DEV/PATH
|
||||
/mnt/onl/DEV/PATH
|
||||
Loads a SWI file from local storage device DEV (e.g. flash).
|
||||
http://[USER:PASSWORD@]SERVER[:PORT]/PATH
|
||||
ftp://[USER:PASSWORD@]SERVER[:PORT]/PATH
|
||||
@@ -111,18 +111,18 @@ case "${SWI}" in
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Parse dev:file or dev:/file or /mnt/dev/file
|
||||
parselocal='s#\(\([^:/]*\):/\?\|/mnt/\([^/]*\)/\)\?\(.*\)#dev="\2\3" file="\4"#p'
|
||||
# Parse dev:file or dev:/file or /mnt/onl/dev/file
|
||||
parselocal='s#\(\([^:/]*\):/\?\|/mnt/onl/\([^/]*\)/\)\?\(.*\)#dev="\2\3" file="\4"#p'
|
||||
eval $(echo "${SWI}" | sed -n "${parselocal}")
|
||||
if [ "${dev}" ] ; then
|
||||
# Wait for /mnt/dev to show up
|
||||
waitforblockdev "/mnt/${dev}"
|
||||
:
|
||||
else
|
||||
# Assume file is relative, parse absolutified file
|
||||
eval $(realpath "${file}" | sed -n "${parselocal}")
|
||||
SWI="${dev}:${file}"
|
||||
fi
|
||||
swipath="/mnt/${dev}/${file}"
|
||||
swipath="/mnt/onl/${dev}/${file}"
|
||||
[ -f "${swipath}" ] || { echo "${SWI} not found or not a file"; exit 1; }
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -53,7 +53,6 @@ while read -r l; do
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# Populate platform-specific settings
|
||||
. /lib/platform-detect
|
||||
|
||||
@@ -62,46 +61,23 @@ if [ ! -f /etc/onl/abort ]; then
|
||||
# Tell kernel to invoke mdev when devices are added or removed
|
||||
echo /sbin/mdev >/proc/sys/kernel/hotplug
|
||||
|
||||
|
||||
# Initialize any block and net devices already present
|
||||
( cd /sys/class/block; for d in *; do initblockdev $d add; done )
|
||||
if [ -d /sys/class/ubi ]; then
|
||||
( cd /sys/class/ubi; for d in *; do initblockdev $d add; done )
|
||||
fi
|
||||
# Initialize net devices
|
||||
( cd /sys/class/net; for d in *; do initnetdev $d add; done )
|
||||
|
||||
# Initialize platform mounts
|
||||
initmounts
|
||||
|
||||
# Perform recovery if necessary; reboot automatically
|
||||
if /bin/recover; then
|
||||
initmounts
|
||||
else
|
||||
restoreconsole
|
||||
echo "Recovery failed."
|
||||
echo "Press CR now to exit sysinit and access the loader shell."
|
||||
echo "Otherwise, the system will reboot in 3s."
|
||||
if read -t 3 prompt; then
|
||||
trap - EXIT
|
||||
exit
|
||||
fi
|
||||
reboot -f
|
||||
fi
|
||||
|
||||
initmounts -q
|
||||
|
||||
if [ -f /etc/issue ]; then
|
||||
cat /etc/issue
|
||||
fi
|
||||
|
||||
waitforblockdev /mnt/flash
|
||||
sleep 1 # wait for external block devices to be mounted
|
||||
[ ! -f /mnt/flash/boot-config ] || cat /mnt/flash/boot-config >>/etc/onl/boot-config
|
||||
[ ! -f /mnt/onl/boot/boot-config ] || cat /mnt/onl/boot/boot-config >>/etc/onl/boot-config
|
||||
|
||||
#
|
||||
# Initialize the /mnt/flash/boot area.
|
||||
#
|
||||
mkdir -p /mnt/flash/boot
|
||||
rm -rf /mnt/flash/boot/*
|
||||
#mkdir -p /mnt/data/boot
|
||||
#rm -rf /mnt/flash/boot/*
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ if [ ! "${SWI}" ]; then
|
||||
exit 200
|
||||
fi
|
||||
|
||||
if [ "${SWI}" = "flash2::latest" ]; then
|
||||
# Boot the latest (by mtime) SWI in the flash2 partition.
|
||||
SWI=`ls /mnt/flash2/*.swi -t | head -n1`
|
||||
if [ "${SWI}" = "images::latest" ]; then
|
||||
# Boot the latest (by mtime) SWI in the images partition.
|
||||
SWI=`ls /mnt/onl/images/*.swi -t | head -n1`
|
||||
if [ -z "${SWI}" ]; then
|
||||
msg_error "No SWI available in /mnt/flash2. SWI booting cannot continue."
|
||||
msg_error "No SWI available in /mnt/onl/images. SWI booting cannot continue."
|
||||
exit 200
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
mounts:
|
||||
ONL-IMAGES:
|
||||
mount: w
|
||||
dir: /mnt/onl/images
|
||||
fsck: true
|
||||
|
||||
ONL-DATA:
|
||||
mount: w
|
||||
dir: /mnt/onl/data
|
||||
|
||||
ONL-CONFIG:
|
||||
mount: r
|
||||
dir: /mnt/onl/config
|
||||
fsck: true
|
||||
|
||||
ONL-BOOT:
|
||||
mount: r
|
||||
dir: /mnt/onl/boot
|
||||
fsck: false
|
||||
@@ -13,21 +13,16 @@
|
||||
/etc/passwd f 644 0 0 - - - - -
|
||||
/bin/autoboot f 755 0 0 - - - - -
|
||||
/bin/boot f 755 0 0 - - - - -
|
||||
/bin/discoverbootconf f 755 0 0 - - - - -
|
||||
/bin/help f 755 0 0 - - - - -
|
||||
/bin/ifget f 755 0 0 - - - - -
|
||||
/bin/ifup f 755 0 0 - - - - -
|
||||
/bin/initblockdev f 755 0 0 - - - - -
|
||||
/bin/initnetdev f 755 0 0 - - - - -
|
||||
/bin/login f 755 0 0 - - - - -
|
||||
/bin/netconf f 755 0 0 - - - - -
|
||||
/bin/recover f 755 0 0 - - - - -
|
||||
/bin/swiinfo f 755 0 0 - - - - -
|
||||
/bin/switchroot f 755 0 0 - - - - -
|
||||
/bin/sysinit f 755 0 0 - - - - -
|
||||
/bin/udhcpc f 755 0 0 - - - - -
|
||||
/bin/waitforblockdev f 755 0 0 - - - - -
|
||||
/bin/wipe f 755 0 0 - - - - -
|
||||
/bin/zcip f 755 0 0 - - - - -
|
||||
/lib/udhcpc-script f 755 0 0 - - - - -
|
||||
/lib/zcip-script f 755 0 0 - - - - -
|
||||
|
||||
@@ -13,3 +13,17 @@ packages:
|
||||
src/bin : /usr/bin
|
||||
|
||||
changelog: Changes
|
||||
|
||||
|
||||
- name: onl-vendor-config-onl-loader
|
||||
version: 1.0.0
|
||||
arch: all
|
||||
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
|
||||
maintainer: support@bigswitch.com
|
||||
summary: ONL Base Configuration Package (Loader)
|
||||
|
||||
files:
|
||||
src/python/onl : /usr/lib/python2.7/onl
|
||||
src/bin/initmounts : /bin/initmounts
|
||||
|
||||
changelog: Changes
|
||||
|
||||
3
packages/base/all/vendor-config-onl/src/bin/initmounts
Executable file
3
packages/base/all/vendor-config-onl/src/bin/initmounts
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/python
|
||||
from onl.mounts import OnlMountManager
|
||||
OnlMountManager.main()
|
||||
153
packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py
Executable file
153
packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py
Executable file
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
import subprocess
|
||||
import logging
|
||||
import time
|
||||
import json
|
||||
import yaml
|
||||
|
||||
class OnlMountManager(object):
|
||||
def __init__(self, mdata, logger):
|
||||
|
||||
if os.path.exists(mdata):
|
||||
mdata = yaml.load(open(mdata, "r"));
|
||||
|
||||
self.mdata = mdata
|
||||
self.logger = logger
|
||||
|
||||
# Needed to avoid ugly warnings from fsck
|
||||
if not os.path.exists('/etc/mtab'):
|
||||
open("/etc/mtab", 'w').close();
|
||||
|
||||
|
||||
def checkmount(self, directory):
|
||||
with open("/proc/mounts") as f:
|
||||
return directory in f.read()
|
||||
|
||||
def mount(self, device, directory, mode='r', timeout=5):
|
||||
self.logger.debug("Mounting %s -> %s %s" % (device, directory, mode))
|
||||
try:
|
||||
subprocess.check_call("mount -%s %s %s" % (mode, device, directory), shell=True)
|
||||
except subrocess.CalledProcessError, e:
|
||||
self.logger("Mount failed: '%s'" % e.output)
|
||||
return False
|
||||
|
||||
# If requested, wait for the mount to complete.
|
||||
while(timeout > 0):
|
||||
if self.checkmount(directory):
|
||||
break
|
||||
time.sleep(1)
|
||||
timeout-=1
|
||||
|
||||
if self.checkmount(directory):
|
||||
self.logger.info("%s is now mounted @ %s" % (device, directory))
|
||||
return True
|
||||
else:
|
||||
self.logger.info("%s failed to report in /proc/mounts." % (directory))
|
||||
|
||||
|
||||
|
||||
def mountall(self, all_=False, fsck=None, timeout=5):
|
||||
for (k, v) in self.mdata['mounts'].iteritems():
|
||||
|
||||
#
|
||||
# Make the mount point for future use.
|
||||
#
|
||||
if not os.path.isdir(v['dir']):
|
||||
self.logger.debug("Make directory '%s'..." % v['dir'])
|
||||
os.makedirs(v['dir'])
|
||||
|
||||
#
|
||||
# Get the partition device.
|
||||
# The timeout logic is here to handle waiting for the
|
||||
# block devices to arrive at boot.
|
||||
#
|
||||
while timeout > 0:
|
||||
try:
|
||||
v['device'] = subprocess.check_output("blkid -L %s" % k, shell=True).strip()
|
||||
break
|
||||
except subprocess.CalledProcessError:
|
||||
self.logger.debug("Block label %s does not yet exist..." % k)
|
||||
time.sleep(1)
|
||||
timeout -= 1
|
||||
|
||||
if 'device' not in v:
|
||||
self.logger.error("Timeout waiting for block label %s after %d seconds." % (k, timeout))
|
||||
continue;
|
||||
|
||||
self.logger.debug("%s @ %s" % (k, v['device']))
|
||||
|
||||
#
|
||||
# If its currently mounted we should unmount first.
|
||||
#
|
||||
if self.checkmount(v['device']):
|
||||
self.logger.info("%s is currently mounted." % (k))
|
||||
try:
|
||||
out = subprocess.check_output("umount %s" % v['device'], shell=True)
|
||||
self.logger.info("%s now unmounted." % (k))
|
||||
except subprocess.CalledProcessError,e:
|
||||
self.logger.error("Could not unmount %s @ %s: " % (k, v['device'], e.output))
|
||||
continue
|
||||
#
|
||||
# FS Checks
|
||||
#
|
||||
if fsck is not None:
|
||||
# Override fsck setting with given value
|
||||
self.logger.debug("Overriding fsck settings for %s with %s" % (k, fsck))
|
||||
v['fsck'] = fsck
|
||||
|
||||
if v.get('fsck', False):
|
||||
try:
|
||||
self.logger.info("Running fsck on %s [ %s ]..." % (k, v['device']))
|
||||
cmd = "fsck.ext4 -p %s" % (v['device'])
|
||||
self.logger.debug(cmd)
|
||||
try:
|
||||
out = subprocess.check_output(cmd, shell=True)
|
||||
self.logger.info("%s [ %s ] is clean." % (v['device'], k))
|
||||
except subprocess.CalledProcessError, e:
|
||||
self.logger.error("fsck failed: %s" % e.output)
|
||||
except subprocess.CalledProcessError, e:
|
||||
# Todo - recovery options
|
||||
raise
|
||||
|
||||
|
||||
if all_:
|
||||
v['mount'] = 'w'
|
||||
|
||||
mount = v.get('mount', None)
|
||||
if mount:
|
||||
if mount in ['r', 'w']:
|
||||
self.mount(v['device'], v['dir'], mode=mount, timeout=v.get('timeout', 5))
|
||||
else:
|
||||
self.logger("Mount %s has an invalid mount mode (%s)" % (k, mount))
|
||||
|
||||
|
||||
@staticmethod
|
||||
def main():
|
||||
import argparse
|
||||
|
||||
logging.basicConfig()
|
||||
|
||||
ap = argparse.ArgumentParser(description="ONL Mount Manager.");
|
||||
ap.add_argument("--mtab", default="/etc/mtab.yml")
|
||||
ap.add_argument("--rw", action='store_true')
|
||||
ap.add_argument("--verbose", "-v", action='store_true')
|
||||
ap.add_argument("--quiet", "-q", action='store_true')
|
||||
|
||||
ops = ap.parse_args();
|
||||
|
||||
logger = logging.getLogger("initmounts")
|
||||
if ops.verbose:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
elif ops.quiet:
|
||||
logger.setLevel(logging.ERROR)
|
||||
else:
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
mm = OnlMountManager(ops.mtab, logger)
|
||||
if ops.rw:
|
||||
mm.mountall(all_=True, fsck=False)
|
||||
else:
|
||||
mm.mountall()
|
||||
@@ -22,6 +22,7 @@ $(TARGET):
|
||||
$(ONLPM) --copy-file onl-buildroot-initrd:$(ARCH) onl-buildroot-initrd-$(ARCH).cpio.gz .
|
||||
sudo rm -rf $(ROOT) && mkdir $(ROOT)
|
||||
$(ONLPM) --sudo --force --extract-dir onl-loader-initrd-files:all $(ROOT)
|
||||
$(ONLPM) --sudo --force --extract-dir onl-vendor-config-onl-loader:all $(ROOT)
|
||||
$(ONLPM) --sudo $(foreach p,$(PLATFORM_PACKAGES),--extract-dir $(p) $(ROOT))
|
||||
$(ONL)/tools/sjson.py --kj version $(ONL)/make/version-onl.json --kl platforms $(PLATFORMS) --kv arch $(ARCH) --out manifest.json
|
||||
sudo mkdir -p $(ROOT)/etc/onl/loader && sudo cp manifest.json $(ROOT)/etc/onl/loader
|
||||
|
||||
Submodule packages/base/any/kernels/legacy/linux-3.9.6 updated: ea892415c5...0106373d79
Submodule packages/platforms-closed updated: 51991fb381...3880b54fe9
@@ -1,7 +1,7 @@
|
||||
# The loader is installed in the fat partition of the first USB storage device
|
||||
platform_bootcmd="usb start; usbiddev; fatload usb 0:1 70000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 70000000#$ONL_PLATFORM"
|
||||
platform_bootcmd="usb start; usbiddev; ext2load usb 0:1 70000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 70000000#$ONL_PLATFORM"
|
||||
|
||||
platform_installer() {
|
||||
# Standard installation to usb storage
|
||||
installer_standard_blockdev_install sda 128M 128M ""
|
||||
installer_standard_blockdev_install sda 128M 128M 1024M ""
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
############################################################
|
||||
|
||||
# The loader is installed in the fat partition of the first USB storage device
|
||||
platform_bootcmd="usb start; fatload usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
|
||||
platform_installer() {
|
||||
# Standard installation to usb storage
|
||||
installer_standard_blockdev_install sda 128M 128M ""
|
||||
installer_standard_blockdev_install sda 32M 32M 448M ""
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
############################################################
|
||||
|
||||
# The loader is installed in the fat partition of the first USB storage device
|
||||
platform_bootcmd="usb start; fatload usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
|
||||
platform_installer() {
|
||||
# Standard installation to usb storage
|
||||
installer_standard_blockdev_install sda 128M 128M ""
|
||||
installer_standard_blockdev_install sda 128M 128M 768M ""
|
||||
}
|
||||
|
||||
@@ -19,13 +19,9 @@
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
|
||||
# The loader must be written raw to the first partition.
|
||||
platform_loader_raw=1
|
||||
|
||||
# The loader is installed in the fat partition of the first USB storage device
|
||||
platform_bootcmd="usb start; usbboot 0x10000000 0:1; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
|
||||
platform_installer() {
|
||||
# Standard installation to usb storage
|
||||
installer_standard_blockdev_install sda 128M 128M ""
|
||||
}
|
||||
installer_standard_blockdev_install sda 128M 128M 1024M ""
|
||||
}
|
||||
|
||||
@@ -19,13 +19,9 @@
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
|
||||
# The loader must be written raw to the first partition.
|
||||
platform_loader_raw=1
|
||||
|
||||
# The loader is installed in the fat partition of the first USB storage device
|
||||
platform_bootcmd="usb start; usbboot 0x10000000 0:1; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
|
||||
platform_installer() {
|
||||
# Standard installation to usb storage
|
||||
installer_standard_blockdev_install sda 128M 128M ""
|
||||
}
|
||||
installer_standard_blockdev_install sda 128M 128M 1024M ""
|
||||
}
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
############################################################
|
||||
|
||||
# The loader is installed in the fat partition of the first USB storage device
|
||||
platform_bootcmd="usb start; fatload usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
|
||||
platform_installer() {
|
||||
# Standard installation to usb storage
|
||||
installer_standard_blockdev_install sda 128M 128M ""
|
||||
installer_standard_blockdev_install sda 128M 128M 768M ""
|
||||
}
|
||||
echo $platform_bootcmd
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
############################################################
|
||||
|
||||
# The loader is installed in the fat partition of the first USB storage device
|
||||
platform_bootcmd="usb start; fatload usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
|
||||
platform_installer() {
|
||||
# Standard installation to usb storage
|
||||
installer_standard_blockdev_install sda 128M 128M ""
|
||||
}
|
||||
installer_standard_blockdev_install sda 128M 128M 768M ""
|
||||
}
|
||||
|
||||
@@ -19,14 +19,10 @@
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
|
||||
# The loader must be written raw to the first partition.
|
||||
platform_loader_raw=1
|
||||
|
||||
# The bootcommand is to read the loader directly from the first partition and execute it.
|
||||
platform_bootcmd="diskboot 0x10000000 0:1 ; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
platform_bootcmd="ext2load ide 0:1 0x10000000 powerpc-quanta-lb9-r0.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
|
||||
platform_installer() {
|
||||
# Standard installation on the CF card.
|
||||
installer_standard_blockdev_install sda 128M 128M ""
|
||||
installer_standard_blockdev_install sda 128M 128M 1024M ""
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
############################################################
|
||||
|
||||
# The bootcommand is to read the loader directly from the first partition and execute it.
|
||||
platform_bootcmd="mmc part 0; fatload mmc 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
platform_bootcmd="mmc part 0; ext2load mmc 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM"
|
||||
|
||||
platform_installer() {
|
||||
# Standard installation on the CF card.
|
||||
installer_standard_blockdev_install mmcblk0 128M 128M ""
|
||||
installer_standard_blockdev_install mmcblk0 128M 128M 1024M ""
|
||||
}
|
||||
|
||||
|
||||
Submodule sm/bigcode updated: 334f99fa41...a5e6bc1d76
Reference in New Issue
Block a user