Resizing an UFS2 filesystem on FreeBSD 4.x is not as straightforward as on recent versions of FreeBSD since gpart appeared in 7.0, and GPT was not common yet. You have to use fdisk and disklabel instead.
This howto assumes that your system is installed on the first IDE drive (ad0) which is 20 GB in size. There is just one BSD slice (aka an MBR partition in DOS/Windows speak) that covers the whole disk (ad0s1). This slice contains 3 FreeBSD partitions (ad0s1a, ad0s1b, ad0s1d) plus one pseudo partition that covers the whole slice (ad0s1c). The former ones serve as root filesystem, swap device, and /var filesystem, respectively. You want to grow /var by 10 GB. You will need root privileges and access to the local console. The system will be rebooted three times.
# fdisk ad0 ******* Working on device /dev/ad0 ******* parameters extracted from in-core disklabel are: cylinders=41610 heads=16 sectors/track=63 (1008 blks/cyl) Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are: cylinders=41610 heads=16 sectors/track=63 (1008 blks/cyl) Media sector size is 512 Warning: BIOS sector numbering starts with sector 1 Information from DOS bootblock is: The data for partition 1 is: sysid 165,(FreeBSD/NetBSD/386BSD) start 63, size 41942817 (20479 Meg), flag 80 (active) beg: cyl 0/ head 1/ sector 1; end: cyl 1023/ head 15/ sector 63 The data for partition 2 is: <UNUSED> The data for partition 3 is: <UNUSED> The data for partition 4 is: <UNUSED>
# disklabel -r ad0 # /dev/ad0c: type: ESDI disk: ad0s1 label: flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 16 sectors/cylinder: 1008 cylinders: 41609 sectors/unit: 41942817 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # milliseconds track-to-track seek: 0 # milliseconds drivedata: 0 8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 8388608 0 4.2BSD 2048 16384 89 # (Cyl. 0 - 8322*) b: 4194304 8388608 swap # (Cyl. 8322*- 12483*) c: 41942817 0 unused 0 0 # (Cyl. 0 - 41609*) e: 29359905 12582912 4.2BSD 2048 16384 89 # (Cyl. 12483*- 41609*)
# dmesg | grep ad0 ad0: 30720MB <QEMU HARDDISK> [62415/16/63] at ata0-master BIOSPIO Mounting root from ufs:/dev/ad0s1a
# fdisk -u ad0 ******* Working on device /dev/ad0 ******* parameters extracted from in-core disklabel are: cylinders=62415 heads=16 sectors/track=63 (1008 blks/cyl) Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are: cylinders=62415 heads=16 sectors/track=63 (1008 blks/cyl) Do you want to change our idea of what BIOS thinks ? [n] Media sector size is 512 Warning: BIOS sector numbering starts with sector 1 Information from DOS bootblock is: The data for partition 1 is: sysid 165,(FreeBSD/NetBSD/386BSD) start 63, size 41942817 (20479 Meg), flag 80 (active) beg: cyl 0/ head 1/ sector 1; end: cyl 1023/ head 15/ sector 63 Do you want to change it? [n] y Supply a decimal value for "sysid (165=FreeBSD)" [165] Supply a decimal value for "start" [63] Supply a decimal value for "size" [41942817] 62914320 Explicitly specify beg/end address ? [n] sysid 165,(FreeBSD/NetBSD/386BSD) start 63, size 62914320 (30719 Meg), flag 80 (active) beg: cyl 0/ head 1/ sector 1; end: cyl 975/ head 0/ sector 63 Are we happy with this entry? [n] y The data for partition 2 is: <UNUSED> Do you want to change it? [n] The data for partition 3 is: <UNUSED> Do you want to change it? [n] The data for partition 4 is: <UNUSED> Do you want to change it? [n] Partition 1 is marked active Do you want to change the active partition? [n] We haven't changed the partition table yet. This is your last chance. parameters extracted from in-core disklabel are: cylinders=62415 heads=16 sectors/track=63 (1008 blks/cyl) Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are: cylinders=62415 heads=16 sectors/track=63 (1008 blks/cyl) Information from DOS bootblock is: 1: sysid 165,(FreeBSD/NetBSD/386BSD) start 63, size 62914320 (30719 Meg), flag 80 (active) beg: cyl 0/ head 1/ sector 1; end: cyl 975/ head 0/ sector 63 2: <UNUSED> 3: <UNUSED> 4: <UNUSED> Should we write new partition table? [n] y
# disklabel -e -r ad0
# /dev/ad0c: type: ESDI disk: ad0s1 label: flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 16 sectors/cylinder: 1008 cylinders: 62415 sectors/unit: 62914320 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # milliseconds track-to-track seek: 0 # milliseconds drivedata: 0 8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 8388608 0 4.2BSD 2048 16384 89 # (Cyl. 0 - 8322*) b: 4194304 8388608 swap # (Cyl. 8322*- 12483*) c: 41942817 0 unused 0 0 # (Cyl. 0 - 41609*) e: 29359905 12582912 4.2BSD 2048 16384 89 # (Cyl. 12483*- 41609*)
# size offset fstype [fsize bsize bps/cpg] a: 8388608 0 4.2BSD 2048 16384 89 # (Cyl. 0 - 8322*) b: 4194304 8388608 swap # (Cyl. 8322*- 12483*) c: 62914320 0 unused 0 0 # (Cyl. 0 - 41609*) e: 50331408 12582912 4.2BSD 2048 16384 89 # (Cyl. 12483*- 41609*)
# fsck -f /dev/ad0s1e
# growfs /dev/ad0s1eEnter Yes (case sensitive!) when asked if you did backup your data
# fsck -f /dev/ad0s1e
# exit
# df -h Filesystem Size Used Avail Capacity Mounted on /dev/ad0s1a 3.9G 271M 3.4G 7% / /dev/ad0s1e 24G 354K 22G 0% /var procfs 4.0K 4.0K 0B 100% /proc