MacOS: shrink Boot Camp partition : Différence entre versions

De La Mouche VII
(Page créée avec « Catégorie:Côté obscur '''Use case:''' You have a Macintosh with macOS and Windows in dual boot, thanks to the [https://en.wikipedia.org/wiki/Boot_Camp_(software) A... »)
 
m (typo)
Ligne 5 : Ligne 5 :
 
utility. You made the Windows partition too big and want to shrink it. This is
 
utility. You made the Windows partition too big and want to shrink it. This is
 
not officially supported by Apple: you're supposed to delete the Windows
 
not officially supported by Apple: you're supposed to delete the Windows
partition and réinstall it. This was not acceptable, so here is how I did it.
+
partition and reinstall it. This was not acceptable, so here is how I did it.
  
 
= Initial partition table =
 
= Initial partition table =

Version du 7 septembre 2017 à 00:00


Use case: You have a Macintosh with macOS and Windows in dual boot, thanks to the Apple Boot Camp utility. You made the Windows partition too big and want to shrink it. This is not officially supported by Apple: you're supposed to delete the Windows partition and reinstall it. This was not acceptable, so here is how I did it.

Initial partition table

Here's how the 500 GB disk was set up initially:

  • disk0s1 : EFI boot (~200 MB)
  • disk0s2 : macOS main partition ("Macintosh HD") (HFS+, ~364 GB)
  • disk0s3 : macOS Recovery (650 MB)
  • disk0s4 : Windows partition ("BOOTCAMP") (NTFS, ~135 GB with about 75 GB free)

Take care to adapt the commands in this article to use the correct device names! diskutil list is your friend.

Step 0: backups!

Backup important files from the Windows partition; in macOS, manually start a TimeMachine backup.

Now is also the time to ask yourself if you really want to mess with all this ;-)

Step 1: shrink and move the Windows partition

The goal here is to shrink the Windows partition and move it at the very end of the disk. You have to do this from Windows, as the Mac utilities won't work on NTFS file systems.

I used MiniTool Partition Manager (free version), as the Windows disk utility would shrink the partition but not move it. Besides, MiniTool was able to shrink the partition more than the Windows tool could (I was able to free 65 GB when the Windows tool woulnd't give me more than 53 GB or so), although to be safe I would recommend sticking with the Windows tool for shrinking (I did get some errors upon rebooting after shrinking the partition with MiniTool, that I was able to fix).

So use the Windows tool to shrink the partition, then MiniTool to move it at the end of the disk.

Step 2: macOS is wrong!

Reboot to macOS and open the Disk Utility. It should not recognize the new Windows partition size (if it does you probably don't need to keep reading this). Same problem with the command-line tool (diskutil list disk0), the BOOTCAMP partition will show the old size.

Reboot on Recovery (Command + R at the chime), open a terminal, and run a manual disk verify; it should detect a problem. Then run a disk repair (it will warn you that disk0s1, that is the EFI boot partition, could be deleted, so to be safe you can back it up on an external hard drive with dd):

diskutil verifyDisk disk0
dd bs=4m if=/dev/disk0s1 of=/Volumes/ExternalHD/disk0s1.dd # change with your HD's name
diskutil repairDisk disk0

This actually creates a new partition (disk0s5) with the right size, but the old one is still there and both have the same UUID. You can see that with the following commands:

diskutil list disk0
diskutil info disk0s4
diskutil info disk0s5

The old partition should disappear after rebooting (see next step).

Step 3: try growing the macOS partition

Reboot to macOS (not Recovery). In the terminal, diskutil list should now show only one BOOTCAMP partition as disk0s4, with the correct size. Launch Disk Utility and extend the macOS partition. (Note that the Disk Utility doesn't show the Recovery partition, don't worry about it.) You can check the result once again with diskutil list.

This went wrong for me. Possibly because I did it from the Recovery; or maybe it fails in any case because the the Recovery partition is in the way of growing the macOS partition. Anyway, if your partition has been extended successfuly and you still have a Recovery partition, then have a nice day. Otherwise, keep reading.

Step 4: delete the Recovery partition

In my case, after running diskutil repairDisk like above, diskutil list showed the old size for the macOS partition, and the Recovery partition now used up all of the space freed from the Windows partition (in my case, I believe it showed as being 73 GB or so, which doesn't quite make sense to me).

So I had to delete the Recovery partition, extend the macOS partition (step 5), then recreate the Recovery partition with a third-party tool as this is (once again) not something Apple thinks you should mess with (step 6).

So let's delete that Recovery prtition. You may be able to do it in the Disk Utility if you enabled the Debug menu, but it's just as easy with the command line (make sure disk0s3 is your Recovery partition before running this!):

diskutil eraseVolume "Free Space" %noformat% disk0s3

Step 5: actually grow the macOS partition

I then resized the macOS partition, using up all of the free space after it. I used the command-line, but the Disk Utility would have worked just as well, most likely:

diskutil resizeVolume disk0s2 R

Step 6: re-create the Recovery partition

Thankfully, somebody wrote a tool to create a Recovery partition, called Recovery Partition Creator, and other people documented the procedure:

  • Start the App Store, go to the “Purchased” tab, and download the macOS Installer for your macOS version (it will end up in your Applications folder).
  • Then run Recovery Partition Creator and follow the instructions.

Then you can make sure the Recovery partition is back with diskutil list, and you can reboot to Recovery to try it out.


That's all there was to it, really…