The page you are reading is served from a web server running with FreeBSD 15.1-RELEASE-p2 on an EC2 instance from Amazon Web Services (AWS). The instance type is a t4g.micro with a 10 GiB EBS volume and it costs me around USD 7.84 per month to keep the lights on.

In fact, I don’t pay anything. I’ve got so many credits from filling out AWS questionnaires.

But questionnaires are not what I want to talk about. 10 GiB is not much by today’s standards. Package upgrades pushed the limit on disk space.

A little more space was needed.

% df -h
Filesystem         Size    Used   Avail Capacity  Mounted on
/dev/gpt/rootfs    9.6G    6.3G    2.6G    71%    /
devfs              1.0K      0B    1.0K     0%    /dev
/dev/gpt/efiesp     32M    836K     31M     3%    /boot/efi

This is a writeup on what I did.

Increase EBS volume

This was easy.

  • Logged into AWS Console.
  • Went to EC2 > Volumes.
  • Select the instance > Actions > Modify volume.
  • Changed the size from 10 GiB to 20 GiB and clicked Modify.

I did not shutdown the instance.

You get a warning telling you, that if you are increasing the size of the volume, you must extend the file system to the new size of the volume.

Took only a couple seconds and voila the EBS volume had 20 GiB instead of the meagre 10 GiB. The web server did not crush by the way.

And to no ones surprise the operating system still reported the 10 GiB.

% df -h
Filesystem         Size    Used   Avail Capacity  Mounted on
/dev/gpt/rootfs    9.6G    6.3G    2.6G    71%    /
devfs              1.0K      0B    1.0K     0%    /dev
/dev/gpt/efiesp     32M    836K     31M     3%    /boot/efi

Increase disk partition

I use UFS and the EBS volume has the device name nda0.

Used gpart to find out.

% gpart show
=>      34  20971446  nda0  GPT  (10G)
        34     66584     1  efi  (33M)
     66618  20904862     2  freebsd-ufs  (10G)

Unfortunately the new unused disk space did not show up.

It did after a reboot, which gave me the missing 10 GiB, but corrupted.

% gpart show nda0   
=>      34  20971446  nda0  GPT  (20G) [CORRUPT]
        34     66584     1  efi  (33M)
     66618  20904862     2  freebsd-ufs  (10G)

Easy fix. Had to become root at this point.

# gpart recover nda0
nda0 recovered
# gpart show nda0
=>      34  41942966  nda0  GPT  (20G)
        34     66584     1  efi  (33M)
     66618  20904862     2  freebsd-ufs  (10G)
  20971480  20971520        - free -  (10G)

I gave the free space to partition 2.

# gpart resize -i 2 nda0
nda0p2 resized
# gpart show nda0
=>      34  41942966  nda0  GPT  (20G)
        34     66584     1  efi  (33M)
     66618  41876382     2  freebsd-ufs  (20G)

The official FreeBSD documentation says it’s better to not do this on a mounted partition. I decided to risk it all. Not running any mission-critical stuff.

Nothing happened. The web server was still doing its job.

Grow UFS

Final step was growing the UFS file system.

# df -hT
Filesystem       Type       Size    Used   Avail Capacity  Mounted on
/dev/gpt/rootfs  ufs        9.6G    6.3G    2.6G    71%    /
devfs            devfs      1.0K      0B    1.0K     0%    /dev
/dev/gpt/efiesp  msdosfs     32M    836K     31M     3%    /boot/efi

And

# growfs /dev/gpt/rootfs
Device is mounted read-write; resizing will result in temporary write suspension for /.
It's strongly recommended to make a backup before growing the file system.
OK to grow filesystem on /dev/gpt/rootfs, mounted on /, from 10GB to 20GB? [yes/no] yes
super-block backups (for fsck_ffs -b #) at:
 21805888, 23088576, 24371264, 25653952, 26936640, 28219328, 29502016, 30784704, 32067392, 33350080, 34632768, 35915456,
 37198144, 38480832, 39763520, 41046208

Again. No mission-critical in my house. Typed yes to proceed. No crash.

DONE.

# df -h
Filesystem         Size    Used   Avail Capacity  Mounted on
/dev/gpt/rootfs     19G    6.3G     12G    35%    /
devfs              1.0K      0B    1.0K     0%    /dev
/dev/gpt/efiesp     32M    836K     31M     3%    /boot/efi