# FreeBSD move partition



## Ikinoki (Sep 7, 2014)

Hello everyone.

I have more of a generic question. I'm trying to move a partition which somehow went after the swap partition in my slice.
So it looked like:


```
=>        0  286487082  aacd0s1  BSD  (137G)
          0    2097152        1  freebsd-swap (1.0G)
    2097152   41943040        4  freebsd-ufs  (20G)
   44040192   62914560        5  freebsd-ufs  (30G)
  106954752   20971520        6  freebsd-ufs  (10G)
  127926272  158560810        7  freebsd-ufs  (76G)
```
But then I deleted all except the 7th which I want to enlarge, how do I do it?


```
=>        0  286487082  aacd0s1  BSD  (137G)
          0  127926272           - free -  (61G)
  127926272  158560810        7  freebsd-ufs  (76G)
```

In Linux I could've used gparted or parted to move the partition, how do I do it in FreeBSD 8.4, 9.2, 10.0?

What I want is:

```
=>        0  286487082  aacd0s1  BSD  (137G)
          0  286487082        1  freebsd-ufs  (137G)
```


----------



## wblock@ (Sep 7, 2014)

FreeBSD does not have a built-in way to do this.  It's also important to note that resizing a partition will not resize the filesystem on it.  I'm not aware of tools that will successfully resize and relocate UFS filesystems.  There is growfs(8), but it will only expand a UFS filesystem, and only after the partition it is on has been enlarged and the free space is at the end.

The standard way to do this is to back up the filesystem, delete the partition, recreate it as desired, then restore from the backup.  See Backup Options For FreeBSD.


----------

