Linux

Skript zum anpassen der root PartitionScript for resize root partition

hi there, here a little script for resize the root partition on the bpi or like somthing else


cat < /root/resize.sh
#!/bin/bash

fdisk_first() {
p2_start=`fdisk -l /dev/mmcblk0 | grep mmcblk0p2 | awk '{print $2}'`
echo "Found the start point of mmcblk0p2: $p2_start"
fdisk /dev/mmcblk0 << __EOF__ >> /dev/null
d
2
n
p
2
$p2_start

p
w
__EOF__

sync
touch /root/.resize
echo "Ok, Partition resized, please reboot now"
echo "Once the reboot is completed please run this script again"
}

resize_fs() {
echo "Activating the new size"
resize2fs /dev/mmcblk0p2 >> /dev/null
echo "Done!"
echo "Enjoy your new space!"
rm -rf /root/.resize
}

if [ -f /root/.resize ]; then
resize_fs
else
fdisk_first
fi
EOT

you can find the file here /root/resize.sh
then chmod +x /root/resize.sh
run it once with ./root/resize.sh
reboot your system and run the script again

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.