FreeBSD does not boot up after connected HDD via USB adaptor

Hi,
Yesterday i was turning on Linux Binary Compatibility and made mistake entry in /etc/fstab file.
Boot stop's on prompt to type shell but 2 of my keyboard's does not work (missing kernel module or something) so
i connected server hard drive by USB adaptor to VMWare OpenBSD instance and edit by vi broken fstab (remove invalid records).
After that, when i connected HDD to target computer boot stop's on blinking dash.

Make USB memstick with FreeBSD and check what gpart show's.
I was have structure something like: mbr, freebsd ufs partition and swap.
Now, show everything without swap partition.

After many attemps with gpart bootcode (show's invalid partition table or no operating system) i decide to try growfs on
main FreeBSD partition (i was hope it will fix something) and enlarge UFS for about 4GB (SWAP was that capacity).

I can mount main system partition with success. Files look's good.
But whatever i trying to do FreeBSD does not load.

Cloud anyone help me with it?
I have that server for years, 3 days ago i was upgraded to FreeBSD 14 and it's was okey.

In attachments show's gpart show, working fstab file on target system (comment out swap record) and some
of error's i got ("missing operating system", "invalid partition table" etc.).

I'm devastated, I didn't sleep all night because I thought I could fix it. But I have to ask for your help.
Thanks a lot for you'r time!
 

Attachments

  • error.jpg
    error.jpg
    277.3 KB · Views: 83
  • gpart-show.jpg
    gpart-show.jpg
    506.3 KB · Views: 85
  • old-fstab.jpg
    old-fstab.jpg
    527.7 KB · Views: 83
Thank you for the quick replay!
I do disklabel -B ada0s1 and now it's seems to do next boot step but show there is no loader (attachment).

--- edit ---
I trying a various path's and when I wrote: 0:ad(0,c)/boot/loader I get into something where I can do lsdev and it's shows structure of hard disk drive.
Before damage it's has swap & ufs partitions (ada0s1a, ada0s1b) and now it's seem's (ada0s1a) unknown. Maybe it's the problem? (attachment 2).
gpart show /dev/ada0s1 & gpart list /dev/ada0s1 in attachments shows unknown type.
 

Attachments

  • IMG_4253.jpg
    IMG_4253.jpg
    511.4 KB · Views: 84
  • trying-2.jpg
    trying-2.jpg
    333.5 KB · Views: 68
  • gpart-list.jpg
    gpart-list.jpg
    412.8 KB · Views: 67
  • gpart-show.jpg
    gpart-show.jpg
    642.4 KB · Views: 63
disklabel -e ad0s1
if you are not good with vi export EDITOR=something_else before

Code:
# /dev/da0s2:
8 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a:    4194288         16    4.2BSD       0     0     0
  c:    4194304          0    unused        0     0     # "raw" part, don't edit
replace fstype for the a: partititon with 4.2BSD and save and exit from the editor
 
covacat Charlie_ i have no nano editor on memory stick version and I better not touching vi anymore (for safety) so I tried to do gpart modify -i 1 -t freebsd-ufs ada0 but I get Invalid argument as at attachment.

--- edit ---
Before moderator approved my post I saw you say freebsd-ufs is not a valid for mbr. Is there any chance to change it by command? (I'm very very afraid of vi)
 

Attachments

  • gpart-modify.jpg
    gpart-modify.jpg
    1.3 MB · Views: 53
covacat Charlie_ check this out, the files seems to be okey but I can not boot into 0:ad(0,1,a)/boot/loader

--- edit ---
It looks like the proper disk is "C", so 0:ad(0,c)/boot/kernel/kernel cause BTX halted like in attachment.

--- edit ---
I have make SSH on live USB stick so now I could paste console text and not the images.

Bash:
root@MiWiFi-R1CM-srv:/ # gpart show ada0
=>        63  1953525105  ada0  MBR  (932G)
          63           1        - free -  (512B)
          64  1953525104     1  freebsd  [active]  (932G)

root@MiWiFi-R1CM-srv:/ # gpart show ada0s1
=>         0  1953525104  ada0s1  BSD  (932G)
           0          16          - free -  (8.0K)
          16  1953525088       1  freebsd-ufs  (932G)
 

Attachments

  • loader-on-ufs.jpg
    loader-on-ufs.jpg
    669.6 KB · Views: 60
  • btx.jpg
    btx.jpg
    660 KB · Views: 53
you can't boot kernel from there since freebsd 6 or so
you have to boot the loader
when you mounted the root fs to check the files inside what did you mount ada0s1a or ada0s1 ?
 
He can mount /dev/ada0s1 or /dev/ada0s1a it will allow it, i just test in under VM.
By default it's /dev/ada0s1a and the boot should load /boot/loader 0:ad(0,a)/boot/loader

Make a backup first until you have access to the filesystem. Just attach an external USB hard disk and make a dump.
!!!MBR only!!!
gpart(8)
/sbin/gpart bootcode -b /boot/boot0 ada0
/sbin/gpart bootcode -b /boot/boot ada0s1
 
i created a md mbr scheme with a std label
i can't mount or fsck /dev/md0s1 (only md0s1a)

Code:
[root@hp14 ~]# file -s /dev/md0s1*
/dev/md0s1:  DOS/MBR boot sector, BSD disklabel
/dev/md0s1a: Unix Fast File system [v2] (little-endian) last mounted on /mnt, last written at Sat Dec  9 10:38:03 2023, clean flag 1, readonly flag 0, number of blocks 25596, number of data blocks 24707, number of cylinder groups 4, block size 32768, fragment size 4096, average file size 16384, average number of files in dir 64, pending blocks to free 0, pending inodes to free 0, system-wide uuid 0, minimum percentage of free blocks 8, TIME optimization

but ive seen above he can fsck /dev/ada0s1 so it looks like the offset for the 'a' partition is wrong
this may explain while boot2 and loader fail to load 'a' but work with 'c'
 
covacat when I mount rootfs I do: mount /dev/ada0s1 /mnt (yes, I do fsck on that partition.).
But when I try to mount ada0s1a I got:
Bash:
root@MiWiFi-R1CM-srv:~ # mount /dev/ada0s1a /mnt
mount: /dev/ada0s1a: Invalid fstype: Invalid argument
When I type on boot: 0:ad(0,c)/boot/loader I got this (attachment).
But there is a files and it's seems to be not empty.
Bash:
root@MiWiFi-R1CM-srv:/mnt/boot/lua # ls -la loader.lua
-r--r--r--  1 root wheel 2306 Dec  8 12:18 loader.lua
And:
Bash:
root@MiWiFi-R1CM-srv:/ # file -s /dev/ada0s1*
/dev/ada0s1:  DOS/MBR boot sector, BSD disklabel
/dev/ada0s1a: data
 

Attachments

  • boot-loader.jpg
    boot-loader.jpg
    297.5 KB · Views: 53
Make a backup of your data to external disk. Then install testdisk and try to recover the filesystem on /dev/ada0s1a as UFS2 and fsck_ufs /dev/ada0s1a

 
Back
Top