cubietruck-slackware/scripts/resize2fs-arch.sh

81 lines
1.6 KiB
Bash
Raw Normal View History

2014-02-15 13:06:26 +01:00
#!/bin/bash
#
#
# Script to resize the partition and filesystem on SD card for
# Archlinux - Cubietruck
#
# Written by Klaus Schulz (soundcheck @ cubieforum.com)
#
# Use script at your own risk. There is a high risk that your loose your data
# by using the script, since it repartitions your media in realtime (mounted)
#
#####################################################################################
2014-02-15 15:09:33 +01:00
REVISION=2.0
DATE=02152014
2014-02-15 13:06:26 +01:00
2014-02-15 15:09:33 +01:00
DISCID=mmcblk0
2014-02-15 13:06:26 +01:00
PARTID=mmcblk0p1
2014-02-15 15:09:33 +01:00
test -b /dev/$DISCID || { echo "SD device /dev/$DISCID can not be identifed. Please verify." ; exit 1 ; } ;
2014-02-15 13:06:26 +01:00
resizepartition() {
echo "******Resizing partition******************************"
echo
sync
2014-02-15 15:09:33 +01:00
FIRSTSECTOR="$(( echo p) | fdisk "/dev/$DISCID" | grep $PARTID | sed "s/\*//g" | tr -s " " | cut -f 2 -d " " )"
#echo $FIRSTSECTOR
( echo d; echo n; echo p; echo 1; echo $FIRSTSECTOR; echo; echo w; ) | fdisk /dev/$DISCID
2014-02-15 13:06:26 +01:00
shutdown -r now
}
resizefs() {
echo "******Resizing filesystem******************************"
echo
resize2fs -p /dev/$PARTID
}
help() {
echo "
###############################################
2014-02-15 15:09:33 +01:00
FS partitioning and resizing tool
for SD card
2014-02-15 13:06:26 +01:00
Revision $REVISION
Warning:
You might loose all your data by running this
script. Run at your own risk!!!!
###############################################
Options:
-p : resizes mounted!! partition and reboots
-f : resizes filesystem
-h : help
###############################################
"
}
#####main################################################################################################
case $1 in
2014-02-15 15:09:33 +01:00
-p) resizepartition
2014-02-15 13:06:26 +01:00
;;
2014-02-15 15:09:33 +01:00
-f) resizefs
2014-02-15 13:06:26 +01:00
;;
*) help
;;
esac
exit 0