Date: Sat, 15 Apr 2000 20:12:50 +0100 From: Ben Smithurst <ben@scientia.demon.co.uk> To: Scott Blachowicz <scott@sabami.seaslug.org> Cc: freebsd-questions@freebsd.org Subject: Re: Erasing an IDE disk Message-ID: <20000415201250.A23900@strontium.scientia.demon.co.uk> In-Reply-To: <20000415095209.A58006@sabami.seaslug.org> References: <20000414161657.A35142@sabami.seaslug.org> <20000415165532.A16019@strontium.scientia.demon.co.uk> <20000415095209.A58006@sabami.seaslug.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Scott Blachowicz wrote: > What did you use to do that? And what OS version? FreeBSD 3.4, I think (definitely FreeBSD 3.something). I used this small program: #include <err.h> #include <errno.h> #include <fcntl.h> #include <signal.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define DISK "/dev/wd1" int sig = 0; void nop(int s) { sig = 1; return; } int main(int argc, char *argv[]) { char buf[64 << 10]; int fd, ch, sverr; ssize_t n, tot; struct sigaction sa; sa.sa_handler = nop; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGINT, &sa, NULL); if (argc > 1) ch = strtol(argv[1], NULL, 0); else ch = 0xff; memset(buf, ch, sizeof buf); fd = open(DISK, O_WRONLY); if (fd < 0) err(1, DISK); warnx("ch=%x buf[0]=%x", ch, (unsigned int)buf[0]); tot = 0; while (!sig && (n = write(fd, buf, sizeof buf)) == sizeof buf) tot += n; sverr = errno; warnx("total %ld bytes written", (long)tot); if (sig) errx(1, "exiting because of signal"); errno = sverr; if (n < 0) err(1, "write"); else errx(1, "partial write of %ld bytes%s", (long)n, (n == 0) ? " (end of device?)" : ""); } Be sure to set the #define DISK correctly. :-) Then run it like ./diskerase 0x0 ./diskerase 0xff ./diskerase 0x0 #include <std_disclaimer.h> Run at your own risk, etc. (I just mis-typed "risk" as "disk", which would probably be just as valid in this case. :-) -- Ben Smithurst / ben@scientia.demon.co.uk / PGP: 0x99392F7D To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000415201250.A23900>