Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Mar 2013 14:56:42 -0800 (PST)
From:      Andrew Pack <andrewpack54@yahoo.com>
To:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   VIA PV530
Message-ID:  <1362351402.61999.YahooMailNeo@web164001.mail.gq1.yahoo.com>

next in thread | raw e-mail | index | archive | help
Does anyone have any experience running FreeBSD on this platform? Unless I'=
m mistaken, I could't find it listed under the new release compatibility li=
st.=A0
From owner-freebsd-questions@FreeBSD.ORG  Mon Mar  4 00:36:06 2013
Return-Path: <owner-freebsd-questions@FreeBSD.ORG>
Delivered-To: freebsd-questions@freebsd.org
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 29370233
 for <freebsd-questions@freebsd.org>; Mon,  4 Mar 2013 00:36:06 +0000 (UTC)
 (envelope-from freebsd@edvax.de)
Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14])
 by mx1.freebsd.org (Postfix) with ESMTP id CB4F7E4
 for <freebsd-questions@freebsd.org>; Mon,  4 Mar 2013 00:36:05 +0000 (UTC)
Received: from r56.edvax.de (port-92-195-109-47.dynamic.qsc.de [92.195.109.47])
 by mx01.qsc.de (Postfix) with ESMTP id D7F233CDE4
 for <freebsd-questions@freebsd.org>; Mon,  4 Mar 2013 01:36:03 +0100 (CET)
Received: from r56.edvax.de (localhost [127.0.0.1])
 by r56.edvax.de (8.14.5/8.14.5) with SMTP id r240a8jP076942
 for <freebsd-questions@freebsd.org>; Mon, 4 Mar 2013 01:36:08 +0100 (CET)
 (envelope-from freebsd@edvax.de)
Date: Mon, 4 Mar 2013 01:36:08 +0100
From: Polytropon <freebsd@edvax.de>
To: FreeBSD Questions <freebsd-questions@freebsd.org>
Subject: Grepping though a disk
Message-Id: <20130304013608.7981e8a9.freebsd@edvax.de>
Organization: EDVAX
X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: Polytropon <freebsd@edvax.de>
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions>;
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 04 Mar 2013 00:36:06 -0000

Due to a fsck file system repair I lost the content of a file
I consider important, but it hasn't been backed up yet. The
file name is still present, but no blocks are associated
(file size is zero). I hope the data blocks (which are now
probably marked "unused") are still intact, so I thought
I'd search for them because I can remember specific text
that should have been in that file.

As I don't need any fancy stuff like a progress bar, I
decided to write a simple command, and I quickly got
something up and running which I _assume_ will do what
I need.

This is the command I've been running interactively in bash:

	$ N=0; while true; do echo "${N}"; dd if=/dev/ad6 of=/dev/stdout bs=10240 count=1 skip=${N} 2>/dev/null | grep "<PATTERN>"; if [ $? -eq 0 ]; then break; fi; N=`expr ${N} + 1`; done

To make it look a bit better and illustrate the simple
logic behind my idea:

	N=0
	while true; do
		echo "${N}"
		dd if=/dev/ad6 of=/dev/stdout bs=10240 count=1 skip=${N} \
			2>/dev/null | grep "<PATTERN>"
		if [ $? -eq 0 ]; then
			break
		fi
		N=`expr ${N} + 1`
	done

Here <PATTERN> refers to the text. It's only a small, but
very distinctive portion. I'm searching in blocks of 10 kB
so it's easier to continue in case something has been found.
I plan to output the resulting "block" (it's not a real disk
block, I know, it's simply a unit of 10 kB disk space) and
maybe the previous and next one (in case the file, the _real_
block containing the data, has been split across more than
one of those units. I will then clean the "garbage" (maybe
from other files) because I can easily determine the beginning
and the end of the file.

Needless to say, it's a _text_ file.

I understand that grep operates on text files, but it will
also happily return 0 if the text to search for will appear
in a binary file, and possibly return the whole file as a
search result (in case there are no newlines in it).

My questions:

1. Is this the proper way of stupidly searching a disk?

2. Is the block size (bs= parameter to dd) good, or should
   I use a different value for better performance?

3. Is there a program known that already implements the
   functionality I need in terms of data recovery?

Results so far:

The disk in question is a 1 TB SATA disk. The command has
been running for more than 12 hours now and returned one
false-positive result, so basically it seems to work, but
maybe I can do better? I can always continue search by
adding 1 to ${N}, set it as start value, and re-run the
command.

Any suggestion is welcome!



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1362351402.61999.YahooMailNeo>