7

There are many articles on the web that describe a command-line to make an ISO image from a DVD-Video disc like this:

dd if=/dev/sr0 of=mydvd.iso conv=noerror,sync,notrunc

I'd like to uderstand why notrunc is necessary. From my knowledge, and from the man page for the command, notrunc prevents the output file from being truncated. This basically means that, if the file exists, dd just overwrites what is already there; if there is content there that dd doesn't touch (perhaps by seeking to another point in the file) then that original content is left intact.

When making an ISO, surely you want to start with a new, clean, empty file ?

The only thing I can think of is in the case of a really bad disc, using notrunc enables you to run the same dd command several times over the same output file to hopefully fill in different bits each time. If the output file doesn't exist then notrunc has no effect.

Is that it, or is there some other reason everyone specifies notrunc ?

(I am not asking how to get around CSS, ARccOS, or anything else; just about dd usage)

5
  • 4
    There's a great answer on Stack Exchange that covers this. Commented Oct 7, 2014 at 11:14
  • I had read that but it didn't anser the specific question of why people do it when copying DVDs. The final summary of the accepted answer there backs up my current understanding that it is only important for when you have a file you want to write into, but don't want to truncate it. I'm trying to understand why people think it necessary not to truncate an iso before writing it. Commented Oct 7, 2014 at 12:09
  • Fair point. My only other thought is that a truncated ISO will have a different MD5 checksum to the untrucated form, which would make checking the integrity of the image impossible. But for that to work, you'd need to add bs= and count= options to dd in order that it clones the CD/DVD exactly. Commented Oct 7, 2014 at 13:00
  • notrunc option avoid OS to de-allocate, then reallocate block used for iso file. This might be a little faster. Commented Oct 7, 2014 at 13:14
  • You can get an md5 match with a basic dd of=/dev/dvd of=image.iso but, yes, it's guaranteed if you add bs=2048 count=$(isosize -d 2048 /dev/dvd) to it. Of course, when you throw a "complicated" disc into it then you get problems... Commented Oct 7, 2014 at 13:16

2 Answers 2

2

If I had to guess, based on this comment from the Wikipedia article on dd:

The notrunc conversion option means do not truncate the output file — that is, if the output file already exists, just replace the specified bytes and leave the rest of the output file alone.

the use of notrunc is for performance reasons. No sense in re-writing the entire file just to update a few bytes/kbytes/megabytes/etc.

NOTE: The definitive answer to this question has got to be the StackOverflow Q&A that @garethTheRed referenced in the comments, titled: Why using conv=notrunc when cloning a disk with dd?. The answer there is superb and includes a C++ program that demonstrates the effect that O_TRUNC has on block devices & files.

1

It is not needed if you want to copy a whole DVD to a file which shall afterwards contain only the payload of that DVD. Actually notrunc is a risk for privacy and can cause media overflow if you overwrite an old file that is larger than the DVD payload. In this case the surplus blocks of the old file will stay appended to the copied DVD content. So they would be copied to a new DVD together with the filesystem.

Quite helpful is the advise in the comment of starfry to copy only the blocks of the ISO 9660 filesystem (if it is actually ISO 9660) because the DVD medium might deliver more blocks than those of the filesystem.

1
  • The format of a DVD is called Universal Disc Format, UDF. It's like a successor to ISO9660 which is primarily a CD format. From a rip/burn perspective I don't think it really matters to the user and it's common to refer to UDF images as .iso files. Tools that expect ISO9660 images, however, may not work on a .iso file that is UDF inside. Commented Oct 8, 2014 at 8:53

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.