在腾讯云买了一个虚拟服务器,安装了FreeBSD 13.1操作系统。
登录后升级:
freebsd-update -r 13.2-RELEASE upgrade
操作系统已经升级到13.2-RELEASE。升级全部已经安装的软件:
pkg-static upgrade -f
接下来扩大分区空间。先查看分区情况:
# gpart show
=> 63 209715137 vtbd0 MBR (100G)
63 1 - free - (512B)
64 20971456 1 freebsd [active] (10G)
20971520 188743680 - free - (90G)
=> 0 20971456 vtbd0s1 BSD (10G)
0 20971456 1 freebsd-ufs (10G)
默认分区空间只有10G,我买了100G的磁盘空间,需要把剩余的空间全部用起来。上面命令显示的 vtbd0 是硬盘的名称。
# gpart resize -i 1 -s 100G -a 4k /dev/vtbd0
vtbd0s1 resized
这样就调整完分区的大小。下一步是扩充文件系统,让它使用新增的空间:
# service growfs onestart
Growing root partition to fill device
vtbd0s1 resized
vtbd0s1a resized
gpart: arg0 'vtbd0s1a': Invalid argument
super-block backups (for fsck_ffs -b #) at:
21798272, 23080512, 24362752, 25644992, 26927232, 28209472, 29491712, 30773952, 32056192, 33338432, 34620672,
35902912, 37185152, 38467392, 39749632, 41031872, 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, 126941952, 128224192, 129506432, 130788672,
132070912, 133353152, 134635392, 135917632, 137199872, 138482112, 139764352, 141046592, 142328832, 143611072,
144893312, 146175552, 147457792, 148740032, 150022272, 151304512, 152586752, 153868992, 155151232, 156433472,
157715712, 158997952, 160280192, 161562432, 162844672, 164126912, 165409152, 166691392, 167973632, 169255872,
170538112, 171820352, 173102592, 174384832, 175667072, 176949312, 178231552, 179513792, 180796032, 182078272,
183360512, 184642752, 185924992, 187207232, 188489472, 189771712, 191053952, 192336192, 193618432, 194900672,
196182912, 197465152, 198747392, 200029632, 201311872, 202594112, 203876352, 205158592, 206440832, 207723072,
209005312
查看分区情况:
# gpart show
=> 63 209715137 vtbd0 MBR (100G)
63 1 - free - (512B)
64 209715136 1 freebsd [active] (100G)
=> 0 209715136 vtbd0s1 BSD (100G)
0 209715136 1 freebsd-ufs (100G)
这样操作之后,分区就使用了全部磁盘空间。
操作系统没有swap分区,需要创建一个swap文件供系统使用。swap分区的用途是将当前不使用的内存数据转存到磁盘分区,腾出更多的物理内存供正在运行的应用程序使用。
我的服务器只有2内存,所以创建一个大小为 2G 的 swap 文件:
# dd if=/dev/zero of=/usr/swap0 bs=1m count=2048
改变文件的权限:
# chmod 0600 /usr/swap0
在 /etc/fstab 文件中添加下面一行:
md none swap sw,file=/usr/swap0,late 0 0
立即使用swap文件:
# swapon -aL
使用top命令,显示:
CPU: 0.0% user, 0.2% nice, 0.4% system, 0.0% interrupt, 99.4% idle
Mem: 688M Active, 714M Inact, 2212K Laundry, 306M Wired, 201M Buf, 44M Free
Swap: 2048M Total, 2048M Free
# swapinfo
Device 1K-blocks Used Avail Capacity
/dev/md0 2097152 0 2097152 0%
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。