win11 ubuntu双系统,清除ubuntu。保留win11步骤

发布于 2026年05月06日

要安全地从 M.2 固态硬盘上的 Windows 11 + Ubuntu 双系统中彻底清理 Ubuntu 系统,同时保留 Windows 11 正常启动,请按照以下步骤操作:


⚠️ 重要前提

  • 备份 Ubuntu 中的重要数据(如有需要)。

  • 不要直接格式化整个磁盘,以免误删 Windows 分区。


✅ 操作步骤

一、删除 Ubuntu 分区

  1. 进入 Windows 11

  2. Win + X → 选择“磁盘管理”。

  3. 找到 不属于 Windows 的分区(通常为 ext4、swap、Linux 文件系统类型,无盘符)。

    • 如果你不确定哪些是 Ubuntu 分区,可以查看容量大小和文件系统类型。

二、清理 GRUB 引导项(关键步骤)

Ubuntu 使用 GRUB 引导,即使删除了分区,开机仍可能进入 GRUB 命令行。需清除 EFI 中的 Ubuntu 引导文件:

  1. 挂载 EFI 系统分区

    diskpart
    list volume               # 找到 FAT32 类型、100~500MB 的 EFI 分区
    select volume N           # N 是 EFI 分区编号
    assign letter=G           # 分配盘符(如 G:)
    exit

2.一键清理脚本(复制粘贴即可运行)


# === 管理员 PowerShell 中运行 ===
Write-Host "正在清理 Ubuntu EFI 引导..." -ForegroundColor Cyan

# 1. 确保 G: 是 EFI 分区
$efiPart = Get-Partition | Where-Object Type -eq 'EFI'
if (-not $efiPart.DriveLetter) {
    $efiPart | Set-Partition -NewDriveLetter G
}
Write-Host "EFI 分区已挂载为 G:"

# 2. 清空 ubuntu 目录(robocopy 法)
if (Test-Path G:\EFI\ubuntu) {
    mkdir C:\empty -Force | Out-Null
    robocopy C:\empty "G:\EFI\ubuntu" /mir /r:0 /w:0 | Out-Null
    rmdir "G:\EFI\ubuntu" /q
    Write-Host "✅ 已清除 G:\EFI\ubuntu"
}

# 3. 删除固件中的 Ubuntu 启动项
$bcdItems = bcdedit /enum firmware | Select-String -Pattern "ubuntu|grub" -Context 2
if ($bcdItems) {
    $ids = $bcdItems | ForEach-Object {
        if ($_ -match 'identifier\s+({[^}]+})') { $matches[1] }
    } | Where-Object { $_ }
    foreach ($id in $ids) {
        bcdedit /delete $id /f
        Write-Host "✅ 已删除启动项: $id"
    }
} else {
    Write-Host "⚠️ 未发现 Ubuntu/grub 启动项"
}

# 4. 修复启动
bcdboot C:\Windows /s G: /f UEFI
Write-Host "✅ 启动已修复,请重启电脑。" -ForegroundColor Green

三、扩展 Windows 分区(可选)

  • 在“磁盘管理”中,右键点击 C 盘 → “扩展卷”,将之前删除 Ubuntu 后留下的“未分配”空间合并进 Windows 分区。



评论