Thursday, April 7, 2016

Resizing an UFS2 filesystem on FreeBSD

List all block devices:
# gpart show

If this doesn't show the correct size for the resized device, then reboot. During reboot ignore any warnings about invalid GPT headers
Error eg: gpart: table 'ada0' is corrupt: Operation not permitted

Fix the invalid GPT header (replace ada0 by your actual block device):
$ gpart recover ada0

Allow write access to GEOM providers:
$ sysctl -w kern.geom.debugflags=16

Resize the third partition (again, replace 3 and ada0): 
$ gpart resize -i 3 ada0
p/s: i value is depand on /dev/ada0p3 (value after p)

Resize the filesystem:
$ growfs ada0p3
Enter Yes (case-sensitive!) when asked

Disallow write access to GEOM providers (just as a security measure):
$ sysctl -w kern.geom.debugflags=0
This even works for a mounted root filesystem.

Friday, April 1, 2016

Add New Hard Disk Freebsd 10.2


Nowadays you should use gpart to partition the disk (fdisk/disklabel are being overtaken by gpart since it supports GPT), newfs to format UFS[2] partitions and zpool to create ZFS filesystems.

#gpart create -s gpt /dev/da1
#gpart add -t freebsd-ufs /dev/da1
#newfs -U /dev/da1p1
#mkdir /data
#mount -t ufs /dev/da1p1 /data 

Add in fstab
# nano /etc/fstab
/dev/da1p1 /data ufs rw 2 2

Ref: https://www.freebsd.org/doc/handbook/disks-adding.html
https://amitabhkant.com/2012/03/26/adding-new-disk-in-freebsd/