Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I had a quick question about this particular modifier, conv=notrunc. What exactly does this do as the man page is a bit sketchy about it? In the past I have created disk images of dvd's and even hard drives and have never had issues with them.
Anyone shed some light on why it would be needed and possible ramifications if it is not used?
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
At Least Try It ...
Quote:
Originally Posted by archtoad6
I seem to only be posting corrections, sorry. ...
From the bash man page (search for "metacharacter"):
This means that the '>' separates words on the CLI the same as a space does, & therefore putting spaces around a '>' is NOT necessary for the command to work.
Furthermore, that is also my personal experience.
Anyone who wants to can test this by comparing the results of the following 2 commands:
Code:
>space_test0
> space_test1
Each will create an empty file in the current directory.
I DO generally put a space before '>' for clarity, especially if it's in a code snippet that I'm going to post. (See my post #361 above.)
OK, archtoad,
Do it the way you want. But if you don't even try what I said then don't post that you don't know how to do it. The > is a redirect operator. Why don't you just try what I said?
Last edited by AwesomeMachine; 09-17-2010 at 08:56 AM.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
Notrunc ...
Quote:
Originally Posted by exvor
I had a quick question about this particular modifier, conv=notrunc. What exactly does this do as the man page is a bit sketchy about it? In the past I have created disk images of dvd's and even hard drives and have never had issues with them.
Anyone shed some light on why it would be needed and possible ramifications if it is not used?
exvor,
This is a popular subject. The conversion parameter, notrunc, tells dd not to truncate the output file. This applies if the output file currently exists.
If you want to write a sector of 0xffh bytes to the beginning of an existing file:
Code:
dd if=/dev/zero bs=512 count=1 | sed 's,\x00,\xff,g' | of=/home/sam/existing.file
will replace the entire file with 512 0xffh bytes, leaving the file 512 bytes long and eliminating the preexisting contents.
Code:
dd if=/dev/zero bs=512 count=1 | sed 's,\x00,\xff,g' | of=/home/sam/existing.file conv=notrunc
tells dd to just replace the specified bytes and leave the rest of the output file alone. Without this option, dd would create an output file 512 bytes long.
Last edited by AwesomeMachine; 09-06-2010 at 01:49 AM.
I actually put a link to the htmlized man page, but when I saved the whole post it was too large and the system refused to save, so I had to cut out some new content and that got cut. If you look at the second post the man page is written out pretty much verbatim.
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
Creating analogs for /dev/zero as input for dd...
Hi AwesomeMachine and other knowledgeable persons .
How is /dev/zero working? I mean what mechanism tells dd to use an endless stream of binary zeros e.g. for an input file in dd if=/dev/zero ... ? I can't imagine that the zeros truly get freshly created for more than one blocksize (bs) -- or do they?
Reason for my inquiry (apart from the joy in generalized knowledge) is this: last night I wiped an old 10 GB disk with "dd if=/dev/urandom of=/dev/sdb". That took more than 1 1/2 hours on my old 700 Mhz Athlon.
After this experience my idea was to first create a file of, say, 1 MB of random data and then using this block of data repeatedly as input for dd. Would that be possible and how would one go about that?
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
Quote:
Originally Posted by rn_
My understanding is that the device driver behind the device responds to the read request by writing zeros....
How wasteful . I mean, creating once the necessary block of zeros and then never increasing the address pointer would do admirably without pestering the CPU for zeros. Ah well...
Quote:
Originally Posted by rn_
...you could use something like:...
Thanks, I copied that and will try it next time.
<edit> Okay, I tried it. It still took close to an hour. While it is an improvement it still is nothing like fast. CPU-load stayed at 100%. </edit>
How wasteful . I mean, creating once the necessary block of zeros and then never increasing the address pointer would do admirably without pestering the CPU for zeros. Ah well...
perhaps that's exactly what it does; i wouldn't know because i haven't seen the code, and if i did, i doubt if i'd be able to make heads or tails of it.
Data written on a null or zero special file is discarded. Reads from the null special file always return end of file, whereas reads from zero always return \0 characters. null and zero are typically created by:
mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
chown root:mem /dev/null /dev/zero
NOTES
If these devices are not writable and readable for all users, many programs will act strange. FILES
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.