1 Star 1 Fork 1

续不上的鹊桥/rpi-backup

forked from juju/rpi-backup 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
resize.sh 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
kevin 提交于 2019-06-16 15:44 . add root resize script
#!/bin/bash
FSTYPE=$(cat /proc/cmdline |tr ' ' '\n' | awk -F= '/rootfstype/{print $2}')
BLKDEV_ROOTPART=$(findmnt / -o SOURCE -n)
ROOTPART_SEQ=$(echo $BLKDEV_ROOTPART | grep -o "[0-9]$")
BLKDEV_ROOTPART_NAME=$(echo $BLKDEV_ROOTPART | cut -d "/" -f 3)
BLKDEV=/dev/$(find /sys/block/*/ | grep $BLKDEV_ROOTPART_NAME$ | cut -d "/" -f 4)
RESIZE_TARGET=$BLKDEV_ROOTPART
if [ ! $RESIZER ]; then
case $FSTYPE in
f2fs)
RESIZER=$(which resize.f2fs)
;;
ext2|ext3|ext4)
RESIZER=$(which resize2fs)
;;
btrfs)
RESIZER=$(which btrfs)
RESIZER_ARGS="filesystem resize max"
RESIZE_TARGET="/"
mount -o remount,rw $RESIZE_TARGET
;;
*)
RESIZER=$(which resize.$FSTYPE)
echo "FSTYPE is $FSTYPE, RESIZER could be $RESIZER"
;;
esac
if [ ! -e $RESIZER ]; then
echo "Filesystem resizer for $FSTYPE not found!"
exit 1
fi
fi
echo "Resizing partiton..."
parted -s $BLKDEV -- resizepart $ROOTPART_SEQ 100%
echo "Informing kernel..."
# Make sure we have updated partition info
partx -u $BLKDEV
partx -u $BLKDEV_ROOTPART
partprobe $BLKDEV
partprobe $BLKDEV_ROOTPART
echo "Resizing filesystem..."
$RESIZER $RESIZER_ARGS $RESIZE_TARGET
systemctl daemon-reload 2>/dev/null
ldconfig 2>/dev/null
echo "Syncing to disk..."
sync && sync
echo ''
echo "Rebooting in 5 seconds..."
a=5
for i in $(seq 1 5); do
echo $a
sleep 1
a=$((a-1))
done
echo "Rebooting..."
init 6
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ZTS11/rpi-backup.git
git@gitee.com:ZTS11/rpi-backup.git
ZTS11
rpi-backup
rpi-backup
master

搜索帮助