Merge pull request #246 from ThomasKaiser/master
Added logging of SD card parameters and move auto detection override …
This commit is contained in:
commit
cf773bf431
@ -6,7 +6,7 @@
|
||||
|
||||
If it is a new feature request, don't start the coding first. Remember to [open an issue](https://guides.github.com/features/issues/) to discuss the new feature.
|
||||
|
||||
If you are strougling, check [this detailed step by step guide on contributing](https://www.exchangecore.com/blog/contributing-concrete5-github/).
|
||||
If you are struggling, check [this detailed step by step guide on contributing](https://www.exchangecore.com/blog/contributing-concrete5-github/).
|
||||
|
||||
# How to build Armbian image or custom kernel?
|
||||
|
||||
@ -67,7 +67,7 @@ Run the script
|
||||
- **EXTENDED_DEBOOTSTRAP** (yes|**no**): use new debootstrap and image creation process
|
||||
- **FORCE_USE_RAMDISK** (yes|no): overrides autodetect for using tmpfs in new debootstrap and image creation process. Takes effect only if `EXTENDED_DEBOOTSTRAP` is set to "yes"
|
||||
- **FIXED_IMAGE_SIZE** (integer): create image file of this size (in megabytes) instead of minimal. Takes effect only if `EXTENDED_DEBOOTSTRAP` is set to "yes"
|
||||
- **COMPRESS_OUTPUTIMAGE** (**yes**|no): create zip archive with image file and GPG signature for redistribution
|
||||
- **COMPRESS_OUTPUTIMAGE** (**yes**|no): create compressed archive with image file and GPG signature for redistribution
|
||||
- **SEVENZIP** (yes|**no**): create .7z archive with extreme compression ratio instead of .zip
|
||||
- **ROOTFS_TYPE** (**ext4**|f2fs|btrfs|nfs|fel): create image with different root filesystems instead of default ext4. Requires setting FIXED_IMAGE_SIZE to actual size of your SD card for F2FS and BTRFS. Takes effect only if `EXTENDED_DEBOOTSTRAP` is set to "yes"
|
||||
|
||||
@ -98,7 +98,7 @@ You can run additional commands to customize created image. Edit file:
|
||||
|
||||
userpatches/customize-image.sh
|
||||
|
||||
and place your code here. You may test values of variables noted in the file to use different commands for different configurations. Those commands will be executed in a process of building just before closing image.
|
||||
and place your code here. You may test values of variables noted in the file to use different commands for different configurations. Those commands will be executed in a chroot environment just before closing image.
|
||||
|
||||
To add files to image easily, put them in `userpatches/overlay` and access them in `/tmp/overlay` from `customize-image.sh`
|
||||
|
||||
@ -167,7 +167,7 @@ To recreate those files you need to remove them manually.
|
||||
|
||||
## Kernel install ##
|
||||
|
||||
When root filesystem is ready we need to instal kernel image with modules, board definitions, firmwares. Along with this we set the CPU frequency min/max, hostname, modules, network interfaces templates. Here is also the place to install headers and fix + native compile them on the way.
|
||||
When root filesystem is ready we need to install kernel image with modules, board definitions, firmwares. Along with this we set the CPU frequency min/max, hostname, modules, network interfaces templates. Here is also the place to install headers and fix + native compile them on the way.
|
||||
|
||||
## Distribution fixes ##
|
||||
|
||||
|
||||
@ -229,8 +229,22 @@ log_hardware_info() {
|
||||
ifconfig >>${Log}
|
||||
echo -e "\n### df:\n" >>${Log}
|
||||
df -h >>${Log}
|
||||
get_flash_information >>${Log} &
|
||||
} # log_hardware_info
|
||||
|
||||
get_flash_information() {
|
||||
# http://www.bunniestudios.com/blog/?page_id=1022
|
||||
find /sys -name oemid | while read Device ; do
|
||||
DeviceNode="${Device%/*}"
|
||||
DeviceName="${DeviceNode##*/}"
|
||||
echo -e "\n### ${DeviceName} info:\n"
|
||||
find "${DeviceNode}" -maxdepth 1 -type f | while read ; do
|
||||
NodeName="${REPLY##*/}"
|
||||
echo -e "$(printf "%20s" ${NodeName}): $(cat "${DeviceNode}/${NodeName}" | tr '\n' " ")"
|
||||
done
|
||||
done
|
||||
} # get_flash_information
|
||||
|
||||
show_motd_warning() {
|
||||
cat > /etc/update-motd.d/90-warning <<EOT
|
||||
#!/bin/bash
|
||||
@ -253,11 +267,13 @@ case $1 in
|
||||
|
||||
# display message, log hardware id to file, write log
|
||||
echo -e "[\e[0;32m ok \x1B[0m] Starting ARM hardware info: $ID"
|
||||
echo $ID > /var/run/machine.id
|
||||
echo $ID >/var/run/machine.id
|
||||
if [ $? -ne 0 ]; then
|
||||
# most probably readonly fs. We'll try to warn the user.
|
||||
show_motd_warning "It seems the rootfs is readonly at the moment. Please check your SD card for errors"
|
||||
fi
|
||||
# check whether auto detection override exists and if true use this for machine.id
|
||||
[ -f /root/.machine.id ] && cat /root/.machine.id >/var/run/machine.id
|
||||
log_hardware_info
|
||||
|
||||
# crash detection, enable verbose logging and disable it at clean shutdown
|
||||
@ -283,3 +299,4 @@ case $1 in
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ MEMTOTAL=$(( $(awk -F" " '/^MemTotal/ {print $2}' </proc/meminfo) / 1024 ))
|
||||
FREESIZE=\$(df -hm / | awk '/\// {print \$(NF-2)}')
|
||||
if [[ ! -f "/var/swap" && "\$FREESIZE" -gt "132" ]]; then
|
||||
fallocate -l 128M /var/swap >/dev/null 2>&1
|
||||
if [ $? -eq 1 ]; then dd if=/dev/zero of=/var/swap bs=1024 count=131072 status=noxfer >/dev/null 2>&1; fi
|
||||
if [ $? -eq 1 ]; then dd if=/dev/zero of=/var/swap bs=1M count=128 status=noxfer >/dev/null 2>&1; fi
|
||||
chown root:root /var/swap
|
||||
chmod 0600 /var/swap
|
||||
mkswap /var/swap >/dev/null 2>&1
|
||||
@ -120,15 +120,9 @@ autodetect_sunxi() {
|
||||
echo heartbeat >/sys/class/leds/blue_led/trigger
|
||||
fi
|
||||
|
||||
# check whether the auto detection override exists and if true use this as $MACHINE
|
||||
if [ -f /root/.machine.id ]; then
|
||||
read MACHINE </root/.machine.id
|
||||
else
|
||||
# wait for armhwinfo
|
||||
sleep 3
|
||||
MACHINE="$(tail -n1 /run/machine.id)"
|
||||
fi
|
||||
|
||||
# wait for armhwinfo
|
||||
sleep 3
|
||||
read MACHINE </run/machine.id
|
||||
NEWHOSTNAME="$(echo "${MACHINE}" | tr '[:upper:]' '[:lower:]' | sed -e 's/+/plus/' -e 's/\ //g')"
|
||||
ScriptBinName="$(echo "${NEWHOSTNAME}" | sed -e 's/2mini$/2/g' -e 's/plus2$/plus/g').bin"
|
||||
ScriptBinUsed="$(readlink -f "/boot/script.bin")"
|
||||
@ -225,6 +219,7 @@ do_expand_rootfs() {
|
||||
# should know what he's doing)
|
||||
CAPACITY=$(parted ${DEVICE} unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", \$2 / ( 1024 / \$4 ))}")
|
||||
if [ ${CAPACITY} -lt 4000000 ]; then
|
||||
# we also run a q&d benchmark to be able to identify cards way too slow easily
|
||||
cd /root
|
||||
echo -e "\n### quick iozone test:\c" >>/var/log/armhwinfo.log
|
||||
iozone -e -I -a -s 1M -r 4k -i 0 -i 1 -i 2 | grep '^ 1024' | sed 's/ 1024 //' >>/var/log/armhwinfo.log
|
||||
@ -283,4 +278,3 @@ main() {
|
||||
|
||||
main
|
||||
exit 0
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user