質問

Why if I run the commande below, I don't have 8G partition but 7,9?

diskutil partitionDisk disk2 hfs+ 14 8G hfs+ 15 8G hfs+ 13 8G
Started partitioning on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk2s2 as Mac OS Extended with name 14
Initialized /dev/rdisk2s2 as a 7 GB case-insensitive HFS Plus volume
Mounting disk
Formatting disk2s3 as Mac OS Extended with name 15
Initialized /dev/rdisk2s3 as a 7 GB case-insensitive HFS Plus volume
Mounting disk
Formatting disk2s4 as Mac OS Extended with name 13
Initialized /dev/rdisk2s4 as a 13 GB case-insensitive HFS Plus volume
Mounting disk
Finished partitioning on disk2
/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *30.8 GB    disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS 14                      7.9 GB     disk2s2
   3:                  Apple_HFS 15                      7.9 GB     disk2s3
   4:                  Apple_HFS 13                      14.4 GB    disk2s4

And how to have 3 partitions of 8G and one with the remaining space? I have tried this command but it does not work

diskutil partitionDisk disk2 4 GPT hfs+ 14 8G hfs+ 15 8G hfs+ 13 8G hfs+ Combo 100%
The disk is too small for your request
役に立ちましたか?

解決

Note: I made the assumption you would want the volumes to be journaled. So I used jhfs+ instead of hfs+.

The command you are looking for is given below.

diskutil partitiondisk disk2 jhfs+ 14 15887144s jhfs+ 15 15887144s jhfs+ 13 R

To have 3 partitions of 8G and one with the remaining space, enter the following command.

diskutil partitiondisk disk2 jhfs+ 14 15887144s jhfs+ 15 15887144s jhfs+ 13 15887144s jhfs+ Combo R

Actually, the command you entered reserved exactly 8 GB of space for the 14 and 15 volumes. However, this includes 134,217,728 bytes of free space between each hfs+ formatted partition. These kinds of obscure requirements generally go away when APFS is used.

Here is how I determined the correct value was 15887144s. The sector size is 512 bytes. So 134,217,728 bytes is 262,144 sectors and 8,000,000,000 bytes is 15,625,000 sectors. Add these two values together and you will get 15,887,144 sectors.

The amount of free space, between each partition, can be determined from the output of the command given below. This is how I came up with the value of 262,144 sectors.

gpt -r show /dev/disk2

The sector size can be found by entering the command given below.

diskutil info disk2 | grep "Block Size"

Also, if the output from the gpt -r show /dev/disk2 command shows a Pri GPT table size of 32 sectors, then the sector size is 512 bytes. Otherwise, you can assume a sector size of 4096 bytes.

ライセンス: CC-BY-SA帰属
所属していません apple.stackexchange
scroll top