gpart: Unknown command: resize

301 Views Asked by At

I'm trying to resize a UFS file system on an old FreeBSD server (FreeBSD 7.1). I'm using gpart to do this,following this documentation: https://www.freebsd.org/doc/handbook/disks-growing.html

I may be running an old/deprecated version of it or something, but my gpart does not even display the "resize" command as an option. It always shows up as "Unknown":

gpart: Uknown command: resize

Pretty confused as I've scoured the net (first two pages of lots of Googling) to no avail.

Alternatively, is there a way to resize the disk using the commands listed? Any help would be super appreciated! Thank you.

1

There are 1 best solutions below

0
On

Without looking things up, I would say that the resize command wasn't included in gpart in FreeBSD until after your version. Sadly you also lack the gpart backup and restore commands which will backup and restore your guid partition layout without affecting your filesystems. At this point I would say that you can grow the partition but if you aren't careful you will lose data. Finally, these steps assume familiarity with the gpart command on FreeBSD. Warren Block's document is my goto resource for gpart. Having said that, with no resize command, you'll have to resize the partition manually by taking the following steps:

  • Backup the data that's currently on the partition using your favorite backup tool
  • Ensure that the backup will restore correctly, you can't be too sure
  • Unmount the partition with umount
  • Delete the current partition with gpart delete -i ...
  • Create a new partition at the appropriate index with gpart create -i using the appropriate start, size, and or end points

If you are growing the partition by appending empty space onto it, take the following steps:

  • fsck the newly created partition.
  • use df on the device to check the filesystem at the newly created partition.

If both of these checks pass: fsck reports no problems and df reports the correct, the old, amount of space, then:

  • Use growfs to grow the filesystem into the newly created space man growfs for more information.
  • Remount the partition using mount

After the mount works, check your data if everything looks good, you are done. Keep the backup around just in case.

If you are shrinking the partition; If you are moving the data from one place to another; or if the grow in place procedure failed as tested by fsck, df, and mount:

  • Create a new filesystem in the new partition with newfs
  • Mount the new filesystem using mount
  • Restore your backup

Honestly, you haven't said much about your situation. For example, is this a virtual machine or a physical server? If it's virtual you can shutdown the machine and snapshot the disks. If things go badly, you can restore your previous state from the snapshot. If it's physical, could you plug in a USB drive to store the partition's data temporarily while you grow the partition.

This is the way that I've done it on virtual machines on ESXi and it works great but I'd really be concerned if I didn't have a good backup and a snapshot to fall back on.