From owner-freebsd-questions@FreeBSD.ORG Thu Dec 11 12:11:53 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C427816A4CE for ; Thu, 11 Dec 2003 12:11:53 -0800 (PST) Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C6F143D1D for ; Thu, 11 Dec 2003 12:11:51 -0800 (PST) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [127.0.0.1]) hBBKBitd076102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 11 Dec 2003 20:11:45 GMT (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id hBBKBis2076101; Thu, 11 Dec 2003 20:11:44 GMT (envelope-from matthew) Date: Thu, 11 Dec 2003 20:11:44 +0000 From: Matthew Seaman To: Dru Message-ID: <20031211201144.GD75256@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Dru , questions@freebsd.org References: <20031211145245.D637@genisis> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="C1iGAkRnbeBonpVg" Content-Disposition: inline In-Reply-To: <20031211145245.D637@genisis> User-Agent: Mutt/1.5.5.1i X-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.60 X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on happy-idiot-talk.infracaninophile.co.uk cc: questions@freebsd.org Subject: Re: dd of mounted filesystem X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2003 20:11:53 -0000 --C1iGAkRnbeBonpVg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 11, 2003 at 02:54:12PM -0500, Dru wrote: > Can anyone describe or point me to resources explaining why it is > dangerous to dd a filesystem while it is mounted? Is it still considered > to be dangerous if the system is first dropped down to single-user mode? I assume you're talking about dd of the filesystem block devices, rather than anything else. dd'ing from a mounted filesystem is generally safe, although you won't get any sort of sensible result unless the source filesystem is inactive -- remounting the FS read-only should be sufficient. Using dd(1) to write to the block device of a mounted filesystem will at minimum create a horrible mess and at worst could well crash the machine. Remember that dd(1) traverses the block device sequentially, but that most FS accesses are random, so any particular change can span either side of dd(1)'s offset. Also that dd'ing from the block device bypasses the usual machinery for doing file IO -- machinery that is designed under the premise that it will have sole control over what gets read or written where and when. dd'ing to a mounted filesystem will overwrite the original inode structure, but the dd(1) process is going to be competing with the buffer cache, which will tend to write data back using it's cached version of the previous structure. You'll end up with a mess that fsck(1) probably couldn't sort out. Even if the target FS is mounted read-only the filesystem code will still probably throw a wobbly when it finds the disk contents have been changed out from underneath it. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --C1iGAkRnbeBonpVg Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQE/2M+AdtESqEQa7a0RAnZkAJ0VEj+KsuwEPtb31nuRBwbJXIxsZwCePLvX F5qr1SagLCcZhJpqjaVYCGw= =mMlD -----END PGP SIGNATURE----- --C1iGAkRnbeBonpVg--