Azure VM Size Standard B1ms (1 vcpu, 2 GiB memory)
Recommended VM size https://docs.opnsense.org/manual/hardware.html
Boot to single user mode by pressing the 2 key when booting. If running in Azure you may need to connect to the serial console and reboot first to see the boot menu
This is the command to show the partitions
root@:/ # gpart show
=> 40 16777136 da0 GPT (40G) [CORRUPT]
40 532480 1 efi (260M)
532520 1024 2 freebsd-boot (512K)
533544 16243632 3 freebsd-ufs (7.7G)
=> 63 8388545 da1 MBR (4.0G)
63 1985 - free - (993K)
2048 8384512 1 ntfs (4.0G)
8386560 2048 - free - (1.0M)
This is the sysctl command to run before resizing the partition
sysctl kern.geom.debugflags=16
This is the partition resize command. See below for how I calculated the size of the new partition as 83352496
gpart resize -i 3 -s 83352496 -a 4k da0
This is the command to resize the file system
growfs /dev/gpt/rootfs
This is the calculation I did to get the size of the new partition from the output of gpart show
16243632 + 67108864 = 83352496
Copy and paste from the serial console in Azure
root@:/ # gpart show
=> 40 16777136 da0 GPT (40G) [CORRUPT]
40 532480 1 efi (260M)
532520 1024 2 freebsd-boot (512K)
533544 16243632 3 freebsd-ufs (7.7G)
=> 63 8388545 da1 MBR (4.0G)
63 1985 - free - (993K)
2048 8384512 1 ntfs (4.0G)
8386560 2048 - free - (1.0M)
root@:/ # gpart recover da0
da0 recovered
root@:/ # gpart show
=> 40 83886000 da0 GPT (40G)
40 532480 1 efi (260M)
532520 1024 2 freebsd-boot (512K)
533544 16243632 3 freebsd-ufs (7.7G)
16777176 67108864 - free - (32G)
=> 63 8388545 da1 MBR (4.0G)
63 1985 - free - (993K)
2048 8384512 1 ntfs (4.0G)
8386560 2048 - free - (1.0M)
root@:/ # sysctl kern.geom.debugflags=16
kern.geom.debugflags: 0 -> 16
root@:/ # gpart resize -i 3 -s 40G -a 4k da0
gpart: size '83886080': Invalid argument
root@:/ # gpart resize -i 3 -s 83352496 -a 4k da0
da0p3 resized
root@:/ # gpart show
=> 40 83886000 da0 GPT (40G)
40 532480 1 efi (260M)
532520 1024 2 freebsd-boot (512K)
533544 83352496 3 freebsd-ufs (40G)
=> 63 8388545 da1 MBR (4.0G)
63 1985 - free - (993K)
2048 8384512 1 ntfs (4.0G)
8386560 2048 - free - (1.0M)
root@:/ # gpart show
=> 40 83886000 da0 GPT (40G)
40 532480 1 efi (260M)
532520 1024 2 freebsd-boot (512K)
533544 83352496 3 freebsd-ufs (40G)
=> 63 8388545 da1 MBR (4.0G)
63 1985 - free - (993K)
2048 8384512 1 ntfs (4.0G)
8386560 2048 - free - (1.0M)
root@:/ # growfs /dev/da0p3
It's strongly recommended to make a backup before growing the file system.
OK to grow filesystem on /dev/da0p3 from 7.7GB to 40GB? [yes/no] yes
growfs: /dev/da0p3: Operation not permitted
root@:/ # growfs /dev/da0p3
It's strongly recommended to make a backup before growing the file system.
OK to grow filesystem on /dev/da0p3 from 7.7GB to 40GB? [yes/no] yes
growfs: /dev/da0p3: Operation not permitted
root@:/ # growfs /dev/gpt/rootfs
It's strongly recommended to make a backup before growing the file system.
OK to grow filesystem on /dev/gpt/rootfs, mounted on /, from 7.7GB to 40GB? [yes/no] yes
super-block backups (for fsck_ffs -b #) at:
16646016, 17926464, 19206912, 20487360, 21767808, 23048256, 24328704, 25609152, 26889600, 28170048,
29450496, 30730944, 32011392, 33291840, 34572288, 35852736, 37133184, 38413632, 39694080, 40974528,
42254976, 43535424, 44815872, 46096320, 47376768, 48657216, 49937664, 51218112, 52498560, 53779008,
55059456, 56339904, 57620352, 58900800, 60181248, 61461696, 62742144, 64022592, 65303040, 66583488,
67863936, 69144384, 70424832, 71705280, 72985728, 74266176, 75546624, 76827072, 78107520, 79387968,
80668416, 81948864, 83229312
root@:/ #
0 Comments