Disk expansion in FreeBSD

Custom Server

Custom server

Create your own custom dedicated server

See configurator

Important! Before making changes, be sure to make a backup (backup) of all server data. Any manipulations with partitions carry the risk of data loss.

  1. It is necessary to disable the GEOM security settings to work with partitions on the mounted device: # sysctl kern.geom.debugflags=16

Drive expansion

  1. There are a few more steps to follow to expand an existing partition.

2.1. We select a team:

# df -h

It will show which devices and their slices (a slice is a hard disk partition inside freeBSD) are connected and where. In our case, there is one slice - vtbd0p2

2.2. Let's look at the partition table of the entire vtbd0 disk:

# gpart show vtbd0

2.3. Attention! After changing the disk size (inside the hypervisor, for example), the GPT table will have the CORRUPT status.

Let's fix this:

# gpart recover vtbd0

2.4. Now we type the command:

# gpart show vtbd0

It will show us the correct slice table on disk, without the CORRUPT warning.

In our example, there is a swap. It needs to be disabled and removed as it is the last one on the disk. And to expand our slice to the end of the disk, the slice itself must be the last one.

Drive expansion

2.5. Team

# swapinfo

will show the swap slice.

2.6. Team:

# swapoff /dev/vtbd0p3

will disable swap.

2.7. Then delete the swap slice:

# gpart delete -i 3 vtbd0

2.8. Make sure the slice is removed:

# gpart show vtbd0

2.9. Let's change the size of our slice from 5GB to 10GB (maximum):

# gpart resize -i 2 -a 4k vtbd0

2.10. Let's check:

# gpart show vtbd0

3.

Drive expansion

After the slice is expanded to the maximum (in our example from 5GB to 10GB), you need to stretch the filesystem to the entire slice:

# growfs -y /dev/vtbd0p2

Now we type the command:

# df -h

It will show our slice is already the correct, expanded, size.

Ready.

Tags:

#server

Did you like the article?

Cookie consent

By clicking «I agree», you consent to our website's use of cookies to give you the most relevant experience by remembering your preferences and repeat visits. However, you may visit «Manage сookies» to provide controlled consent. Learn more

Cookies settings

functional

Necessary cookies are crucial for the basic functions of the website and the website will not work in its intended way without them.

Analytics

Analytical cookies are used to understand how visitors interact with the website.

Advertisement

Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns.