Subject: cgd/FFS on raw CDROM/Workaround for 2048 bytes/sector
To: Ignatios Souvatzis <ignatios@cs.uni-bonn.de>
From: Florian Stoehr <netbsd@wolfnode.de>
List: netbsd-users
Date: 02/10/2005 19:00:46
On Thu, 10 Feb 2005, Ignatios Souvatzis wrote:

> On Thu, Feb 10, 2005 at 12:34:01AM +0100, Florian Stoehr wrote:
>> Hi,
>>
>> I'd like to create a vnd with 2048 bytes/sector, consisting of 100
>> sectors/cylinder, 1 track/cylinder and 327 cylinders.
>>
>> The goal is to create a FFS non-ISO CDROM image (thus 2048 bytes/sec).
>>
>> It fails in newfs.
>>
>> Any hints? Is that possible at all (regarding the FFS CDROM).
>
> FFS with block sizes != 512 bytes doesn't currently work, and hasn't in
> the last decade or so.
>
> See PRs 26636, 2404, 3686, 26634, 3790, 3791, 3792, 7668, to name a few.
>
> 	-is
>

Hi,

OK my case corresponds to 26636.

I found a way to reach my initial goal - putting a cgd-encrypted FFS file
system on a raw CDROM.

(Should also work with non-encrypted FFS on CDROM of course).

The steps follow below, perhaps this is useful to someone else also.

This *might* address 26636 also (not sure) since I read in cd(4) that
the 2048-based disklabel of a CD can be changed (changes in-core).

root@irina [~] # dd if=/dev/zero of=image.bin bs=32k count=1k
1024+0 records in
1024+0 records out
33554432 bytes transferred in 0.922 secs (36393093 bytes/sec)
root@irina [~] # vnconfig vnd0 image.bin
root@irina [~] # cgdconfig -V re-enter cgd1 /dev/vnd0d /etc/cgd/image
/dev/vnd0d's passphrase:
re-enter device's passphrase:
root@irina [~] # disklabel -e -I cgd1  # (just enter ":wq" here)
root@irina [~] # newfs cgd1a
/dev/rcgd1a: 32.0MB (65536 sectors) block size 8192, fragment size 1024
         using 4 cylinder groups of 8.00MB, 1024 blks, 1984 inodes.
super-block backups (for fsck -b #) at:
     32, 16416, 32800, 49184,
root@irina [~] # mount /dev/cgd1a /mnt

<<< Add content to /mnt >>>

root@irina [~] # umount /mnt
root@irina [~] # cgdconfig -u cgd1
root@irina [~] # vnconfig -u vnd0
root@irina [~] # cdrecord -v dev=15,1,0 speed=10 image.bin

<<< Eject CD. To read data again, follow these steps: >>>

root@irina [~] # disklabel -e cd0

<<< The "d" slice will have the correct 512-bytes sector count.
Now when editing the disklabel, change the geometry of the header data >>>

# /dev/rcd0d:
type: ATAPI
disk: mydisc
label: fictitious
flags: removable
bytes/sector: 2048  # <<<<---- Change to 512
sectors/track: 100 # <<<<---- Change to 25
tracks/cylinder: 1
sectors/cylinder: 100 # <<<<---- Change to 25
cylinders: 164
total sectors: 16386 # <<<<---- Change to value of slice "d" (=65544)
rpm: 300
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0

4 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
  a:     65544         0     4.2BSD      0     0     0  # (Cyl.      0 - 
655+)
  d:     65544         0    ISO9660       0             # (Cyl.      0 - 
655+)

<<< Now configure the cgd and mount its slice(s) >>>

root@irina [~] # cgdconfig cgd1 /dev/cd0d /etc/cgd/image
/dev/cd0d's passphrase:
root@irina [~] # mount /dev/cgd1a /mnt
root@irina [~] #

-----

Hope this is not doubled information. I didn't find
anything about cgd on CDROM in the FAQ.

-Florian