disklabelの不思議 (2) fictitious
藤原さんから
まず、ddでMBRとラベルをつぶし(dd if=/dev/zero of=/dev/rsd1d bs=512k count=10)、fdisk, disklabel -rで確認します。
それでは、このラベルをon-diskに書いてしまい、disklabel -rで確認してみます。
あぁ、そうでした。label: factitousっていうのをそのままラベルとして書いてしまったので当然on-diskにもその文字列が書き込まれてしまったのですね (sd1はUSBメモリですが、抜き差ししても同じ表示)。
じゃぁ、disklabel -eでlabelを空文字列にしてみると、って試してみたら、on-diskでもin-coreでも空文字列が表示されます。当たり前か。
つまり、disklabelがfictitiousを表示するのはon-diskなラベルが存在しないときだけ、それ以外のときにはon-diskなラベルに書かれたlabelに相当する文字列をそのまま表示する (on-diskにfictitiousって文字列が入っていればそれを表示する)、ということのようです。
利用する上ではdisklabelを書くときにはlabel: fictitiousをそのままにしない (たとえば日付などを入れる) 習慣をつけておくと、後から役に立つかもなぁ、と思いました。
label: fictitiousというコメントをいただいたので試してみました。
っていう行が(これは良きにはからったものだよ)という意味になっているかどうか、つまり本当に、「良きにはからった時」だけに表示されるかが気になるのですが、自分では実はまだ確めたことがないのです。
まず、ddでMBRとラベルをつぶし(dd if=/dev/zero of=/dev/rsd1d bs=512k count=10)、fdisk, disklabel -rで確認します。
eeepc# fdisk sd1 fdisk: primary partition table invalid, no magic in sector 0 fdisk: Cannot determine the number of heads Disk: /dev/rsd1d NetBSD disklabel disk geometry: cylinders: 31, heads: 64, sectors/track: 32 (2048 sectors/cylinder) total sectors: 64000 BIOS disk geometry: cylinders: 31, heads: 64, sectors/track: 32 (2048 sectors/cylinder) total sectors: 64000 Partition table: 0: <UNUSED> 1: <UNUSED> 2: <UNUSED> 3: <UNUSED> Bootselector disabled. No active partition. eeepc#
eeepc# disklabel -r sd1 disklabel: could not read existing label eeepc#たしかにon-diskなラベルはありませんね。では、in-coreラベルを作ってもらい、それを表示してもらいましょう。
eeepc# disklabel sd1 # /dev/rsd1d: type: SCSI disk: ClipDrive label: fictitious flags: removable bytes/sector: 512 sectors/track: 32 tracks/cylinder: 64 sectors/cylinder: 2048 cylinders: 31 total sectors: 64000 rpm: 3600 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: 64000 0 4.2BSD 0 0 0 # (Cyl. 0 - 31*) d: 64000 0 unused 0 0 # (Cyl. 0 - 31*) disklabel: boot block size 0 disklabel: super block size 0 eeepc#おぉ、labelにfictitiousが表示されてます。
それでは、このラベルをon-diskに書いてしまい、disklabel -rで確認してみます。
eeepc# disklabel -i -I sd1 partition> P 4 partitions: # size offset fstype [fsize bsize cpg/sgs] a: 64000 0 4.2BSD 0 0 0 # (Cyl. 0 - 31*) d: 64000 0 unused 0 0 # (Cyl. 0 - 31*) partition> W Label disk [n]? y Label written partition> Q eeepc#
eeepc# disklabel -r sd1 # /dev/rsd1d: type: SCSI disk: ClipDrive label: fictitious flags: removable bytes/sector: 512 sectors/track: 32 tracks/cylinder: 64 sectors/cylinder: 2048 cylinders: 31 total sectors: 64000 rpm: 3600 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: 64000 0 4.2BSD 0 0 0 # (Cyl. 0 - 31*) d: 64000 0 unused 0 0 # (Cyl. 0 - 31*) eeepc#あれ? on-diskラベルでもfictitiousって表示されます。
あぁ、そうでした。label: factitousっていうのをそのままラベルとして書いてしまったので当然on-diskにもその文字列が書き込まれてしまったのですね (sd1はUSBメモリですが、抜き差ししても同じ表示)。
じゃぁ、disklabel -eでlabelを空文字列にしてみると、って試してみたら、on-diskでもin-coreでも空文字列が表示されます。当たり前か。
つまり、disklabelがfictitiousを表示するのはon-diskなラベルが存在しないときだけ、それ以外のときにはon-diskなラベルに書かれたlabelに相当する文字列をそのまま表示する (on-diskにfictitiousって文字列が入っていればそれを表示する)、ということのようです。
利用する上ではdisklabelを書くときにはlabel: fictitiousをそのままにしない (たとえば日付などを入れる) 習慣をつけておくと、後から役に立つかもなぁ、と思いました。
- TB-URL http://www.tokuda.net/diary/0571/tb/
1: makoto fujiwara 2008年04月09日(水) 午後4時25分
その文字をそのままにしておくと、書いてしまう、なんて思っても見ませんでした。良く分りましたね。すごい。というか書くときに ficticious だったら、何か別の文字にしておいてよねって send-br したい気分