mirror of
https://github.com/Fishwaldo/build.git
synced 2025-03-26 16:51:48 +00:00
First run scripts added functionality. If there is not enough space, create SWAP area after reboot - when FS is expanded
This commit is contained in:
parent
32c047d08f
commit
4d962842cd
4 changed files with 17 additions and 5 deletions
|
@ -2,6 +2,7 @@
|
|||
# only do this for interactive shells
|
||||
if [ "$-" != "${-#*i}" ]; then
|
||||
if [ -f "$HOME/.not_logged_in_yet" ]; then
|
||||
echo ""
|
||||
echo -e "\e[0;31mThank you for choosing Armbian. Support: www.armbian.com\x1B[0m"
|
||||
echo ""
|
||||
rm -f "$HOME/.not_logged_in_yet"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# only do this for interactive shells
|
||||
if [ "$-" != "${-#*i}" ]; then
|
||||
if [ -f "/tmp/.reboot_required" ]; then
|
||||
echo ""
|
||||
echo -e "[\e[0;91m Kernel was updated, please reboot!\x1B[0m ]"
|
||||
echo ""
|
||||
rm "/tmp/.reboot_required"
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# starting at first time.
|
||||
# regenerate ssh host key
|
||||
### END INIT INFO
|
||||
|
||||
#
|
||||
# Create this file to speed up boot process
|
||||
#
|
||||
|
@ -21,8 +20,9 @@ cat > /tmp/create_swap.sh <<EOT
|
|||
#
|
||||
# create swap and adds it into fstab
|
||||
#
|
||||
MEMTOTAL=$(awk 'BEGIN { printf "%.0f\n", '$(grep MemTotal /proc/meminfo | awk '{print $2}')'/1024/1024 }')
|
||||
if [ ! -f "/var/swap" ]; then
|
||||
MEMTOTAL=\$(awk 'BEGIN { printf "%.0f\n", '\$(grep MemTotal /proc/meminfo | awk '{print \$2}')'/1024/1024 }')
|
||||
FREESIZE=\$(df -hm / | awk '/\// {print \$(NF-2)}')
|
||||
if [[ ! -f "/var/swap" && "\$FREESIZE" -lt "132" ]]; 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
|
||||
|
@ -42,7 +42,7 @@ fi
|
|||
if [[ "$(apt-cache policy ramlog | grep Installed)" != "" ]]; then
|
||||
service ramlog enable
|
||||
# if we have 1G ram reduce RAMLOG size
|
||||
if [[ "$MEMTOTAL" -le "1" ]]; then
|
||||
if [[ "\$MEMTOTAL" -le "1" ]]; then
|
||||
if [ -f "/etc/default/ramlog" ]; then
|
||||
sed -e 's/TMPFS_RAMFS_SIZE=512m/TMPFS_RAMFS_SIZE=256m/g' -i /etc/default/ramlog
|
||||
fi
|
||||
|
@ -96,7 +96,8 @@ do_expand_rootfs(){
|
|||
fsck -f $root_partition >/dev/null 2>&1 || true
|
||||
partprobe $device >/dev/null 2>&1 || s=$?
|
||||
resize2fs $root_partition >/dev/null 2>&1 || true
|
||||
if [[ "$DISTRIBUTION" == "wheezy" || "$s" != "0" ]]; then
|
||||
FREESIZE=$(df -hm / | awk '/\// {print $(NF-2)}')
|
||||
if [[ "$DISTRIBUTION" == "wheezy" || "$s" != "0" || "$FREESIZE" -lt "152" ]]; then
|
||||
touch /var/run/reboot
|
||||
display_alert "Automatic reboot is needed. Please wait"
|
||||
update-rc.d resize2fs defaults >/dev/null 2>&1
|
||||
|
|
|
@ -31,6 +31,15 @@ case "$1" in
|
|||
if [[ $rootfstype == ext4 && ! -f "/root/.no_rootfs_resize" ]]; then
|
||||
/sbin/resize2fs $device >/dev/null 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
|
||||
update-rc.d -f resize2fs remove >/dev/null 2>&1
|
||||
;;
|
||||
*)
|
||||
|
|
Loading…
Add table
Reference in a new issue