0%

Ubuntu 根目录扩容脚本

Ubuntu server 下根目录扩容脚本

基于橙子派写的,不同设备分区名不同自行修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

set -e

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

set -x

DEVICE="/dev/mmcblk0"
PART="2"

resize() {
start=$(fdisk -l ${DEVICE}|grep ${DEVICE}p${PART}|awk '{print $2}')
echo $start

set +e
fdisk ${DEVICE} <<EOF
p
d
2
n
p
2
$start

w
EOF
set -e

partx -u ${DEVICE}
resize2fs ${DEVICE}p${PART}
}

resize

echo "Done!"

新年快乐!