stevepedwards.com/DebianAdmin linux mint IT admin tips info

Issues Writing with DD to /dev/sr0 With Blank DVDs

Recently I found DD in Mint not writing directly to new blank CD/DVD disks via the actual device ID such as /dev/sr0, as I thought it always used to in older, pre Mint, Debian distros, with a complaint of:

stevee@AMDA8 ~ $ dd if=Downloads/Win7/Win7_64.iso of=/dev/sr0 bs=32M conv=noerror,sync

dd: error writing ‘/dev/sr0’: No space left on device

1+0 records in

0+0 records out

0 bytes (0 B) copied, 0.110467 s, 0.0 kB/s

I googled and many others seem to have the same problem, but the solutions offered only blamed DD for not being the “correct tool” for this error without giving a sensible answer, just opinionated crap as in red below.

https://forums.opensuse.org/showthread.php/431934-dd-won-t-burn-iso-image

Wrong tool. dd is not a optical media burner. Linux GUI burner tools include k3b, brasero, and a whole heap of others.”

http://www.linuxquestions.org/questions/linux-software-2/dev-sr0-is-read-only-filesystem-4175503522/

Quakeboy02: I used to be able to do "dd if=xxx.iso of=/dev/sr0". Somewhere along the line this has gotten changed/broken and it now resolutely says that /dev/sr0 is a read-only filesystem. How can I burn an iso file to a DVD without having to resort to k3b or brasero or something similar? I want my dd back.
The OS is Debian/Wheezy.”

metaschima: 'dd' is not meant for this task. Use 'growisofs' or 'cdrecord'. However, it may be a permissions issue. I always burn as root to avoid such issues.”

Quakeboy02: I keep running into the comment "dd is not made for this task". Why not? dd is made for reading/writing directly to any storage device, whether it's tape, disk, floppy, CD, or DVD.

metaschima: What about burn speed, buffering, BurnFree, and handling more advanced appendable formats ? I would think those are very important when burning disks. 'dd' is mostly meant for low-level data manipulation. It is probably best known for accidentally or deliberately wiping disks.

Quote:

Write an optical disk with dd and you'll get a coaster. I think that the ISO 9660 file system needs a lead in and lead out, and the disk needs to be finalized. Make the .iso with dd then write it with growisofs.

That would be quite a surprise for all the folks who have been using dd for years to burn images to CDs and DVDs.

Wow! Wiping disks only? Getting coasters? Really? Not Copying and Converting files from one type to another, as in it's original, arbitrarily changed name from CC to DD…? What do these people think you would need to do on a headless server, as was the origins of UNIX – and yes the CD writer was public around 1980 on, before decent graphics for GUI based apps.

https://en.wikipedia.org/wiki/Dd_(Unix)

An example of it's ability to copy and convert data types, byte per byte, is shown if used in a similar way to cat with input from the keys, using the convert to upper case option. The first line is typed in, then CtrlD to see the conversion and summary:

dd conv=ucase
dd test text
DD TEST TEXT
0+1 records in
0+1 records out
13 bytes (13 B) copied, 12.63 s, 0.0 kB/s 

Quakeboy echos my thoughts exactly. “I used to be able to do "dd if=xxx.iso of=/dev/sr0”

Me too.

What is all that above about?

I always wrote ISO files direct to cd/dvd devices before also - reflecting Quakeboy02's comment in the second forum.

I wish people would not make such authorative statements when they are obviously from the GUI only linux generation and don't know what used to happen before possible “changes” have been made to change the historical behaviour of well established commands like dd.

However, I don't know why this is happening myself right now, unless there has been a change in linux systems code, or the lead in code on blank manufactured DVD media.

I am using blank Imation DVDs, new out the box, and after the lack of sensible solutions from google, I experimented a bit and found that I could get DD to write as above, if I blanked the unused DVD first with Brasero. Why?

First, lets see what's happening.

A new blank DVD shows as blank and mounted on insertion to my laptop writer:

Using:

stevee@AMDA8 ~ $ dvd+rw-mediainfo /dev/sr0

INQUIRY: [hp ][DVDRW SU208FB ][HH01]

GET [CURRENT] CONFIGURATION:

Mounted Media: 1Ah, DVD+RW

Current Write Speed: 4.0x1385=5540KB/s

Write Speed #0: 4.0x1385=5540KB/s

Write Speed #1: 2.0x1385=2770KB/s

GET [CURRENT] PERFORMANCE:

Write Performance: 3.3x1385=4570KB/s@[0 -> 458751]

4.0x1385=5540KB/s@[458752 -> 2295103]

Speed Descriptor#0: 00/2295103 R@8.0x1385=11080KB/s W@4.0x1385=5540KB/s

Speed Descriptor#1: 00/2295103 R@8.0x1385=11080KB/s W@2.4x1385=3324KB/s

READ DVD STRUCTURE[#0h]:

Media Book Type: 00h, DVD-ROM book [revision 0]

Media ID: MBIPG101/W04

Legacy lead-out at: 2295104*2KB=4700372992

READ DISC INFORMATION:

Disc status: blank

Number of Sessions: 1

State of Last Session: empty

"Next" Track: 1

Number of Tracks: 1

READ FORMAT CAPACITIES:

unformatted: 2295104*2048=4700372992

26h(0): 2295104*2048=4700372992

READ TRACK INFORMATION[#1]:

Track State: invisible incremental

Track Start Address: 0*2KB

Free Blocks: 2295104*2KB

Track Size: 2295104*2KB

READ CAPACITY: 0*2048=0

It seems that this new blank drive is truly readable but not directly writeable out of the box as it is unformatted. So if you DO use Brasero/other first to “REBLANK” a blank cd, it magically becomes useable to DD with the standard command format:

On re-insertion the DVD shows exactly as before in the GUI, but:

stevee@AMDA8 ~ $ dvd+rw-mediainfo /dev/sr0

INQUIRY: [hp ][DVDRW SU208FB ][HH01]

GET [CURRENT] CONFIGURATION:

Mounted Media: 1Ah, DVD+RW

Media ID: MBIPG101/W04

Current Write Speed: 4.0x1385=5540KB/s

Write Speed #0: 4.0x1385=5540KB/s

Write Speed #1: 2.0x1385=2770KB/s

GET [CURRENT] PERFORMANCE:

Write Performance: 3.3x1385=4570KB/s@[0 -> 458751]

4.0x1385=5540KB/s@[458752 -> 2295103]

Speed Descriptor#0: 00/2295103 R@8.0x1385=11080KB/s W@4.0x1385=5540KB/s

Speed Descriptor#1: 00/2295103 R@8.0x1385=11080KB/s W@2.4x1385=3324KB/s

READ DVD STRUCTURE[#0h]:

Media Book Type: 00h, DVD-ROM book [revision 0]

Legacy lead-out at: 2295104*2KB=4700372992

READ DISC INFORMATION:

Disc status: complete

Number of Sessions: 1

State of Last Session: complete

Number of Tracks: 1

BG Format Status: suspended

READ FORMAT CAPACITIES:

formatted: 2295104*2048=4700372992

26h(0): 2295104*2048=4700372992

READ TRACK INFORMATION[#1]:

Track State: complete incremental

Track Start Address: 0*2KB

Free Blocks: 0*2KB

Track Size: 2295104*2KB

FABRICATED TOC:

Track#1 : 14@0

Track#AA : 17@2295104

Multi-session Info: #1@0

READ CAPACITY: 2295104*2048=4700372992

The disc is now formatted! The sector (track) sizes are also shown as DVD standard size of 2048 bytes, or 2KB. (1KB = 1024 bytes; 1000 bytes = kB). This size is for user data - the sectors are actually a bit larger - 2,418 bytes - for overhead management data.

2,048 bytes:
For example, a 4.7 GB DVD+R disc: 2,048 bytes/sector x 2,295,104 sectors = 4,700,372,992 bytes. This rounds to roughly 4.7 GB (decimal notation) = 4.7 thousand, million bytes. 

If you want more info on "Advanced Format" current and legacy drive byte sizes, see:

https://en.wikipedia.org/wiki/Advanced_Format

https://en.wikipedia.org/wiki/DVD

So, for the benefit of the GUI only generation, what do you do for a headless server/cmd line only situation?

With a new blank DVD/RW inserted again, here's the proof it shows as “free space: 0 bytes”, and trying to use DD to write an ISO fails as before:

 

dd if=/home/stevee/750GB/MintDownloads/linuxmint-17.2-cinnamon-64bit.iso of=/dev/sr0

dd: writing to ‘/dev/sr0’: No space left on device

1+0 records in

0+0 records out

0 bytes (0 B) copied, 0.035723 s, 0.0 kB/s

This is a new, unused DVD/RW saying it has “no space left” because it is unformatted as discovered above.

So what command line tool can you use to prepare it? You can try:

wodim blank=all

Device was not specified. Trying to find an appropriate drive...

Detected CD-R drive: /dev/sr0

Using /dev/cdrom of unknown capabilities

Device type : Removable CD-ROM

Version : 5

Response Format: 2

Capabilities :

Vendor_info : 'hp '

Identification : 'DVDRW SU208FB '

Revision : 'HH01'

Device seems to be: Generic mmc2 DVD-R/DVD-RW.

Using generic SCSI-3/mmc DVD-R(W) driver (mmc_mdvd).

Driver flags : SWABAUDIO BURNFREE

Supported modes: PACKET SAO

Speed set to 5540 KB/s

Starting to write CD/DVD at speed 4.0 in real BLANK mode for single session.

Last chance to quit, starting real write in 0 seconds. Operation starts.

Error: this media does not support blanking, ignoring.

This drive or media does not support the 'BLANK media' command

wodim: Cannot blank disk, aborting.

Try to force it:

$ sudo wodim -format

Device was not specified. Trying to find an appropriate drive...

Detected CD-R drive: /dev/sr0

Using /dev/cdrom of unknown capabilities

Device type : Removable CD-ROM

Version : 5

Response Format: 2

Capabilities :

Vendor_info : 'hp '

Identification : 'DVDRW SU208FB '

Revision : 'HH01'

Device seems to be: Generic mmc2 DVD-R/DVD-RW.

Using generic SCSI-3/mmc DVD-R(W) driver (mmc_mdvd).

Driver flags : SWABAUDIO BURNFREE

Supported modes: PACKET SAO

Speed set to 5540 KB/s

Starting to write CD/DVD at speed 4.0 in real FORMAT mode for single session.

Last chance to quit, starting real write in 0 seconds. Operation starts.

wodim: media format asked

format_mdvd: media is unformated.

scsi_format: preparing

scsi_format: running

scsi_format: post processing 0

Formating in progress: 0.37 % done [244].

Looking good...

scsi_format: post processing 0
Formating in progress: 100.00 % done.

However, this still doesn't allow wodim blank=all to prepare the disk for writing in terms of lead in/out etc. probably:

This drive or media does not support the 'BLANK media' command
wodim: Cannot blank disk, aborting.

Ok, so wodim won't work.

So, according to the guy above who said "dd is not meant for this task..use growisofs..." - what does growisofs use as part of it's file conversion operation to write to the new iso file system it creates? DD! It just seems to add the capability of writing ISO9660 lead ins and outs...

growisofs -dvd-compat -Z /dev/sr0=/home/stevee/750GB/MintDownloads/linuxmint-17.2-cinnamon-64bit.iso

Executing 'builtin_dd if=/home/stevee/750GB/MintDownloads/linuxmint-17.2-cinnamon-64bit.iso of=/dev/sr0 obs=32k seek=0'
/dev/sr0: pre-formatting blank DVD+RW...

1619034112/1631322112 (99.2%) @4.0x, remaining 0:03 RBU 36.6% UBU 96.9%
builtin_dd: 796544*2KB out @ average 2.9x1352KBps
/dev/sr0: flushing cache
/dev/sr0: writing lead-out
/dev/sr0: reloading tray

Once the DVD is formatted, dd writes the ISO as I remember it always did. I must have always had pre-formatted disks before, maybe as Quakeboy did, so never had to think about this. Now using dd as ever before:

dd if=Downloads/Win7/Win7_64.iso of=/dev/sr0

96+1 records in

97+0 records out

3254779904 bytes (3.3 GB) copied, 729.118 s, 4.5 MB/s

Once ejected and re-inserted, the successful write is verified:

So much for "getting a coaster" or "'dd' is mostly meant for low-level data manipulation. It is probably best known for accidentally or deliberately wiping disks"
....learn your subject first and do your research, Trolls and dick heads..!

It seems to be just a question of formatting and/or preparing a medium - and what program can do it for you before a write can occur.

Any medium - disk, CD or pen stick - has to be formatted first for the associated electronics to register and set it up for "software controlled ordered data use" in the first place else how can it work? See my later Post on encapsulation if you don't see why.:

http://www.stevepedwards.com/DebianAdmin/encapsulation-from-bits-to-gigabytes-in-200-years-2/

GUI folk probably just don't see or realise this happening first during an overall software burn.

I guess some CDs/DVDs come preformatted out the box, some don't. Simple as that. Comparing details before and after for the earlier operation:

READ DISC INFORMATION:

Disc status: blank

Number of Sessions: 1

State of Last Session: empty

unformatted: 2295104*2048=4700372992

Track State: invisible incremental

compared to:

READ DISC INFORMATION:

Disc status: complete

Number of Sessions: 1

State of Last Session: complete

formatted: 2295104*2048=4700372992

Track State: complete incremental

Note that a completely low level unformatted (no zeros or ones) hard drive or mem card would also cause any App to act similarly as the DD failure above for the same reasons - the device's control electronics cannot initialise the device for data transfer to a specific system either! Again, these disk type devices come at least low level formatted from the manufacturer else they would not work either! If you have been around long enough, you may remember older BIOS options to low level format a hard drive if required...but they still require an MBR to point to the blank sectors, same as a formatted DVD needs a lead in, else it's just a collection of orderless, meaningless zeroes stored on a device...get it?? These are then ordered more specifically with a "format" of some sort, to suit the system they will communicate with...encapsulation to a set of protocols...usually a file system.

You have the options for formatting them to a particular file system if you TAB mkfs:

$ mkfs
mkfs mkfs.ext3 mkfs.hfs mkfs.msdos mkfs.xfs
mkfs.bfs mkfs.ext4 mkfs.hfsplus mkfs.ntfs
mkfs.cramfs mkfs.ext4dev mkfs.jfs mkfs.reiserfs
mkfs.ext2 mkfs.fat mkfs.minix mkfs.vfat

No ISO file systems appear here for CDs/DVDs which is why you need ISO specific formatting tools like mkisofs or growisofs.

So, this Post has shown DD's behaviour difference between some new optical DVD media (with different format capabilities; write speed and storage size; DVD + or - etc.) and hard drives/other media that don't usually have to be pre-formatted (i.e. are already "low level formatted" by the manufacturer or are already formatted with a file system like NTFS, EXT4 etc.).

Also explore testing optimum bs values for your specific kit:

dd if=/dev/zero of=/dev/null count=10 bs=512

10+0 records in
10+0 records out
5120 bytes (5.1 kB) copied, 0.000462209 s, 11.1 MB/s

See the DD Post for more info:

http://www.stevepedwards.com/DebianAdmin/cool-command-1-dd-progress/

BUT BEWARE!! If for example, you created a backup image from a 8GB SDcard say, with dd at it's default bs of 512k, then tried to re-write that image back to an 8GB SDcard later at a faster speed using an "optimum" but larger bs of say bs=2M, then you may find the operation fails as the image won't now fit on the drive due to the much larger sector sizes you have tried to write! 

If in doubt use it for both image creation AND re-write, especially if the drive/media is the "same size" as the image, as there is no overflow space if required, and the minimum 512k sector size won't waste space for many small files.

Better to wait many hours writing a massive backup image that works after, than a few less hours for one that doesn't!

Again, read the encapsulation Post to understand why. DD's default bs=512k for a good reason;

4 x 512k blocks fit into a 2048k DVD sector, and 8 x 512k blocks fit into a 4096k ext4 file system sector. Any larger bs sizes will waste media sector space with empty data, as you only get 1 block per sector written instead of 4 or 8, but it's generally quicker IF you do have the media overflow space available.

http://www.stevepedwards.com/DebianAdmin/encapsulation-from-bits-to-gigabytes-in-200-years-2/

Comments are closed.

Post Navigation