Before proceed, boot into option 4 (single user mode) for all steps below.
1. ) Add another disk to NAS machine or virtual disk if running on VM.
2. ) Backup the current partitions for reference, type:
# gpart backup da0
<da0> is the geom label, your case may difference.
3. ) Backup all partition to new added disk.
# dd if=/dev/da0s1 of=<new disk path>/da0s1
# dd if=/dev/da0s2 of=<new disk path>/da0s2
# dd if=/dev/da0s3 of=<new disk path>/da0s3
# dd if=/dev/da0s4 of=<new disk path>/da0s4
4. ) Delete and re-create the partition so that we have the free space for 1st partition.
# gpart show da0
=> 63 18874305 da0 MBR (9.0G)
63 1930257 1 freebsd [active] (942M)
1930320 1930257 2 freebsd (942M)
3860577 3024 3 freebsd (1.5M)
3863601 41328 4 freebsd (20M)
3904929 14969376 - free - (7.1G)
# gpart delete -i 4 da0
you need calculate the start index of your last partition, your last partition index should be 18874305 - 128 - 41328.
# gpart add -t freebsd -b 18832849 -s 41328 da0
5. ) Repeat step 4. for partition 3 and 2. You should get something like below
# gpart show da0
=> 63 18874305 da0 MBR (9.0G)
63 1930320 1 freebsd [active] (942M)
1930383 14969241 - free - (7.1G)
16899624 1930257 2 freebsd (942M)
18829881 3024 3 freebsd (1.5M)
18832905 41328 4 freebsd (20M)
6. ) Restore the partition 2,3 and 4.
# dd of=/dev/da0s2 if=<new disk path>/da0s2
# dd of=/dev/da0s3 if=<new disk path>/da0s3
# dd of=/dev/da0s4 if=<new disk path>/da0s4
# dd of=/dev/da0s3 if=<new disk path>/da0s3
# dd of=/dev/da0s4 if=<new disk path>/da0s4
# gpart resize -i 1 da0
8. ) Correct the label
# bsdlabel /dev/da0s1
# /dev/da0s1:
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 1930241 16 unused 0 0
c: 1930257 0 unused 0 0 # "raw" part, don't edit
Edit the label to correct size.
# gpart show da0
=> 63 18874305 da0 MBR (9.0G)
63 16899561 1 freebsd [active] (8.1G)
16899624 1930257 2 freebsd (942M)
18829881 3024 3 freebsd (1.5M)
18832905 41328 4 freebsd (20M)
18874233 135 - free - (67k)
Mine da0s1 size is 16899561, I edit my label as below:
# /dev/da0s1:
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 16899545 16 unused 0 0
c: 16899561 0 unused 0 0 # "raw" part, don't edit
9. ) Now grow the file system
# growfs /dev/da0s1a
10. ) Reboot the machine and you will find that the root / not able to mount
type ufs:/dev/da0s1a to mount root.
11. ) Correct the mount path for root /
# mount -uw /
# vi /conf//base/etc/fstab
change /dev/ufs/FreeNASs1a / ufs ro 1 1
to /dev/da0s1a / ufs ro 1 1
12.) Reboot and done.