467
edits
No edit summary |
|||
Line 2: | Line 2: | ||
== Create a loop device == | == Create a loop device == | ||
Similar to losetup for Linux, this allows setting up a {{iw|wikipedia|loop device}} for any file. Usually hdiutil tries to determine how to attach the file based on the file extension and contents. | Similar to losetup for Linux, this allows setting up a {{iw|wikipedia|loop device}} for any file. Usually hdiutil tries to determine how to attach the file based on the file extension and contents, so we need to force it to assume a raw disk with <code>-imagekey diskimage-class=CRawDiskImage</code>. | ||
<pre> | <pre> | ||
hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount myfile.bin | hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount myfile.bin | ||
Line 15: | Line 15: | ||
</pre> | </pre> | ||
After attaching it can be formatted with any tool, such as diskutil, Disk Utility, or newfs_*. | After attaching it can be formatted with any tool, such as diskutil, Disk Utility, or newfs_*. | ||
{| class="wikitable" | |||
|+ Table of common sizes for quick access | |||
! Disk size | |||
! In bytes | |||
! In sectors | |||
! hdiutil command | |||
|- | |||
| 1 GiB | |||
| 1073741824 | |||
| 2097152 | |||
| <code>hdiutil attach -nomount ram://2097152</code> | |||
|- | |||
| 2 GiB | |||
| 2147483648 | |||
| 4194304 | |||
| <code>hdiutil attach -nomount ram://4194304</code> | |||
|- | |||
| 3 GiB | |||
| 3221225472 | |||
| 6291456 | |||
| <code>hdiutil attach -nomount ram://6291456</code> | |||
|- | |||
| 4 GiB | |||
| 4294967296 | |||
| 8388608 | |||
| <code>hdiutil attach -nomount ram://8388608</code> | |||
|- | |||
| 5 GiB | |||
| 5368709120 | |||
| 10485760 | |||
| <code>hdiutil attach -nomount ram://10485760</code> | |||
|- | |||
| 6 GiB | |||
| 6442450944 | |||
| 12582912 | |||
| <code>hdiutil attach -nomount ram://12582912</code> | |||
|- | |||
| 7 GiB | |||
| 7516192768 | |||
| 14680064 | |||
| <code>hdiutil attach -nomount ram://14680064</code> | |||
|- | |||
| 8 GiB | |||
| 8589934592 | |||
| 16777216 | |||
| <code>hdiutil attach -nomount ram://16777216</code> | |||
|} | |||
== <tt>create -srcfolder</tt> doesn't preserve creation time == | == <tt>create -srcfolder</tt> doesn't preserve creation time == |