Day: January 25, 2026

  • 如何升級EC2 上的MacOS? How to upgrade MacOS on AWS EC2

    參考官方文件就可以了 – https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mac-instance-updates.html

    過於陳舊的MacOS 需要升級ENA driver,但通常不會有這種情況,因為使用MacOS 主要是用於iOS 開發和迅速迭代,沒有人會用五年前的Mac 來寫code,因為你要支持最新的iPhone 就必須要用最新的MacOS。而且,不是所有的版本都支持升級,支持的版本請參考該頁面說明。

    使用SSH 連結到 EC2 並為ec2-user 設置一個密碼:

    sudo /usr/bin/dscl . -passwd /Users/ec2-user

    為了Enable the secure token for the ec2-user user,必須修改一次密碼,修改的動作並不是為了修改密碼,而是為了Enable the secure token。

    vi old_password.txt
    
    vi new_password.txt
    
    sysadminctl -oldPassword `cat old_password.txt` -newPassword `cat new_password.txt`
    
    2026-01-21 06:53:17.708 sysadminctl[705:6829] Attempting to change password for ec2-user…
    2026-01-21 06:53:19.287 sysadminctl[705:6829] SecKeychainCopyLogin returned -25294
    2026-01-21 06:53:19.287 sysadminctl[705:6829] Failed to update keychain password (-25294)
    2026-01-21 06:53:19.288 sysadminctl[705:6829] - Done

    確認一下真的啟用了:

    sysadminctl -secureTokenStatus ec2-user
    
    2026-01-21 06:58:35.755 sysadminctl[806:8689] Secure token is ENABLED for user ec2-user

    創建一個json 文件用於Delegate ownership of the Amazon EBS root volume to the EBS root volume administrative user,這是因為在 Apple Silicon Mac (Mac2, Mac2-m2, Mac-m4 等)上,系統更新需要特定的管理權限,當你要進行 macOS 系統更新時,需要先將 EBS根磁碟區的所有權從內部磁碟管理員(aws-managed-user)委派給 EBS 根磁碟區管理使用者(通常是 ec2-user)。

    vi mac-credentials.json
    
    {
      "internalDiskPassword":"",
      "rootVolumeUsername":"ec2-user",
      "rootVolumepassword":"newPasswordHere"
    }
    
    aws ec2 create-delegate-mac-volume-ownership-task \
    --instance-id i-079180f283a7b0baf \
    --mac-credentials file://mac-credentials.json
    
    {
        "MacModificationTask": {
            "InstanceId": "i-079180f283a7b0baf",
            "MacModificationTaskId": "macmodification-05b40255b8b15176c",
            "MacSystemIntegrityProtectionConfig": {},
            "StartTime": "2026-01-21T08:09:43.417000+00:00",
            "TaskState": "pending",
            "TaskType": "volume-ownership-delegation"
        }
    }
    
    aws ec2 describe-mac-modification-tasks \
    --mac-modification-task-id macmodification-05b40255b8b15176c
    
    {
        "MacModificationTasks": [
            {
                "InstanceId": "i-079180f283a7b0baf",
                "MacModificationTaskId": "macmodification-05b40255b8b15176c",
                "MacSystemIntegrityProtectionConfig": {},
                "StartTime": "2026-01-21T08:09:43.417000+00:00",
                "Tags": [],
                "TaskState": "in-progress",
                "TaskType": "volume-ownership-delegation"
            }
        ]
    }

    上面一般需要30~90 分鐘,我是用了四十幾分鐘,

    login after rebooted:
    
        ┌───┬──┐   __|  __|_  )
        │ ╷╭╯╷ │   _|  (     /
        │  └╮  │  ___|\___|___|
        │ ╰─┼╯ │  Amazon EC2
        └───┴──┘  macOS Sequoia 15.7.3
    
    
    softwareupdate --list
    Software Update Tool
    
    Finding available software
    Software Update found the following new or updated software:
    * Label: macOS Tahoe 26.2-25C56
        Title: macOS Tahoe 26.2, Version: 26.2, Size: 8111826KiB, Recommended: YES, Action: restart, 
    
    sudo softwareupdate --install --all --restart
    Software Update Tool
    
    Finding available software
    Downloading macOS Tahoe 26.2
    Password: 
    Downloading: 62.47%
    Downloading: 93.73%
    Downloading: 100.00%
    Downloaded: macOS Tahoe 26.2
    Restarting...
    
    
        ┌───┬──┐   __|  __|_  )
        │ ╷╭╯╷ │   _|  (     /
        │  └╮  │  ___|\___|___|
        │ ╰─┼╯ │  Amazon EC2
        └───┴──┘  macOS Tahoe 26.2