Open7

CoreStorageボリュームのサイズを小さくする

itochanitochan

掘り出したMacBook Pro 15-inch Late 2011のHDDが不調なのでSSDに換装したいが換装先のSSDの容量が微妙に少ないので頑張ってCoreStorageボリュームを縮小する。

MacBook Proに入っていたHDD: TOSHIBA MK5065GSXF 500GB
移行先のSSD: EXCERIA SSD-CK480S/N 480GB

itochanitochan

diskutil corestorage resizeVolume なるコマンドでCoreStorageボリュームのリサイズができるようだが、APFS時代となったmacOS Sequoia 15.1.1ではそんなコマンドは存在しない。

% diskutil cs
Usage:  diskutil [quiet] coreStorage|CS <verb> <options>
        where <verb> is as follows:

     list            (Show status of CoreStorage volumes)
     info[rmation]   (Get CoreStorage information by UUID or disk)
     delete          (Delete a CoreStorage logical volume group)
     unlockVolume    (Attach/mount a locked CoreStorage logical volume)

diskutil coreStorage <verb> with no options will provide help on that verb
itochanitochan

昔のインストーラを落としてVMを実行したら古いdiskutilでボリュームのりサイズができるのではないか

createinstallmedia が動作するEl Capitanをダウンロードする
Mac App StoreはApple Silicon Macでは対象外とされ落とせなかったため、ブラウザから落とせる最新のSierra 10.12を落としてみる。
https://support.apple.com/ja-jp/102662

itochanitochan

ダウンロードしたdmgをマウントする
pkgutil を使うことで.pkgの解凍ができる

% mkdir InstallMacOSX
% cd InstallMacOSX
% pkgutil --expand-full '/Volumes/Install OS X/InstallMacOSX.pkg' pkg
% cd pkg/InstallMacOSX.pkg
% cp InstallESD.dmg Payload/Install\ OS\ X\ El\ Capitan.app/Contents/SharedSupport

https://discussions.apple.com/thread/254940087?sortBy=rank

itochanitochan

仮想のHFS+パーティションを作る

% diskutil image create blank -s 16G
% diskutil image attach boot_disk.dmg
/dev/disk4      GUID_partition_scheme
/dev/disk4s1    Apple_APFS
/dev/disk5      Apple_APFS_Container
/dev/disk5s1    Apple_APFS_Volume       /Volumes/untitled
% diskutil eraseDisk JHFS+ Untitled {device}
% diskutil list /dev/disk4
/dev/disk4 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        +16.0 GB    disk4
   1:                        EFI NO NAME                 209.7 MB   disk4s1
   2:                  Apple_HFS Untitled                15.7 GB    disk4s2
itochanitochan

インストールメディアを作成する

% sudo Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath Install\ OS\ X\ El\ Capitan.app --nointeraction
Erasing Disk: 0%... 10%... 20%... 30%...100%...
Copying installer files to disk...
Copy complete.
Making disk bootable...
Copying boot files...
Copy complete.
Done.
itochanitochan

仮想マシンでブートするためdmgをisoにする

% diskutil unmountDisk {disk}
Unmount of all volumes on disk4 was successful
% hdiutil convert ./boot_disk.dmg -format UDTO -o install_macos.iso
Protective Master Boot Record(MBR: 0)を読み込み中…
GPT Header(Primary GPT Header: 1)を読み込み中…
GPT Partition Data(Primary GPT Table: 2)を読み込み中…
(Apple_Free: 3)を読み込み中…
EFI System Partition(C12A7328-F81F-11D2-BA4B-00A0C93EC93B: 4)を読み込み中…
..
Untitled 2(Apple_HFS: 5)を読み込み中…
......................................................................................................................
(Apple_Free: 6)を読み込み中…
GPT Partition Data(Backup GPT Table: 7)を読み込み中…
......................................................................................................................
GPT Header(Backup GPT Header: 8)を読み込み中…
......................................................................................................................
経過時間: 27.255s
速度: 559.8Mバイト/秒
節約率: 0.0%
created: /private/tmp/install_macos.iso.cdr