From 934405dcfcf2125abd434e733055b6d514c9043c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Mon, 23 Aug 2021 11:30:26 +0800 Subject: [PATCH] =?UTF-8?q?post:=E5=A2=9E=E5=8A=A0=E5=9C=A8macOS=E4=B8=8B?= =?UTF-8?q?=E5=88=B6=E4=BD=9CUbuntu=E5=90=AF=E5=8A=A8U=E7=9B=98=E7=9A=84?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/_posts/make-ubuntu-boot-macos.md | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 source/_posts/make-ubuntu-boot-macos.md diff --git a/source/_posts/make-ubuntu-boot-macos.md b/source/_posts/make-ubuntu-boot-macos.md new file mode 100644 index 0000000..f179f2b --- /dev/null +++ b/source/_posts/make-ubuntu-boot-macos.md @@ -0,0 +1,52 @@ +--- +title: 在macOS下制作Ubuntu启动U盘 +tags: + - Linux + - Ubuntu + - macOS + - Boot +categories: + - - DevOps + - 系统管理 +keywords: 'Ubuntu,启动U盘,macOS' +date: 2021-08-23 11:29:14 +--- + +Ubuntu的启动U盘在Windows系统下可以借助UltraISO工具来制作,但是在macOS下,就需要使用一系列的命令来制作了。这里对macOS中制作Ubuntu启动U盘的过程进行一个简要的记录。 + +## 转换Ubuntu镜像 + +首先需要使用`hdiutil`工具将已经下载的Ubuntu镜像(.iso)转换成macOS上常用的DMG镜像(.dmg)。 + +```bash +hdiutil convert -format UDRW -o ubuntu.iso ubuntu-20.04.2.0-desktop-amd64.iso +``` + +其中格式`UDRW`表示转换成一个拥有读写权限的镜像。 + +## 弹出已经挂载的U盘 + +当U盘插入到计算机上的时候,会自动挂载,这时首先需要使用`diskutil`工具卸载。 + +```bash +# 首先查询一下U盘所使用的设备号 +diskutil list +# 假设U盘使用的设备号是/dev/disk2 +diskutil unountDisk /dev/disk2 +``` + +> 卸载U盘以后还需要保持U盘在计算机上插入的状态,不要拔下来。 + +## 复制镜像到U盘 + +复制Ubuntu镜像到U盘所需要的命令是`dd`。这个命令需要使用`if`参数指定输入源,`of`参数指定输出目标。`bs`是缓冲区块大小,一般选择`1m`足以。 + +```bash +sudo dd if=./ubuntu.iso.dmg of=/dev/disk2 bs=1m +``` + +当镜像写入完毕的时候,U盘会自动弹出。 + +## U盘格式化 + +格式化U盘同样使用`diskutil`工具,需要使用其中的`eraseDisk`子命令。这个子命令可以完成磁盘的重新分区。如果只是需要格式化一个分区,可以使用`eraseVolume`子命令。