# Installation problems



## stream (Jun 21, 2021)

Hi,

I am trying to install Freebsd on already installed SSD. Now the installation is somewhat ok, I can boot and login as user from ada0.

Now the serve has additional storage, which I am trying to use for general data/storage. I want to create a zfs pool.

Unfortunately, I can't do it.

I tried creating partition with gpart, but is says operation not permitted.

---
>> gpart create -s gpt ada1
returns
gpart : geom "ada1" : operation not permitted

--

>> dmesg | grep ada
returns
GEOM:: ada1 : the primary GPT table is corrupt
using the secondary table.. recovery strongly advised


So my question is how to partition the drives, and make it show in gpart show.

Thank you for your time.


----------



## Emrion (Jun 21, 2021)

So you want to destroy all files/partitions/scheme on ada1?

If yes, you must run before: `gpart destroy -F ada1`. Then, you can create a partition scheme: `gpart create -s GPT ada1`. After that, you can create partitions with `gpart add -t type -s size ada1`, where _type _and _size_ depend on what you exactly want to do.

If you want a zfs partition that takes all the disk, just type: `gpart add -t freebsd-zfs ada1`.

See gpart(8).


----------



## stream (Jun 21, 2021)

Forgot to mention.. I tried that already..
gpart destroy -F ..

It returned gpart: arg0 'ada1'; Invalid argument


----------



## Emrion (Jun 21, 2021)

It's better to not forgot this kind of details...

Have you tried with /dev/ada1 as argument?
You can also try to repair the GPT scheme with `gpart recover ada1` before to destroy it.


----------



## stream (Jun 21, 2021)

Agreed.

Yes, I have tried /dev/ada1 as argument, and gpart recover ..

Same error message: invalid argument


----------



## stream (Jun 21, 2021)

Also, I tried
dd if=/dev/zero ...

it said the same thing operation not permitted.

I also rebooted the machine, and tried the above commands: dd zero, gpart destroy, etc..

Same errors were replicated.


----------



## SirDice (Jun 21, 2021)

Did you boot from that disk? If that's the case the first sector might be locked from accidental overwrites.

`sysctl kern.geom.debugflags=16`


----------



## astyle (Jun 21, 2021)

Let's assume that /dev/ada0 is your boot disk (which boots fine), and you're trying to add another disk as /dev/ada1. 

If you don't care what's on /dev/ada1, you might want to format it first, using another computer, and then try plugging it in again. Once FreeBSD can 'see' /dev/ada1, refer to the FreeBSD handbook section about adding disks. Do pay attention to what it says early on about reading /var/dmesg.boot, your newly added drive might be 'seen' as something else.


----------



## stream (Jun 22, 2021)

SirDice said:


> Did you boot from that disk? If that's the case the first sector might be locked from accidental overwrites.
> 
> `sysctl kern.geom.debugflags=16`


Sir-

No I did not boot from that disk. I booted from another one.

In fact when I first logged in and tried gpart show:
ada0 had efi, boot, swap, zfs, free

Furthermore, it also showed ada1:
efi, swap, free, and zfs partitions.

These were possibly previous partitions from earlier installation.

I tried to create a pool, and then everything is went south after that. Can't show or create gpart.


----------



## Alain De Vos (Jun 22, 2021)

It is always interesting to know what you want to do and how you want to do.


----------



## gpw928 (Jun 22, 2021)

Assuming that `gpart show` confirms that your active root is on ada0, you can clean all the crap from the start of ada1 as follows:
	
	



```
sudo dd if=/dev/zero of=/dev/ada1 bs=1g count=2
```
If /dev/ada1 has ever been used in a gmirror(8), then you need to clean the gmirror metadata as well:
	
	



```
# Determine the "mediasize in bytes" for /dev/ada1
sudo diskinfo -v /dev/ada1
# Calculate the number of GiB on the drive.
# This is "mediasize in bytes"/(1024*1024*1024)
# Call it NNN.  Subtract 5 => NN5.
# Nuke the end of the drive (gmirror metadata).
sudo dd if=/dev/zero of=/dev/ada1 bs=1g seek=NN5 count=999999
```


----------



## Emrion (Jun 22, 2021)

What is the output of `zpool status`?


----------



## stream (Jun 22, 2021)

Alain De Vos said:


> It is always interesting to know what you want to do and how you want to do.


Nice Alain. If we all knew both, there's no need for this forum, arguably ;-)


----------



## stream (Jun 22, 2021)

gpw928 said:


> Assuming that `gpart show` confirms that your active root is on ada0, you can clean all the crap from the start of ada1 as follows:
> 
> 
> 
> ...


gpw928 Yes, it was part of mirror.  How to clean the gmirror metadata?
And as I stated previously, I did trry dd if=/dev/zero of=/dev/ada1 bs=64000, without the seek and count. Am assuming that will cleanup the entire disk.
Anyway, it gave Invalid argument error.

I am trying gpart restore -F .. that seems to be working, and doing something.. ;-)


----------



## gpw928 (Jun 22, 2021)

stream said:


> gpw928 Yes, it was part of mirror.  How to clean the gmirror metadata?


The information you seek is in my original post...


----------



## stream (Jun 23, 2021)

gpw928 thanks.

The gpart restore command is taking awfully long time-- Is it normal for a 1T disk? if not is it ok to kill the process?


----------



## Alain De Vos (Jun 23, 2021)

gpart restore should take less than 1 second. It is written just a partition table which is very little data.
Try to kill it with first "kill" , second "kill -9".


----------



## gpw928 (Jun 23, 2021)

The process I described above wipes the disk metadata completely.

There will be no partition table. Nor will there be a backup partition table, so trying to restore it is bound to fail.

The disk is ready to be initialised.  Please see the handbook for how to proceed.


----------



## stream (Jun 23, 2021)

Ok. I stopped gpart recover. 
And tried dd commands above. 
Same error-- operation not permitted!!


----------



## SirDice (Jun 23, 2021)

Post the output from `zpool status`


----------



## Alain De Vos (Jun 23, 2021)

It can be interesting to know if there is still partition table data available.
What is the output of the following commands:

```
geom disk list | egrep "Name"
```


```
gpart backup ada1
```


```
fdisk -vsp ada1
```


```
gpart show -p
```


----------



## SirDice (Jun 23, 2021)

The output from `mount` would be useful too.


----------



## stream (Jun 23, 2021)

SirDice said:


> The output from `mount` would be useful too.


----------



## SirDice (Jun 23, 2021)

Please don't post pictures of text. Just copy and paste it. The information that's shown doesn't add up with what you mentioned before:


stream said:


> I am trying to install Freebsd on already installed SSD. Now the installation is somewhat ok, I can boot and login as user from ada0.



Your system isn't installed on ada0. You have a mfi(4) based RAID card with 4 disks (mfisyspd0 to mfisyspd3), that's split up and used as two mirrored ZFS pools.


----------



## Alain De Vos (Jun 23, 2021)

& verify the contents of the /boot and /boot/efi directories.


----------



## stream (Jun 23, 2021)

SirDice said:


> Please don't post pictures of text. Just copy and paste it. The information that's shown doesn't add up with what you mentioned before:
> 
> 
> Your system isn't installed on ada0. You have a mfi(4) based RAID card with 4 disks (mfisyspd0 to mfisyspd3), that's split up and used as two mirrored ZFS pools.


Sir-
Unfortunately, I cannot copy paste. that is why I had to type up this outputs in my earlier posts.
yes- previously I typed up the info manually and used equivalent terms for simplicity. Please substitute ada0-3 to the mfisyspd0-3.
Also the boot pool is ok on disk0/2. Per dmesg and gpart horrors, the other pool is corrupt and/or invalid, and I want to clean it up and setup a different mirrored ZFS pool on disk1/3.
And none of the commands that I am aware of seem to be working.


----------



## Emrion (Jun 23, 2021)

How can people help you if you lie about the real problem?
I was thinking you have an active zpool on the disk - sorry the disks - you want to reuse...
Ever read zpool(8)?


----------



## stream (Jun 23, 2021)

Emrion said:


> How can people help you if you lie about the real problem?
> I was thinking you have an active zpool on the disk - sorry the disks - you want to reuse...
> Ever read zpool(8)?


Emrion-- I think you are mistating. sorry.

I have typed up the core problem- I reinstalled the OS. and I can boot+login. OS say is installed in one mirror and gpart etc commands work. But I have other non-boot disks which I am unable to use right now. As I have stated dmesg gives me error message that the primary partition is corrupt or invalid. And I can't seem to clean up these  other disk(s).
I just need to know how to force a restore or clean on this other disk(s), and use gpart etc the normal way.
The one thing I can think of is reinstall the OS again. I very much would l like to avoid that.


----------



## SirDice (Jun 23, 2021)

stream said:


> I typed up the info manually and used equivalent terms for simplicity.


You're not 'simplifying' things, you're causing a lot of confusion. ada(4) is a completely different kind of disk. Never do this please.



stream said:


> Please substitute ada0-3 to the mfisyspd0-3.


In that case, you can't access that disk directly because mfisyspd1 is part of the zdata pool.



Emrion said:


> How can people help you if you lie about the real problem?


"lie" or "lying"  implies malicious intent. I don't believe there's been malicious intent here.


----------



## Alain De Vos (Jun 23, 2021)

Well i don't waste time on speculation of hiding motives. Good luck to your setup.


----------



## stream (Jun 23, 2021)

SirDice said:


> You're not 'simplifying' things, you're causing a lot of confusion. ada(4) is a completely different kind of disk. Never do this please.
> 
> 
> In that case, you can't access that disk directly because mfisyspd1 is part of the zdata pool.
> ...


I apologize for the confusion.
Yes, the thing is these are prior mirrors/pool on the disks. and I tried to clean up.

I now tried zpool destroy -f zdata. and the output shown in the attachment


----------



## SirDice (Jun 23, 2021)

You need to 'export' the pool first. That will cause everything to be unmounted and the pool to be removed from the system. Then you can 'destroy' the pool. Once the pool is destroyed you can access those disks individually (partition, dd(1), whatever you want to do with them).

The reason the partition table appears to be corrupt is because you've used those disks as a whole (not a partition on those disks) in the pool. This will overwrite parts of the original partition table that used to be on there. Because some parts of that old partition table survived you get the error messages. Just clear the disk or `gpart destroy` the old partition tables.


----------



## stream (Jun 23, 2021)

SirDice said:


> You need to 'export' the pool first. That will cause everything to be unmounted and the pool to be removed from the system. Then you can 'destroy' the pool. Once the pool is destroyed you can access those disks individually (partition, dd(1), whatever you want to do with them).
> 
> The reason the partition table appears to be corrupt is because you've used those disks as a whole (not a partition on those disks) in the pool. This will overwrite parts of the original partition table that used to be on there. Because some parts of that old partition table survived you get the error messages. Just clear the disk or `gpart destroy` the old partition tables.


SIr- 
Yes, all commands working now.. Yay 
TyTy..

Yes, I read somewhere that it is better to use the entire disk rather than partitions. The ZFS administration documentation too has examples of creating mirror with the entire disk, I think.
Anyway, learned a few things today.

Thank you all.


----------



## SirDice (Jun 23, 2021)

stream said:


> Yes, I read somewhere that it is better to use the entire disk rather than partitions.


It actually doesn't matter these days. There's nothing to gain or lose performance wise. Using partitions makes the disk and its contents more easier to identify for us humans. And the few KB a partition table uses is hardly going to matter on a multi-TB of disk space. You do need to make sure the partitions neatly line up with the actual sector sizes of the disks, or else it will have a negative impact on performance.


----------

