how to merge two partitions that one of their size can not be changed?
I have created a linux partition and used it for a while. Now I erased it and I want to add this partition to my macosx partition. However, the partition that includes Macosx says that "The size of this partition cannot be changed.".
Is there any way without losing my data in macosx and merge those 2 partitions?
You can find SS below:
And diskutil list
:
While this type of question has been asked and answered many times here at Ask Different, I have not found a previous question which matched your configuration. So, I might as well post a new answer.
Note: This answer assumes the
Ek
volume does not contain any important data. If so, then post a comment.
-
Boot to macOS Recovery over the Internet or an USB flash drive macOS installer. Once booted to macOS Recovery or a macOS installer, open a Terminal application window.
Note: The Terminal application can be found under "Utilities" on the menu bar.
-
Enter the command shown below. If you are using an older version of macOS Recovery or an older macOS installer, then may need to omit the
internal
argument.diskutil list internal
From the output, determine the identifier for the internal drive. In this answer, the identifier is assumed to be
disk1
. If your internal drive has been assigned a different identifier, then make the appropriate substitutions in the remaining steps. Enter the command below to set thedisk
variable to the identifier of the internal drive.disk=disk1
-
Determine if the MBR partition table may contain undesired partition entries by entering the command given below.
gpt -r show $disk >/dev/null
If you do not get the message show below, then proceed to step 4.
gpt show: disk1: Suspicious MBR at sector 0
Enter the command below to edit the MBR partition table.
fdisk -e /dev/$disk
A message similar to the one shown below will appear. You can ignore this message. (The message means macOS does not include MBR BIOS boot code.)
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
The
fdisk
has entered an interactive input mode. Enter the input show below to remove any undesired partition entries.s 2 0 s 3 0 s 4 0 w y q
-
Enter the commands below to remove the partition encompassing the APFS volume labeled
Ek
.Note: Usually, a
diskutil unmountdisk $disk
command needs to be entered just before using agpt
command that writes to the internal drive.read b x < <(gpt -r show $disk | grep 7C34) diskutil unmountdisk $disk gpt remove -b $b $disk
-
(Optional) There is an
Apple_Boot
type partition which I believe is not needed. You can enter the commands below to remove this partition.read b x < <(gpt -r show $disk | grep 426F) diskutil unmountdisk $disk gpt remove -b $b $disk
-
Change the GUID partition type of FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF to the correct value.
read b s i t < <(gpt -r show $disk | grep FFFF) diskutil unmountdisk $disk gpt remove -b $b $disk diskutil unmountdisk $disk gpt add -i $i -b $b -s $s -t apfs $disk
If you are using an older version of macOS Recovery or an older macOS installer, then you may get the error message shown below when entering the last command shown above.
usage: gpt add [-b lba] [-i index] [-s lba] [-t uuid] device ...
If you get the message shown above, then enter the alternate version shown below.
diskutil unmountdisk $disk gpt add -i $i -b $b -s $s -t 7C3457EF-0000-11AA-AA11-00306543ECAC $disk
-
Restart to macOS.
-
Use the Disk Utility application or enter the command below to reclaim the free space.
diskutil apfs resizecontainer disk0s2 0
Performing this step will also clean up the partition tables if necessary in the following ways
-
Removing any remaining hybrid partitioning from the MBR partition table.
-
Reordering the GPT partition entries in ascending order.
-