UFS Restoring boot code

amnixed

Active Member

Reaction score: 4
Messages: 116

Hello,

I have a laptop with FreeBSD 13 and Win 10 on a shared drive.

After the latest Windows "feature experience" update, FreeBSD can't boot.

Using LiveCD, gpart gives:
Code:
Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 976773167
first: 63
entries: 4
scheme: MBR
Providers:
1. Name: ada0s1
   Mediasize: 575668224 (549M)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   efimedia: HD(1,MBR,0x8bb41e01,0x800,0x112800)
   attrib: active
   rawtype: 7
   length: 575668224
   offset: 1048576
   type: ntfs
   index: 1
   end: 1126399
   start: 2048
2. Name: ada0s2
   Mediasize: 99477067264 (93G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   efimedia: HD(2,MBR,0x8bb41e01,0x113000,0xb94a5cb)
   rawtype: 7
   length: 99477067264
   offset: 576716800
   type: ntfs
   index: 2
   end: 195417546
   start: 1126400
3. Name: ada0s3
   Mediasize: 609222656 (581M)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   efimedia: HD(3,MBR,0x8bb41e01,0xba5d800,0x122800)
   rawtype: 39
   length: 609222656
   offset: 100054073344
   type: !39
   index: 3
   end: 196607999
   start: 195418112
4. Name: ada0s4
   Mediasize: 386547056640 (360G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   efimedia: HD(4,MBR,0x8bb41e01,0xbb80800,0x2d000000)
   rawtype: 165
   length: 386547056640
   offset: 100664344576
   type: freebsd
   index: 4
   end: 951584767
   start: 196610048
Consumers:
1. Name: ada0
   Mediasize: 500107862016 (466G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0

Will I be able to restore FreeBSD booting with
Code:
gpart bootcode -b /boot/boot0 ada0
?

With the LiveCD, I was able to mount /dev/ada0s4 to /mnt and by a cursory look, all the files seem to be there.

Please advise.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,560
Messages: 37,878

You probably need boot0cfg(8), which allows you to select which OS to boot.
 

covacat

Well-Known Member

Reaction score: 170
Messages: 365

i thing both gpart and boot0cfg will work / do the same thing
 
OP
A

amnixed

Active Member

Reaction score: 4
Messages: 116

You probably need boot0cfg(8), which allows you to select which OS to boot.
Thank you SirDice, I can now boot.

For boot options, I now get:

F1: Win
F2: Win
F3: ?
F4: FreeBSD

I have also changed /etc/fstab entries to /dev/ada0s4a and
/dev/ada0s4b to mount root.

But what happened to the F3 option? Before Windows update ruined FreeBSD booting, F3 was the FreeBSD option.
 

astyle

Aspiring Daemon

Reaction score: 240
Messages: 538

Thank you SirDice, I can now boot.

For boot options, I now get:

F1: Win
F2: Win
F3: ?
F4: FreeBSD

I have also changed /etc/fstab entries to /dev/ada0s4a and
/dev/ada0s4b to mount root.

But what happened to the F3 option? Before Windows update ruined FreeBSD booting, F3 was the FreeBSD option.
I think that /dev/ada0s4a should offer a hint. Your /etc/fstab entries needed to be modified, right? from /dev/ada0s3a to /dev/ada0s4a, I'm guessing?

Rather obscure way to connect the dots, I know.
 
OP
A

amnixed

Active Member

Reaction score: 4
Messages: 116

I think that /dev/ada0s4a should offer a hint. Your /etc/fstab entries needed to be modified, right? from /dev/ada0s3a to /dev/ada0s4a, I'm guessing?

Rather obscure way to connect the dots, I know.
That's just my question: why is the FreeBSD slice now s4 when it used to be s3?
 

astyle

Aspiring Daemon

Reaction score: 240
Messages: 538

Seems like the process you used [to start booting FreeBSD again] took a look at things, and realized that for some reason, it can't boot FreeBSD from slice 3. However, booting it from the next available slice number (4 in your case), proved successful. I'd suggest re-reading the manpage (that SirDice pointed you to) so that you can better understand what happened, and how it's supposed to work. It may take re-reading it several times over before it makes sense.
 

Vull

Well-Known Member

Reaction score: 233
Messages: 487

Windows updates and disk administration programs can, and sometimes will ( 1.) renumber partitions, ( 2.) resize its own partitions to create more free space, and ( 3.) create new partitions, although not necessarily in that order. Sharing a drive with Windows is tricky business. I do it, but can't recommend it. I make frequent backups of my own stuff to removable drives, and am always prepared to reinstall everything from scratch.

Like Linux, Windows seems to prefer using UUIDs to keep track of partitions, instead of partition numbers. If your partition numbers get out of sequence, Windows will likely renumber them to put them in sequence, if you give it an opportunity to do so. If you leave free space on your drive, Windows will probably use it. If you create FAT32 or NTFS partitions on that drive, Windows will think that it owns those partitions, often assigning its own drive letters (D:, E:, etc.) to them.
 
OP
A

amnixed

Active Member

Reaction score: 4
Messages: 116

Windows updates and disk administration programs can, and sometimes will ( 1.) renumber partitions, ( 2.) resize its own partitions to create more free space, and ( 3.) create new partitions, although not necessarily in that order. Sharing a drive with Windows is tricky business.[...]
Yep, a second hard drive should spare me this kind of headache.
 

Vull

Well-Known Member

Reaction score: 233
Messages: 487

Yep, a second hard drive should spare me this kind of headache.
I've never tried that. I'm sure Windows will still see that drive, and want to claim it as it's own, but I wish you luck. Hopefully its meddling will be less severe. One thing that might help is to partition the whole drive with a filesystem or filesystems foreign to Windows. That way, even if you don't need the whole drive now, you can always delete some partitions later, and free up the space for your own purposes when you need it.
 
Top