1.\" $OpenBSD: scan_ffs.8,v 1.16 2008/03/23 23:28:46 krw Exp $ 2.\" 3.\" Copyright (c) 1997 Niklas Hallqvist, Tobias Weingartner 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25.\" 26.\" .TH scan_ffs 8 27.Dd $Mdocdate: March 23 2008 $ 28.Dt SCAN_FFS 8 29.Os 30.Sh NAME 31.Nm scan_ffs 32.Nd find UFS/FFS partitions on a disk 33.Sh SYNOPSIS 34.Nm scan_ffs 35.Op Fl lsv 36.Op Fl b Ar begin 37.Op Fl e Ar end 38.Ar device 39.Sh DESCRIPTION 40This is the life-saver of typos. 41If you have ever been working too long, 42and just happened to type 'disklabel -w sd0 floppy', instead of 'disklabel 43-w fd0 floppy', you know what I am talking about. 44.Pp 45This little program will take a raw disk device (which you might have to 46create) that covers the whole disk, and finds all probable UFS/FFS partitions 47on the disk. 48It has various options to make it go faster, and to print out 49information to help in the reconstruction of the disklabel. 50.Pp 51The options are as follows: 52.Bl -tag -width Ds 53.It Fl b Ar begin 54Tell 55.Nm 56where to begin searching for filesystems. 57This makes it easier to skip swap 58partitions, or other large non-UFS/FFS partitions. 59.It Fl e Ar end 60Ditto for telling 61.Nm 62where to stop. 63.It Fl l 64This will make 65.Nm 66print out a string looking much like the input to disklabel. 67With a little massaging, this output can usually be used in the disklabel edit. 68.It Fl s 69This tells 70.Nm 71to be smart about skipping partitions (when it thinks it found a valid one). 72By not scanning partitions for superblocks, the program completes a couple of 73orders of magnitude faster. 74However, sometimes being smart is too good for 75its own good, 76especially if your disk has had a different layout previously, or contains 77other non-UFS/FFS filesystems. 78.It Fl v 79Tell 80.Nm 81to be verbose about what it is doing, and what it has found. 82.It Ar device 83This specifies which device 84.Nm 85should use to scan for filesystems. 86Usually this device should cover the whole disk in question. 87.El 88.Pp 89The basic operation of this program is as follows: 90.Bl -enum -width "1111" 91.It 92Panic. 93You usually do so anyways, so you might as well get it over with. 94Just don't do anything stupid. 95Panic away from your machine. 96Then relax, and see if the steps below won't help you out. 97.It 98Try to find your old disklabel by any other means possible. 99This includes 100printouts, backups 101(look in 102.Pa /var/backups/ ) , 103screendumps, and whatever other method you can think of. 104The more information you have, the better your chances are in recovering the 105disklabel of the disk. 106.It 107Create a disklabel on the affected disk, which covers the whole disk, and has 108at least one partition which covers the whole disk. 109As the 110.Dq c 111partition 112usually covers the whole disk anyways, this sounds like a good place to start. 113.It 114Run 115.Nm 116over this partition. 117If you have any information about the disklabel 118which used to exist on the disk, keep that in mind while 119.Nm 120spews out its things. 121.It 122Use 123.Xr disklabel 8 124to reconstruct the disklabel on the affected disk, using 125all the information you gathered from 126.Nm 127and other sources. 128.El 129.Pp 130Last but certainly not least, we wish you good luck. 131The UFS/FFS filesystems are pretty sturdy. 132I've seen them reconstructed after some pretty weird and 133awesome fumbles. 134If you can't have backups, at least have funky tools to help 135you out of a jam when they happen. 136.Sh SEE ALSO 137.Xr disklabel 8 138.Sh BUGS 139It is not perfect, and could do a lot more things with date/time information 140in the superblocks it finds, but this program has saved more than one butt, 141more than once. 142