# Hetzner recovery with mfsbs?



## dds (Mar 16, 2012)

Hi,

I have FreeBSD on hetzner.de servers. I made a mistake with some SSL setup which doesn't permit me a normal boot, and I want to use hetzner.de rescue system. I've booted the server in rescue mode, which uses the mfsBSD system (memory file system). After this point the hetzner wiki is not very informative, I don't know how to mount my hard disk partitions and repair files..

http://wiki.hetzner.de/index.php/FreeBSD_Rescue-System/en

When I use the *mount* command *I*'ve got following:


```
[root@rescue ~]# mount
/dev/md0 on / (ufs, local)
devfs on /dev (devfs, local, multilabel)
/dev/md1 on /tmp (ufs, local, soft-updates)
/dev/md2.uzip on /usr (ufs, local, read-only)
/dev/md3 on /tmp/.usr_overlay (ufs, local)
<above>:/tmp/.usr_overlay on /usr (unionfs, local)
/dev/md4 on /var (ufs, local)
/dev/md5 on /usr/local (ufs, local, soft-updates)
nfs.hetzner.de:/nfs/freebsd on /nfs (nfs)
nfs.hetzner.de:/nfs/freebsd on /nfs (nfs)
[root@rescue ~]#
```


```
[root@rescue ~]# gpart show
=>       34  586072300  ad4  GPT  (279G) [CORRUPT]
         34       2014       - free -  (1.0M)
       2048        128    1  freebsd-boot  (64K)
       2176    8388608    2  freebsd-swap  (4.0G)
    8390784  577681550    3  freebsd-ufs  (275G)

=>       34  586072300  ad6  GPT  (279G) [CORRUPT]
         34       2014       - free -  (1.0M)
       2048        128    1  freebsd-boot  (64K)
       2176    8388608    2  freebsd-swap  (4.0G)
    8390784  577681550    3  freebsd-ufs  (275G)
```

Please, does anybody have an idea what to do next?

Thanks!


----------



## DutchDaemon (Mar 16, 2012)

Can you tell us what the SSL mistake is? Did you put an SSL certificate in Apache with a password on it? That means the boot process is waiting for someone to enter a password before starting httpd and booting further. The certificate should be converted to one without a password on remote installations. (Just a guess based on you mentioning SSL). I'm guessing the NFS mounts rooted in /nfs contain your installation. Maybe you can start exploring from there.


----------



## SirDice (Mar 16, 2012)

It looks like a mirrored system. Have a look in /dev/mirror/. You may need to kldload(8) geom_mirror.


----------



## kpa (Mar 16, 2012)

It says "CORRUPT" for both of the GPT partition tables, that suggests that gmirror(8) is used incorrectly with GPT partitioning and the mirror covers the whole disk. To fix that you would have to clear the mirror metadata on the disks (see the manual page) and convert to mirroring the individual partitions ad4p3 and ad6p3. Make full backups that you know you can restore before proceeding with any of this.


----------



## dds (Mar 16, 2012)

kpa said:
			
		

> It says "CORRUPT" for both of the GPT partition tables, that suggests that gmirror(8) is used incorrectly with GPT partitioning and the mirror covers the whole disk. To fix that you would have to clear the mirror metadata on the disks (see the manual page) and convert to mirroring the individual partitions ad4p3 and ad6p3. Make full backups that you know you can restore before proceeding with any of this.




I did clearing mirror metadata with gmirror clear /dev/ad6 and gmirror clear /dev/ad4, can you explain how to convert to mirroring individual partitions ad43p3 and ad6p3?
I'm pretty new to this 

Thanks !


----------



## dds (Mar 16, 2012)

DutchDaemon said:
			
		

> Can you tell us what the SSL mistake is? Did you put an SSL certificate in Apache with a password on it? That means the boot process is waiting for someone to enter a password before starting httpd and booting further. The certificate should be converted to one without a password on remote installations. (Just a guess based on you mentioning SSL). I'm guessing the NFS mounts rooted in /nfs contain your installation. Maybe you can start exploring from there.



Yes, you are correct, I put an SSL certificate in Apache with password 
On my /nfs there is only images of different FreeBSD releases 


```
[root@rescue /nfs]# ls
.svn    64      7.3_64  8.0_64  8.1_64  8_64
32      7.3_32  8.0_32  8.1_32  8_32    mfsbsd
[root@rescue /nfs]#
```


----------



## dds (Mar 16, 2012)

SirDice said:
			
		

> It looks like a mirrored system. Have a look in /dev/mirror/. You may need to kldload(8) geom_mirror.




```
[root@rescue /nfs]# kldload geom_mirror
[root@rescue /nfs]# cd /dev/mirror
-bash: cd: /dev/mirror: No such file or directory
[root@rescue /nfs]#
```


----------



## kpa (Mar 16, 2012)

Label the partitions for the new mirror with this:

`# gmirror label myroot ad4p3 ad6p3`

Then edit the /etc/fstab of the system to this for the / filesystem:

```
/dev/mirror/myroot / ufs rw 1 1
```

Make sure there's a line like this in /boot/loader.conf:


```
geom_mirror_load="YES"
```

After this you can repair the GPT backup headers(those are on the last LBAs of the disks and gmirror(8) overwrote those in the full disk mirror setup) with these:

`# gpart recover ad4`
`# gpart recover ad6`


----------



## dds (Mar 16, 2012)

kpa said:
			
		

> Label the partitions for the new mirror with this:
> 
> `# gmirror label myroot ad4p3 ad6p3`
> 
> ...




It looks like we are on right track 



```
[root@rescue ~]# gpart show
=>       34  586072301  ad4  GPT  (279G)
         34       2014       - free -  (1.0M)
       2048        128    1  freebsd-boot  (64K)
       2176    8388608    2  freebsd-swap  (4.0G)
    8390784  577681550    3  freebsd-ufs  (275G)
  586072334          1       - free -  (512B)

=>       34  586072301  ad6  GPT  (279G)
         34       2014       - free -  (1.0M)
       2048        128    1  freebsd-boot  (64K)
       2176    8388608    2  freebsd-swap  (4.0G)
    8390784  577681550    3  freebsd-ufs  (275G)
  586072334          1       - free -  (512B)

[root@rescue ~]#
```


I've tried to mount ad4 and ad6 on /mnt, but without luck, what to do next?
Thanks for your patience


----------



## kpa (Mar 16, 2012)

Did you create the mirror? If you created it you can mount the mirror device under /mnt

`# mount /dev/mirror/myroot /mnt`

Just make sure you have geom_mirror module loaded

`# kldload geom_mirror`

This should show the status of the mirror:
`# gmirror status`


----------



## dds (Mar 16, 2012)

Yes, now I have access   Thank you, and other participants, this forum is great thing to learn FreeBSD  Thanks!!!


----------



## kpa (Mar 16, 2012)

No problem, I hope everything works allright.

I now realise that there's a potential problem with this "on the fly" labeling of the mirror, it's actually the same problem as there is with the FreeBSD handbook example of creating a full disk mirror out of a existing non-mirrored MBR setup. The problem is that the last blocks of the providers ad4p3 and ad6p3 are forcefully overwritten by the labeling process (resulting in one block smaller mirror device than the used providers). To do this in a completely safe way you would first make a full dump(8) of the filesystem on the non mirrored filesystem ad4p3, create the mirror as above, newfs(8) the new mirror device /dev/mirror/myroot and lastly restore(8) the dump to /dev/mirror/myroot and then do the edits on /etc/fstab and /boot/loader.conf.


----------

