Gentoo Archives: gentoo-user

From: Dale <rdalek1967@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Testing a used hard drive to make SURE it is good.
Date: Thu, 18 Jun 2020 09:14:36
Message-Id: 91bbab90-88b1-47ac-3c80-a8a842b5b48f@gmail.com
In Reply to: Re: [gentoo-user] Testing a used hard drive to make SURE it is good. by David Haller
1 David Haller wrote:
2 > Hello,
3 >
4 > On Mon, 15 Jun 2020, Dale wrote:
5 > [..]
6 >> While I'm at it, when running dd, I have zero and random in /dev.  Where
7 >> does a person obtain a one?  In other words, I can write all zeros, I
8 >> can write all random but I can't write all ones since it isn't in /dev. 
9 >> Does that even exist?  Can I create it myself somehow?  Can I download
10 >> it or install it somehow?  I been curious about that for a good long
11 >> while now.  I just never remember to ask. 
12 > I've wondered that too. So I just hacked one up just now.
13 >
14 > ==== ones.c ====
15 > #include <unistd.h>
16 > #include <stdlib.h>
17 > #include <stdio.h>
18 > static unsigned int buf[BUFSIZ];
19 > int main(void) {
20 > unsigned int i;
21 > for(i = 0; i < BUFSIZ; i++) { buf[i] = (unsigned int)-1; }
22 > while( write(STDOUT_FILENO, buf, sizeof(buf)) );
23 > exit(0);
24 > }
25 > ====
26 >
27 > Compile with:
28 > gcc $CFLAGS -o ones ones.c
29 > or
30 > gcc $(portageq envvar CFLAGS) -o ones ones.c
31 >
32 > and use/test e.g. like
33 >
34 > ./ones | dd of=/dev/null bs=8M count=1000 iflag=fullblock
35 >
36 > Here, it's about as fast as
37 >
38 > cat /dev/zero | dd of=/dev/null bs=8M count=1000 iflag=fullblock
39 >
40 > (but only about ~25% as fast as
41 > dd if=/dev/zero of=/dev/null bs=8M count=1000 iflag=fullblock
42 > for whatever reason ever, but the implementation of /dev/zero is
43 > non-trivial ...)
44 >
45 > HTH,
46 > -dnh
47 >
48
49 I got it to compile, at least it created a file named ones anyway.  What
50 I'm unclear about, where is the if= for dd in the command?  All the
51 commands I've seen before has a if= and a of=.  The if for input and of
52 for output or target.  I'm assuming that if I want to target sdb, I'd
53 replace null with /dev/sdb. 
54
55 As I've posted before, even my scripting skills are minimal.  Surprised
56 I got it to compile even.  lol  Just trying to make sure I don't mess up
57 something.  I placed all this in the /root directory.  I'm assuming I
58 can copy paste the commands above while in /root to make it work?  I'm
59 asking because I haven't tried it yet. 
60
61 Thanks.
62
63 Dale
64
65 :-)  :-) 

Replies

Subject Author
RE: [gentoo-user] Testing a used hard drive to make SURE it is good. Pengcheng Xu <i@××××××××.moe>
Re: [gentoo-user] Testing a used hard drive to make SURE it is good. David Haller <gentoo@×××××××.de>