Is there a way to resize a /root partition while running OS which resides on it? I am running FreeBSD. Thanks in advance!
Resizing /root partition
partition;freebsd
There's a fairly comprehensive guide to growing a disk under FreeBSD in the handbook. For UFS (the default for FreeBSD), you can grow online from kernel version 10.0 onward.However, changing the partitions around mounted filesystems might lead to data loss or inconsistencies which might be first discovered when the system tries to boot the next time. Also remember to check up on your bootloader.Growing a filesytem basically boils down to this:Adjust your partition table. Be very careful with this step, as messing up here can lead to corrupting your entire disk. You'd probably want to unmount all partitions that are not actively needed to run a minimal system, most notably the swap partition.From your question, I assume you know how to use gpart to accomplish this.After having made the adjustments, you can safely remount all partitions and re-enable swap.Actually grow the FS. For FreeBSD, this is as easy as issuing growfs <blockdevice> with <blockdevice> being the partition that you resized.For shrinking, you have to do these steps in reverse:Shrink the filesystem to make sure you won't overwrite anything important: growfs -s <new_size> <blockdevice>. Make sure that you choose a size less than your new target filesystem size, i.e. if you want to go down from a 100GB partition to a 70GB one, resize the FS to about 60-65GB at this step. Overshooting more means more headroom, but usually also means more relocations and thus longer wait time.Adjust the partition table. Unlike before, at this step you choose your exact target size. You'd probably want to unmount additional partitions at this step too, especially if you move other partitions around (in fact, in this case you have to unmount these).Grow the filesystem. This gets rid of the headroom you left at the end of the (new) partition: growfs <blockdevice>. Omitting the size parameter tells it to use the entire partition.