On 9/6/21 9:22 AM, Thomas Windisch wrote:
I think I just overwrote my file system by using sd1 instead of sd2:

        # pv install69.img > /dev/rsd1c

sd1 is softraid crypto device that holds the system partitions and data:

$ df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/sd1a      1.9G    143M    1.7G     8%    /
/dev/sd1f      843G    734G   66.2G    92%    /home
/dev/sd1b      9.7G   14.5M    9.2G     0%    /tmp
/dev/sd1e     48.4G   40.8G    5.2G    89%    /usr
/dev/sd1d     19.4G   16.9G    1.5G    92%    /var

# disklabel sd1
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: SR CRYPTO
duid: a1f07cee2aba3a55
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 121600
total sectors: 1953518528
boundstart: 64
boundend: 1953504000
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
   a:          4208960               64  4.2BSD   2048 16384 12960 # /
   b:         20980896          4209024  4.2BSD   2048 16384 12960 # /tmp
   c:       1953518528                0  unused
   d:         41945696         25189920  4.2BSD   2048 16384 12960 # /var
   e:        104872320         67135616  4.2BSD   2048 16384 12960 # /usr
   f:       1781496064        172007936  4.2BSD   8192 65536 52270 # /home


The system is currently up and running.
I'm not sure what has been overwritten. Possibly only sd1a /?
Is it possible to recover from this without loosing access to the data in 
/home, /var, /usr?


You may be in luck.

Only the FDISK partition table, the BSD partition table, root, and /tmp are gone.

This is what I'd do. Someone more knowledgeable could know better.

Power the system down asap so that the system won't try to use the bad data.

If you wrote onto the -encrypted- partition marked OpenBSD
not the one holding it marked RAID in that drive's fdisk it's only painful.

Install onto a -different- drive to make a rescue system.

If you just nuked the -encrypted- partition,
 Go to part B.

Otherwise, if you nuked the RAID partition:
Part A:

Boot the rescue system -c to disable softraid.

Reset the fdisk partition table on the nuked drive.
write a disklabel containing the RAID partition where the
encrypted one lived.

You must find someone who knows the softraid metadata.
That person would have to tell you how to write -just-
the metadata -only-.

Reenable softraid on the rescue system.
If necessary, reboot it.
The encrypted disk should reappear.
It has no structure.
Use fdisk to establish the OpenBSD are.
Use disklabel to reestablish your partitions.

part B:

On the encrypted partition:
Use fdisk to make the OpenBSD area and disklabel to write
the partition table.

Mount and copy your precious data onto some other drive.

Boot from bsd.rd
Install on the partially recovered encrypted drive.
The install program should recognize the rewritten partition table.
Otherwise use a custom partition table matching your old one.
Clear all the mount point names other than / and /tmp,
That tells the install program to -not- newfs them.

When rebooting at the end you may need to use -s to
fix any custom configuration that needs to be done early.
Fix the rest of your custom configuration once the system is up.
Reinstall packages etc etc etc.

With luck everything is back to normal.

Little portable USB drives are $60 or so for 1 TB.
Pretty large ones don't cost a lot more.

This doesn't happen often but... maybe a page somewhere online?

Geoff Steckel

Reply via email to