How do I do a raw write to my CD drive
/dev/scd0? I want to write a bootloader (that takes two sectors) directly onto a CD, is this possible?
As CDs are not traditional block devices, writing via dd will likely not result in a usable CD. If you want to write an image to a CD, use the
Alternatively, you can use the graphical
Note also that a different process is used to boot off a CD compared to booting off a block device like a hard disk. Rather than just executing code found in the first sectors of the image, it makes use of a process called the El Torito Bootable CD Specification. In effect there is a table in the CD image that says where to find boot loaders for one or more CPU architectures. The boot loader either exists directly on the CD itself, or inside a floppy disk image. In the latter case, the BIOS emulates a floppy drive backed by that image and boots as normal from there.
If you want to boot Linux from the CD, I would suggest using the ISOLINUX boot loader. A copy of the boot loader can be found in the
If you want to use some other custom boot code, the floppy emulation mode might be an easier choice.
I see a couple of shortcomings with your approach...
Firstly, it is generally impossible to write arbitrary sectors on a CD-ROM - unlike the hard drives, optical media does not support random writes. Think about CD-R disks, opening/closing sessions and other stuff.
Secondly, the procedure of booting from a CD is quite different from booting from a HD - in some cases bootable cdroms use an image of a floppy or emulate a harddisk etc. See El Torito standard for more details
So, to make a bootable CD, I would imagine you need to prepare a bootable ISO image using ISOLINUX or some other boot loader. Burning that ISO to a CDROM using some standard program such as Brasero or K3b would produce a bootable disk.