Skip to content
Permalink
Browse files

Create universal FS resize script + apply to NanoPi M4

  • Loading branch information...
NEMS Linux
NEMS Linux committed Apr 2, 2019
1 parent dc2f699 commit 289a66dd25b30d42c7c96d08b33b504c8dc83a23
Showing with 62 additions and 1 deletion.
  1. +1 −1 build/packages.base
  2. +1 −0 html
  3. +13 −0 nems-cleanup.sh
  4. +47 −0 resize_rootfs/nems-fs-resize
@@ -50,6 +50,6 @@ grub-common
grub-efi-amd64
grub-efi-amd64-bin
grub2-common
firmware-linux-nonfree
#firmware-linux-nonfree
ssh
less
1 html
Submodule html added at 7d7aff
@@ -259,6 +259,19 @@ nameserver 2001:4860:4860::8844
fi
fi

if (( $platform >= 67 )) && (( $platform <= 68 )); then
# NanoPi M4
addition="/root/nems/nems-admin/resize_rootfs/nems-fs-resize\n"
if grep -q "exit" /etc/rc.local; then
# This file contains an exit command, so make sure our new command comes before it
/bin/sed -i -- 's,exit,'"$addition"'exit,g' /etc/rc.local
else
# No exit command within the file, so just add it
echo "PLACEHERE" >> /etc/rc.local
/bin/sed -i -- 's,PLACEHERE,'"$addition"'exit 0,g' /etc/rc.local
fi
fi

# remove any package data left behind after removal
apt-get purge $(dpkg -l | awk '/^rc/ { print $2 }')

@@ -0,0 +1,47 @@
#!/bin/sh
rootdev=`/usr/local/bin/nems-info rootdev`
rootpart=`/usr/local/bin/nems-info rootpart`

set -e

if [ "$(id -u)" -ne "0" ]; then
echo "This script requires root."
exit 1
fi

set -x

resize() {
start=$(fdisk -l /dev/${rootdev}|grep /dev/${rootdev}p${rootpart}|awk '{print $2}')
echo $start

set +e
fdisk /dev/${rootdev} <<EOF
p
d
$rootpart
n
p
$rootpart
$start
w
EOF
set -e

partx -u /dev/${rootdev}
resize2fs /dev/${rootdev}p${rootpart}
}

resize

# Log that patch (resize) has been applied to this system
# Activates features such as bootscreen.sh
if ! grep -q "PATCH-000002" /var/log/nems/patches.log; then
echo "PATCH-000002" >> /var/log/nems/patches.log
fi

echo "Done!"

sed -i "s,/root/nems/nems-admin/resize_rootfs/nems-fs-resize,,g" /etc/rc.local

0 comments on commit 289a66d

Please sign in to comment.
You can’t perform that action at this time.