# resize a partition



## Steph1234 (Oct 3, 2013)

Hi,

First, sorry for my bad English (I'm French, so...  ). I have installed FreeBSD 10.0-CURRENT (ARM) on a Raspberry Pi. I used an SD card of 8 GB. I started with this:

```
% df -h
Filesystem        Size    Used   Avail Capacity  Mounted on
/dev/mmcsd0s2a    3.0G    1.2G    1.6G    42%    /
devfs             1.0k    1.0k      0B   100%    /dev
tmpfs             885M    4.0k    885M     0%    /tmp
```

After installing PHP-5.5 and PHP-5.5 extensions:

```
% df -h
Filesystem        Size    Used   Avail Capacity  Mounted on
/dev/mmcsd0s2a    3.0G    1.9G    958M    66%    /
devfs             1.0k    1.0k      0B   100%    /dev
tmpfs             610M    4.0k    610M     0%    /tmp
```

(installing PHP extensions not terminated...)

The image base was probably for a 4 GB SD card. Mine is 8 GB. I would like to resize /dev/mmcsd0s2a. How can I proceed?

Thanks for your help.


----------



## wblock@ (Oct 3, 2013)

Please show `gpart show` output.  The best way would be to back up, delete the partitions, then recreate them at the desired size.  That may require a live USB.

Otherwise, there is growfs(8).


----------



## Erratus (Oct 3, 2013)

You can try just `gpart resize â€“i index geom` which expands the last partition to the maximum available. And then `growfs /dev/yourdevice`.

BTW I've applied this on the FreeBSD installation memdisks successfully, after adjusting /etc/fstab accordingly.

```
# [cmd]cat /etc/fstab[/cmd]
/dev/da0a  / ufs rw,noatime 1 1
```
So you get write access and can configure it to use the services you need (i.e. SSH, NFS, ...).


----------



## Steph1234 (Oct 3, 2013)

```
[CMD=%]gpart show[/CMD]
=>       1  15394815  mmcsd0  MBR  (7.3G)
         1        32          - free -  (16k)
        33     65505       1  !12  [active]  (32M)
     65538   7551621       2  freebsd  (3.6G)
   7617159   7777657          - free -  (3.7G)

=>      0  7551621  mmcsd0s2  BSD  (3.6G)
        0  6553600         1  freebsd-ufs  (3.1G)
  6553600   998021         2  freebsd-swap  (487M)
```


----------



## Erratus (Oct 4, 2013)

You have 7777657 blocks free. Last partition in mmcsd0s2 is swap. Fortunately this one you can delete without loosing any data. Then you can resize the remaining partition to 6553600+7777657=14331257 blocks. Add swap partition again, using the remaining blocks (no â€“s option). 


```
gpart delete -i 2 /dev/mmcsd0  
gpart resize -i 1 -s 14331257 /dev/mmcsd0
gpart add -t freebsd-swap 
growfs /dev/mmcsd0s2
```


----------



## Steph1234 (Oct 4, 2013)

Thank you very much. (I didn't hope directly the code, cool  )


```
# gpart delete -i 2 /dev/mmcsd0
gpart: Device busy
```

I think something's missing.


----------



## wblock@ (Oct 4, 2013)

If the partition is in use, it can't be deleted.  So use `swapoff`.


----------

