UFS How to check external disk

balanga

Son of Beastie

Reaction score: 109
Messages: 2,721

I had a problem with a disk last week where I was unable to run fsck(8), so unable to boot....

After reinstalling FreeBSD on another disk, I thought I'd like to find out what went wrong with it.
I propose to attach it via a USB adapter and try and run fsck on it, but not sure how.

Any advice would be appreciated.
 

kpa

Beastie's Twin

Reaction score: 1,801
Messages: 6,318

Attach the disk and run gpart show. Then figure out from the output which partition has the UFS filesystem. For example if the UFS filesystem is on da0p2 you would run:

# fsck -y /dev/da0p2
 
OP
OP
B

balanga

Son of Beastie

Reaction score: 109
Messages: 2,721

Code:
gpart list da0
Geom name: da0
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 625142414
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: da0p1
   Mediasize: 524288 (512K)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 1024
   Mode: r0w0e0
   rawuuid: f0e891ec-1893-11e6-8cdd-001641aa6de9
   rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
   label: (null)
   length: 524288
   offset: 17408
   type: freebsd-boot
   index: 1
   end: 1057
   start: 34
2. Name: da0p2
   Mediasize: 315679571968 (294G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 1024
   Mode: r0w0e0
   rawuuid: f0e952ff-1893-11e6-8cdd-001641aa6de9
   rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
   label: (null)
   length: 315679571968
   offset: 541696
   type: freebsd-ufs
   index: 2
   end: 616562721
   start: 1058
3. Name: da0p3
   Mediasize: 4294967296 (4.0G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 1024
   Mode: r0w0e0
   rawuuid: f0eae28b-1893-11e6-8cdd-001641aa6de9
   rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
   label: (null)
   length: 4294967296
   offset: 315680113664
   type: freebsd-swap
   index: 3
   end: 624951329
   start: 616562722
Consumers:
1. Name: da0
   Mediasize: 320072933376 (298G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
Code:
fsck -y /dev/da0p2
** /dev/da0p2
The previous newfs operation on this volume did not complete.
You must complete newfs before mounting this volume.
I don't recall running newfs....
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,268
Messages: 29,700

Apparently the filesystem is so corrupt even fsck(8) can't figure it out anymore. At least it explains why your machine refused to boot from it :D
 
Top