デバイスのサイズをバイト単位で取得するにはどうすればよいですか?
Mac OS X 10.6 では、これを使用しています:
$ diskutil information /dev/disk0s2
Device Identifier: disk0s2
Device Node: /dev/disk0s2
Part Of Whole: disk0
Device / Media Name: macOSX106
Volume Name: macOSX106
Escaped with Unicode: macOSX106
Mounted: Yes
Mount Point: /
Escaped with Unicode: /
File System: Journaled HFS+
Type: hfs
Name: Mac OS Extended (Journaled)
Journal: Journal size 8192 KB at offset 0x12d000
Owners: Enabled
Partition Type: Apple_HFS
Bootable: Is bootable
Media Type: Generic
Protocol: SATA
SMART Status: Verified
Volume UUID: E2D5E93F-2CCC-3506-8075-79FD232DC63C
Total Size: 40.0 GB (40013180928 Bytes) (exactly 78150744 512-Byte-Blocks)
Volume Free Space: 4.4 GB (4424929280 Bytes) (exactly 8642440 512-Byte-Blocks)
Read-Only Media: No
Read-Only Volume: No
Ejectable: No
Whole: No
Internal: Yes
そしてそれはうまくいきます。しかし、Mac OS X 10.4 では、出力は次のようになります。
$ diskutil info disk0s2
Device Node: /dev/disk1s2
Device Identifier: disk1s2
Mount Point:
Volume Name:
Partition Type: Apple_HFS
Bootable: Not bootable
Media Type: Generic
Protocol: SATA
SMART Status: Not Supported
Total Size: 500.0 MB
Free Space: 0.0 B
Read Only: No
Ejectable: Yes
(40013180928 Bytes) (正確には 78150744 512-Byte-Blocks) のようなものはありません
私の bash スクリプトは diskutil 出力を解析し、合計サイズをバイト単位で抽出し、ddコマンドでディスクの最後の 10 Mb を取得するため、10.4 では機能しません...
別の方法でサイズをバイト単位で取得するにはどうすればよいですか?