Normally in the Disk Utility you need to select a device. Is it possible to create an AFPS volume as an ordinary file in other filesystem? And if so, how would that be done?
2 Answers
You can use the Disk Utility application or a combination of the hdiutil
and diskutil
commands. The files can be either full images (.dmg
) or sparse images (.sparseimage
). You can also create a sparse bundle which is actually a folder (.sparsebundle
) containing files. The sparse bundle can be used, for example, to create a 10 GB APFS drive on a physical partition that is FAT32 formatted. This would allow a person save a file greater than 4 GB on a drive/partition that was physically FAT32 formatted.
Below is an example of where the Disk Utility is used to create a 1 TB FAT32 formatted sparse image.
- Open the Disk Utility application.
- From the menu bar select
File->New Image->Blank Image...
. - Enter the following information, then click on
Save
.
An example of creating a 10 GB APFS sparse bundle is given below.
Note: This sparse bundle folder is created in the FAT32 sparse image from the previous example.
If you have a file that contains a raw image of a disk, you can use the following command in the Terminal:
hdiutil attach -imagekey diskimage-class=CRawDiskImage myimage.raw
If you haven't got an existing image, you can create a new, empty file named myimage.raw
and then attach it without mounting:
hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount myimage.raw
Then you can create APFS volumes on there as you would have a physical disk and mount them. This can be done via the command line with a command such as:
diskutil apfs create disk5 MyNewVolumeName
where disk5
needs to be replaced with the device name, you've received from the attach command earlier.
-
1When creating a new, empty image, the third command above results in: Started APFS operation on disk6 Creating a new empty APFS Container Unmounting Volumes Switching disk6 to APFS Creating APFS Container newfs_apfs: wipefs: Invalid argument Error: -69626: Unable to create a new APFS Container Commented Nov 17, 2019 at 22:40