Fix firstrun/resize2fs, improve log upload, minor doc fixes

This commit is contained in:
ThomasKaiser
2016-06-09 23:21:51 +02:00
parent 1aa8383f29
commit 2e284be77d
4 changed files with 75 additions and 64 deletions

View File

@@ -83,6 +83,9 @@ and change the autologin user.
apt-get update
apt-get upgrade
This will not only update distribution packages (Debian/Ubuntu) but also updates Armbian kernel, u-boot and board support package if available. So if you've seen in the list of updated packages the names _u-boot_ or _linux_ the following command is required for changes to take effect:
reboot
# How to switch kernels or upgrade from other systems?
@@ -101,7 +104,7 @@ Check [this for manual way](http://www.armbian.com/kernel/) and more info.
**Important: If you came here since you can't get Armbian running on your board please keep in mind that in 95 percent of all cases it's either a faulty/fraud/counterfeit SD card or an insufficient power supply that's causing these sorts of _doesn't work_ issues!**
If you broke the system you can try to get in this way. You have to get to u-boot command prompt, using either a serial adapter or monitor and usb keyboard.
If you broke the system you can try to get in this way. You have to get to u-boot command prompt, using either a serial adapter or monitor and usb keyboard (USB support in u-boot currently not enabled on all H3 boards).
After switching power on or rebooting, when u-boot loads up, press some key on the keyboard (or send some key presses via terminal) to abort default boot sequence and get to the command prompt:
@@ -235,8 +238,7 @@ Alter **min_speed** or **max_speed** variable.
apt-get -y install xorg lightdm xfce4 tango-icon-theme gnome-icon-theme
reboot
Check [this site](http://namhuy.net/1085/install-gui-on-debian-7-wheezy.html) for others.
Check [this site](http://namhuy.net/1085/install-gui-on-debian-7-wheezy.html) for others and be prepared that some desktop image features currently might not work afterwards (eg. 2D/3D/video HW acceleration, so downgrading a _desktop_ image, removing the `libxfce4util-common` package and doing an `apt-get autoremove` later might be the better idea in such cases)
# How to upgrade Debian from Wheezy to Jessie?
@@ -248,16 +250,15 @@ Check [this site](http://namhuy.net/1085/install-gui-on-debian-7-wheezy.html) fo
apt-get dist-upgrade
# How to upgrade from Ubuntu Trusty to next LTS?
# How to upgrade from Ubuntu Trusty to 16.04 LTS (Xenial Xerus)?
... when available.
apt-get install update-manager-core
do-release-upgrade -d
# further to vivid
do-release-upgrade -d
# further to xenial
apt-get dist-upgrade
# How to toggle boot output?
Edit and change [boot parameters](http://redsymbol.net/linux-kernel-boot-parameters/) in /boot/boot.cmd:
- console=ttyS0,115200
@@ -274,6 +275,7 @@ Serial console on imx6 boards are ttymxc0 (Hummingboard, Cubox-i) or ttymxc1 (Ud
# How to toogle verbose boot?
touch /boot/.force-verbose # enable
You need to reboot to conduct changes.
rm /boot/.force-verbose # disable
@@ -327,7 +329,7 @@ Check which wireless stations / routers are in range
iwlist wlan0 scan | grep ESSID
# How to install to NAND, SATA & USB?
# How to install to eMMC, NAND, SATA & USB?
[su_youtube_advanced url="https:\/\/youtu.be\/6So8MA-qru8" controls="yes" showinfo="no" loop="yes" rel="no" modestbranding="yes"]
@@ -338,10 +340,10 @@ NAND:
* kernel 3.4.x and NAND storage
* pre-installed system on NAND (stock Android or other Linux)
SATA/USB:
eMMC/SATA/USB:
* any kernel
* pre-partitioned SATA or USB storage
* onboard eMMC storage or permanently attached SATA or USB storage
Start the install script:
@@ -350,8 +352,8 @@ Start the install script:
and follow the guide. You can create up to three scenarios:
* boot from SD, system on SATA / USB
* boot from NAND, system on NAND
* boot from NAND, system on SATA / USB
* boot from eMMC / NAND, system on eMMC/NAND
* boot from eMMC / NAND, system on SATA / USB
# How to change network configuration?

View File

@@ -157,7 +157,12 @@ ParseOptions() {
(echo "Network/firewall problem detected. Please fix this or upload /var/log/armhwinfo.log manually." >&2 ; exit 1)
which curl >/dev/null 2>&1 || apt-get -f -qq -y install curl
echo -e "/var/log/armhwinfo.log has been uploaded to \c"
CollectSupportInfo | curl -F 'sprunge=<-' http://sprunge.us
# we obfuscate IPv4 addresses somehow but not too much, MAC addresses have to remain
# in clear since otherwise the log becomes worthless due to randomly generated
# addresses here and there that might conflict
CollectSupportInfo \
| sed -E 's/([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3})/XXX.XXX.\3\4/g' \
| curl -F 'sprunge=<-' http://sprunge.us
echo -e "Please post the URL in the Armbian forum where you've been asked for."
exit 0
;;
@@ -652,7 +657,12 @@ CollectSupportInfo() {
cat /var/log/armhwinfo.log
[ -z $SUDO_USER ] || echo -e "\n### Group membership of $(groups $SUDO_USER)"
echo -e "\n### Installed packages:\n\n$(dpkg -l | egrep "armbian| linux-")"
[[ -e /boot/script.bin ]] && echo -e "\n### fex settings: $(ls -la /boot/script.bin)\n\n$(bin2fex /boot/script.bin 2>/dev/null)"
KernelVersion=$(awk -F" " '{print $3}' < /proc/version)
case ${KernelVersion} in
3.*)
[[ -e /boot/script.bin ]] && echo -e "\n### fex settings: $(ls -la /boot/script.bin)\n\n$(bin2fex /boot/script.bin 2>/dev/null)"
;;
esac
echo -e "\n### dmesg now:\n\n$(dmesg | tail -n 250)"
ls /tmp/armbianmonitor_checks_* >/dev/null 2>&1 || return
for file in /tmp/armbianmonitor_checks_* ; do

View File

@@ -33,7 +33,7 @@ cat > /tmp/create_swap.sh <<EOT
# SSH Keys creation
rm -f /etc/ssh/ssh_host*
dpkg-reconfigure openssh-server >/dev/null 2>&1
echo -e "\n### [firstrun] Recreated SSH keys" >>${Log}
echo -e "### [firstrun] Recreated SSH keys" >>${Log}
MEMTOTAL=$(( $(awk -F" " '/^MemTotal/ {print $2}' </proc/meminfo) / 1024 ))
FREESIZE=\$(df -hm / | awk '/\// {print \$(NF-2)}')
SWAPFILE=/var/swap
@@ -65,6 +65,7 @@ fi
while [ -f /tmp/firstrun_running ]; do sleep 1; done
if [ -f "/var/run/reboot" ]; then reboot; fi
rm -f /tmp/create_swap.sh
sync &
EOT
chmod +x /tmp/create_swap.sh
@@ -163,8 +164,7 @@ do_expand_rootfs() {
else
# Unattended mode. We 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
echo -e "\n### quick iozone test:$(iozone -e -I -a -s 1M -r 4k -i 0 -i 1 -i 2 | grep '^ 1024' | sed 's/ 1024 //')" >>/var/log/armhwinfo.log
# check device capacity. If 4GB or below do not use whole card but leave a 5% spare area
# to help older cards with wear leveling and garbage collection. In case this reduced card
@@ -202,19 +202,28 @@ do_expand_rootfs() {
# Start resizing
echo -e "\n### [firstrun] ${ResizeLog}. Start resizing Partition now:\n" >>${Log}
cat /proc/partitions >>${Log}
echo -e "\nExecuting fdisk, fsck and partprobe:\n" >>${Log}
if [ "X${DISTRIBUTION}" = "Xxenial" -a "X${PARTITIONS}" = "X1" ]; then
((echo d; echo n; echo p; echo ; echo $STARTFROM; echo ${LASTSECTOR} ; echo w;) | fdisk ${DEVICE}) >>${Log} 2>&1 || true
echo -e "\nExecuting fdisk, fsck and partprobe:" >>${Log}
UtilLinuxVersion=$(echo q | fdisk ${DEVICE} | awk -F"util-linux " '/ fdisk / {print $2}')
if [ "X${PARTITIONS}" = "X1" ]; then
case ${UtilLinuxVersion} in
2.27.1*)
# if dealing with fdisk from util-linux 2.27.1 we need a workaround for just 1 partition
# https://github.com/igorpecovnik/lib/issues/353#issuecomment-224728506
((echo d; echo n; echo p; echo ; echo $STARTFROM; echo ${LASTSECTOR} ; echo w;) | fdisk ${DEVICE}) >>${Log} 2>&1 || true
;;
*)
((echo d; echo $PARTITIONS; echo n; echo p; echo ; echo $STARTFROM; echo ${LASTSECTOR} ; echo w;) | fdisk ${DEVICE}) >>${Log} 2>&1 || true
;;
esac
else
((echo d; echo $PARTITIONS; echo n; echo p; echo ; echo $STARTFROM; echo ${LASTSECTOR} ; echo w;) | fdisk ${DEVICE}) >>${Log} 2>&1 || true
fi
echo -e "\nNew partition table:\n" >>${Log}
s=0
fsck -f $root_partition >>${Log} ll 2>&1 || true
partprobe ${DEVICE} >>${Log} ll 2>&1 || s=$?
fsck -f $root_partition >>${Log} 2>&1 || true
partprobe ${DEVICE} >>${Log} 2>&1 || s=$?
echo -e "\nNew partition table:\n" >>${Log}
cat /proc/partitions >>${Log}
echo -e "\nNow executing resize2fs to enlarge ${root_partition} to the maximum\n:" >>${Log}
echo -e "\nNow executing resize2fs to enlarge ${root_partition} to the maximum:\n" >>${Log}
resize2fs $root_partition >>${Log} 2>&1 || true
# check whether reboot is necessary for resize2fs to take effect
@@ -223,7 +232,7 @@ do_expand_rootfs() {
touch /var/run/reboot
display_alert "Automatic reboot is needed. Please wait"
update-rc.d resize2fs defaults >/dev/null 2>&1
echo -e "\n### [firstrun] Automated reboot needed to let /etc/init.d/resize2fs do the job\n" >>${Log}
echo -e "\n### [firstrun] Automated reboot needed to let /etc/init.d/resize2fs do the job" >>${Log}
fi
return 0
} # do_expand_rootfs

View File

@@ -11,49 +11,39 @@
# Description:
### END INIT INFO
set -e
ROOTFS=$(findmnt / | awk -F" " '/\/dev\// {print $2"\t"$3}')
set ${ROOTFS}
device=$1
rootfstype=$2
if [ -z $rootfstype ]; then
device="/dev/"$(lsblk -idn -o NAME | grep mmcblk0)
PARTITIONS=$(($(fdisk -l $device | grep $device | wc -l)-1))
device="/dev/"$(lsblk -idn -o NAME | grep mmcblk0)"p"$PARTITIONS
N=/etc/init.d/resize2fs
root_device=$(mountpoint -d /)
for file in /dev/* ; do
CURRENT_DEVICE=$(printf "%d:%d" $(stat --printf="0x%t 0x%T" $file))
if [ $CURRENT_DEVICE = $root_device ]; then
root_partition=$file
break;
fi
done
rootfstype=$(blkid -s TYPE -o value $root_partition)
fi
case "$1" in
start)
start)
set -e
# Try to get rootfs device and type
ROOTFS=$(findmnt / | awk -F" " '/\/dev\// {print $2"\t"$3}')
set ${ROOTFS}
device=$1
rootfstype=$2
# If this doesn't work (wheezy) then try it the old way
if [ -z $rootfstype ]; then
device="/dev/"$(lsblk -idn -o NAME | grep mmcblk0)
PARTITIONS=$(($(fdisk -l $device | grep $device | wc -l)-1))
device="/dev/"$(lsblk -idn -o NAME | grep mmcblk0)"p"$PARTITIONS
N=/etc/init.d/resize2fs
root_device=$(mountpoint -d /)
for file in /dev/* ; do
CURRENT_DEVICE=$(printf "%d:%d" $(stat --printf="0x%t 0x%T" $file))
if [ $CURRENT_DEVICE = $root_device ]; then
root_partition=$file
break;
fi
done
rootfstype=$(blkid -s TYPE -o value $root_partition)
fi
# if ext4 and rootfs should be resized then do it
if [[ $rootfstype == ext4 && ! -f "/root/.no_rootfs_resize" ]]; then
echo -e "\n### [resize2fs] Start resizing partition now\n" >>/var/log/armhwinfo.log
/sbin/resize2fs $device >>/var/log/armhwinfo.log 2>&1
fi
if [[ ! -f "/var/swap" ]]; then
dd if=/dev/zero of=/var/swap bs=1024 count=131072 status=noxfer >/dev/null 2>&1
chown root:root /var/swap
chmod 0600 /var/swap
mkswap /var/swap >/dev/null 2>&1
swapon /var/swap >/dev/null 2>&1
if ! grep -q swap /etc/fstab; then echo "/var/swap none swap sw 0 0" >> /etc/fstab; fi
if ! grep -q swap /etc/sysctl.conf; then echo "vm.swappiness=0" >> /etc/sysctl.conf; fi
fi
# disable further executions of this script
update-rc.d -f resize2fs remove >/dev/null 2>&1
;;
*)
exit 1
;;
esac
exit 0