FreeBSD 11 磁盘空间扩容

作者 bluse wang 日期 2018-06-16
FreeBSD 11 磁盘空间扩容

场景

阿里云买了个60G的系统盘ECS。进去一看只有20G!
原因是:它刷镜像时,只刷了前边的20G。后边的40G,就成了空白。结果交到我手上,就成了个半成品。
只得自己给它扩容

初始状态:

1
2
3
4
root@log:~ # df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/ufsid/59a7effe7885633c 19G 4.1G 14G 23% /
devfs 1.0K 1.0K 0B 100% /dev

第一步:查看

1
2
3
4
5
root@log:~ # gpart show
=> 63 125829057 vtbd0 MBR (60G)
63 1 - free - (512B)
64 41942975 1 freebsd [active] (20G)
41943039 83886081 - free - (40G)

的确有40G的空白

第二步:重置大小

1
2
root@log:~ # gpart resize -i 1 -a 4k -s 59G vtbd0
vtbd0s1 resized

-i 1 这里的1是抄写 gpart showvtbd0一栏下当前正使用的磁盘的编号
-s 59G 为什么要丢掉一个G?因为交换分区需要空间。

第三步:执行配置

1
2
3
4
5
6
7
8
root@log:~ # service growfs onestart
Growing root partition to fill device
vtbd0s1 resized
super-block backups (for fsck_ffs -b #) at:
42314112, 43596352, 44878592, 46160832, 47443072, 48725312, 50007552, 51289792, 52572032, 53854272, 55136512, 56418752, 57700992, 58983232, 60265472, 61547712, 62829952,
64112192, 65394432, 66676672, 67958912, 69241152, 70523392, 71805632, 73087872, 74370112, 75652352, 76934592, 78216832, 79499072, 80781312, 82063552, 83345792, 84628032,
85910272, 87192512, 88474752, 89756992, 91039232, 92321472, 93603712, 94885952, 96168192, 97450432, 98732672, 100014912, 101297152, 102579392, 103861632, 105143872, 106426112,
107708352, 108990592, 110272832, 111555072, 112837312, 114119552, 115401792, 116684032, 117966272, 119248512, 120530752, 121812992, 123095232, 124377472, 125659712

完成!并检查

1
2
3
4
5
6
7
8
root@log:~ # df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/ufsid/59a7effe7885633c 58G 4.2G 49G 8% /
devfs 1.0K 1.0K 0B 100% /dev
root@log:~ # gpart show
=> 63 125829057 vtbd0 MBR (60G)
63 1 - free - (512B)
64 125829056 1 freebsd [active] (60G)