# Trying to delete partition on FreeBSD 8.2 results in operation not permitted



## antoniog120 (Sep 10, 2011)

I am using FreeBSD 8.2 and I would like to remove/add a new partition in an existing FreeBSD slice. So I am removing partition /dev/ar0s1d which is mounted on /backup3 and recreating a new larger partition however when I try to delete the partition using disk label I receive the following error. I unmounted the partition prior to deleting it and still receive the error. I don't have any security features on. Is this new to the 8.X serious as I have not had these issues in the past. Any help would be appreciated.




```
eagle# disklabel -e /dev/ar0s1
# /dev/ar0s1:
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:   526336        0    4.2BSD        0     0     0
  b:  8388608 59729920      swap
  c: 490094892        0    unused        0     0         # "raw" part, don't edit
  e:  1024000 27789312    4.2BSD        0     0     0
  f:  9216000 28813312    4.2BSD        0     0     0
  g:  8388608 38029312    4.2BSD        0     0     0
  h: 13312000 46417920    4.2BSD        0     0     0
~
~
~
/tmp/EdDk.qAeLYPPkX5: 10 lines, 495 characters.
disklabel: /dev/ar0s1: Operation not permitted
re-edit the label? [y]: n




eagle# df
Filesystem  1K-blocks     Used     Avail Capacity  Mounted on
/dev/ar0s1a    254702   186274     48052    79%    /
devfs               1        1         0   100%    /dev
/dev/ar0s1e    495726     5134    450934     1%    /tmp
/dev/ar0s1f   4459918  1779070   2324056    43%    /usr
/dev/ar0s1g   4058062  2553916   1179502    68%    /var
/dev/ar0s1h   6442798   485206   5442170     8%    /var/mail
devfs               1        1         0   100%    /var/named/dev
/dev/ad5s1d 473015558 11084000 424090314     3%    /home
/dev/ar0s1d  13199246        8  12143300     0%    /backup3
```


----------



## aragon (Sep 10, 2011)

AFAIK, GEOM won't let you modify a provider that has any mounted filesystems on it.  Unless you do this first:

`# sysctl -w kern.geom.debugflags=17`


----------



## antoniog120 (Sep 11, 2011)

Thanks for the reply aragon. After modifying the parameter via sysctl I am still receiving the same result. Any other settings that might need to altered?



```
# /dev/ar0s1:
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:   526336        0    4.2BSD        0     0     0
  b:  8388608 59729920      swap
  c: 490094892        0    unused        0     0         # "raw" part, don't edit
  e:  1024000 27789312    4.2BSD        0     0     0
  f:  9216000 28813312    4.2BSD        0     0     0
  g:  8388608 38029312    4.2BSD        0     0     0
  h: 13312000 46417920    4.2BSD        0     0     0
~

~
~
:q
disklabel: /dev/ar0s1: Operation not permitted
re-edit the label? [y]: n
eagle# sysctl kern.geom.debugflags
kern.geom.debugflags: 17
```


----------



## aragon (Sep 11, 2011)

Maybe the situation has changed.  Have you tried using gpart(8)?


----------



## antoniog120 (Sep 12, 2011)

Thanks for the suggestion Aragon. After reading the man page for a bit I was able to use gpart to delete the /dev/ar0s1d partition and recreate it as a larger one. Had not used this tool before but it seems to be more complete than the fdisk/disklabel tools. It's weird because when I reference the FreeBSD handbook on the freebsd.org website it never states gpart under the adding disk section. Thanks again.


```
eagle# df
Filesystem  1K-blocks     Used     Avail Capacity  Mounted on
/dev/ar0s1a    254702   186276     48050    79%    /
devfs               1        1         0   100%    /dev
/dev/ar0s1e    495726     5134    450934     1%    /tmp
/dev/ar0s1f   4459918  1843342   2259784    45%    /usr
/dev/ar0s1g   4058062  2552618   1180800    68%    /var
/dev/ar0s1h   6442798   480836   5446540     8%    /var/mail
devfs               1        1         0   100%    /var/named/dev
/dev/ad5s1d 473015558 11085846 424088468     3%    /home
/dev/ar0s1d  71085512        4  65398668     0%    /backup3
eagle# gpart show ar0s1
=>        0  490094892  ar0s1  BSD  (234G)
          0     526336      1  freebsd-ufs  (257M)
     526336   27262976         - free -  (13G)
   27789312    1024000      5  freebsd-ufs  (500M)
   28813312    9216000      6  freebsd-ufs  (4.4G)
   38029312    8388608      7  freebsd-ufs  (4.0G)
   46417920   13312000      8  freebsd-ufs  (6.3G)
   59729920    8388608      2  freebsd-swap  (4.0G)
   68118528  146800640      4  freebsd-ufs  (70G)
  214919168  275175724         - free -  (131G)
```


----------



## DutchDaemon (Sep 12, 2011)

antoniog120, start formatting your posts, thanks.


----------



## aragon (Sep 12, 2011)

antoniog120 said:
			
		

> Had not used this tool before but it seems to be more complete than the fdisk/disklabel tools. It's weird because when I reference the FreeBSD handbook on the freebsd.org website it never states gpart under the adding disk section.



FWIW, things are changing.  Gpart is relatively new, and disklabel is becoming old and crusty it seems.  Documentation will be updated in time.


----------

