parted分区命令详解
时间: 2024-08-12 16:09:51 浏览: 98
Parted 是一个强大的磁盘分区工具,它允许用户在 Linux 和其他类 Unix 系统中管理磁盘分区。以下是 parted 命令的一些关键概念和用法:
1. **启动 parted**: 在终端中运行 `sudo parted /dev/sdX`(X 替换为你要操作的硬盘设备),例如 `/dev/sda`,然后输入密码以获取超级用户权限。
2. **查看分区信息**: 进入 parted 后,可以使用 `print` 或 `status` 命令查看当前磁盘的分区情况。
3. **创建新分区**: 使用 `mkpart` (make partition) 命令,例如 `mkpart primary fat32 1MiB 100%` 创建一个主分区,从第一个扇区开始,占满整个磁盘。
4. **调整分区大小**: 如果你想调整分区大小,可以使用 `resize` 命令。例如 `resize /dev/sda1 +100M` 将分区 sda1 增加 100MB。
5. **删除分区**: 删除分区前确保你不再需要它,因为这是不可逆的操作。使用 `rm` 或 `delete` 命令,如 `rm /dev/sda1`。
6. **标记或激活分区**: 分区创建后,通常需要将其标记为活动分区以便引导系统。使用 `set` 命令,例如 `set /dev/sda1 boot on`。
7. **保存更改**: 所有的更改都是临时的,你需要使用 `commit` 或 `quit` 命令保存到硬盘上。`commit` 会永久改变分区,而 `quit` 退出 parted 并提示你是否保存更改。
阅读全文
相关推荐


















