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: Tue, 16 Jun 2020 07:17:29
Message-Id: 158351d5-27cc-88d0-951c-893d0b5ad8aa@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
50 Thanks David for the reply and others as well.  I got some good ideas
51 from some experts plus gave me things to google.  More further down.
52
53 For the /dev/one, I found some which seems to work.  They listed further
54 down.  I think my google search terms was poor.  Google doesn't have ESP
55 for sure.  O_o
56
57 I mentioned once long ago that I keep a list of frequently used
58 commands.  I do that because, well, my memory at times isn't that
59 great.  Here is some commands I ran up on based on posts here and what
60 google turned up when searching for things related on those posts.  I
61 wanted to share just in case it may help someone else.  ;-)  dd commands
62 first. 
63
64
65 root@fireball / # cat /root/freq-commands | grep dd
66 dd commands
67 dd if=/dev/zero of=/dev/sd bs=4k conv=notrunc
68 dd if=/dev/zero of=/dev/sd bs=4k conv=notrunc oflag=direct  #disables cache
69 dd if=/dev/zero of=/dev/sd bs=1M conv=notrunc
70 dd if=<(yes $'\01' | tr -d "\n") of=
71 dd if=<(yes $'\377' | tr -d "\n") of=
72 dd if=<(yes $'\xFF' | tr -d "\n") of=
73 root@fireball / #
74
75
76 The target device or file needs to be added to the end of course on the
77 last three.  I tend to leave out some of the target to make sure I don't
78 copy and paste something that ends badly.  dd can end badly if targeting
79 the wrong device. 
80
81
82 root@fireball / # cat /root/freq-commands | grep smartctl
83 smartctl -t long /dev/sd
84 smartctl -t full  ##needs research
85 smartctl -c -t short -d sat /dev/sd  ##needs research
86 smartctl -t conveyance -d sat /dev/sd  ##needs research
87 smartctl -l selftest -d sat /dev/sd  ##needs research
88 smartctl -t <short|long|conveyance|select> /dev/sd  ##needs research
89 smartctl -c /dev/sd  ##displays test times in minutes
90 smartctl -l selftest /dev/sd
91 root@fireball / #
92
93
94 The ones where I have 'needs research' on the end, I'm still checking
95 the syntax of the command.  I haven't quite found exact examples of them
96 yet.  This also led to me wanting to print the man page for smartctl. 
97 That is a task in itself.  Still, google found me some options which are
98 here:
99
100
101 root@fireball / # cat /root/freq-commands | grep man
102 print man pages to text file
103 man <command> | col -b > /home/dale/Desktop/smartctl.txt
104 print man pages to .pdf but has small text.
105 man -t <command> > /home/dale/Desktop/smartctl.pdf
106 root@fireball / #
107
108
109 It's amazing sometimes how wanting to do one thing, leads to learning
110 how to do many other things, well, trying to learn how anyway.  LOL 
111
112 I started the smartctl longtest a while ago.  It's still running but it
113 hasn't let the smoke out yet.  It's a good sign I guess. I only have one
114 SATA port left now.  I got to order another PCI SATA card I guess.  :/ 
115 I really need to think on the NAS project. 
116
117 Thanks to all. 
118
119 Dale
120
121 :-)  :-) 

Replies