mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-13 22:30:37 +08:00
commit
8b0fc607d5
@ -1,127 +0,0 @@
|
||||
[#]: subject: "How to Use the dd Command to Create a Live USB Drive in Linux Terminal [For Experts and Adventurers]"
|
||||
[#]: via: "https://itsfoss.com/live-usb-with-dd-command/"
|
||||
[#]: author: "Hunter Wittenborn https://itsfoss.com/author/hunter/"
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "perfiffer"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
How to Use the dd Command to Create a Live USB Drive in Linux Terminal [For Experts and Adventurers]
|
||||
======
|
||||
|
||||
There are several graphical tools available for creating live USB. [Etcher on Linux][1] is probably the most popular. Ubuntu has its own Startup Disk Creator tool for this purpose.
|
||||
|
||||
However, advanced Linux users swear by the comfort and swiftness of creating live USBs in Linux terminal using the dd command.
|
||||
|
||||
The dd command is a [CLI tool][2] that gives you powerful features for copying and converting files.
|
||||
|
||||
A common use case that people use dd for is to write ISO files to an external storage device such as a USB drive, which can be used to do things like install a new Linux distribution onto a computer or laptop.
|
||||
|
||||
That’s what I am going to show in this tutorial. I’ll go over the commands you will need to run, finding our USB drive from the terminal, and then finally doing the actual flashing of the ISO file.
|
||||
|
||||
### Creating live USB from ISO with dd command
|
||||
|
||||
Before I show you the steps, let me quickly go over the command which you’ll be using and explain what it does.
|
||||
|
||||
Here’s the example command for flashing of the ISO:
|
||||
|
||||
```
|
||||
dd if="./filename.iso" of="/dev/sdb" status="progress" conv="fsync"
|
||||
```
|
||||
|
||||
Let’s go over what exactly that [dd command][3] is doing.
|
||||
|
||||
#### Understanding the above dd command
|
||||
|
||||
![Explanation of the dd command for live USB creation][4]
|
||||
|
||||
First, you enter `dd`. As expected, this is just the name of the program you are going to run.
|
||||
|
||||
Next, you specify `if="./filename.iso"`. `if` stands for input file, which tells `dd` what file you are going to be writing to the external storage drive.
|
||||
|
||||
After that, you enter `of="/dev/sdb"`. As was with `if`, `of` simply stands for output file.
|
||||
|
||||
The thing to remember is that the output file doesn’t technically have to be a file on your system. You can also specify things like the path to an external device (as shown in the example), which just **looks** like a normal file on your system, but actually points to a device connected to your machine.
|
||||
|
||||
`status` can be set to three options: `none`, `noxfer` and `progress.`
|
||||
|
||||
The `progress` option that you set will cause dd to show periodic statistics on how much of the ISO has been transferred to the storage drive, as well as an estimation on how much longer it will be until dd is finished.
|
||||
|
||||
If you were to have set the `none` option instead, dd would only print error messages during the writing of the ISO, thus removing things like the progress bar.
|
||||
|
||||
The `noxfer` option hides some information that’s printed after a transfer is complete, such as how long it took from start to finish.
|
||||
|
||||
Lastly, you set the `conv` option to `fsync`. This causes dd to not report a successful write until the entire ISO has been written to the USB drive.
|
||||
|
||||
If you omit this option, dd will still write just fine (and might actually appear to run quicker), but you might find your system taking quite a while before it tells you it’s safe to remove the USB drive as it will finish writing the ISO’s content in the background, thus allowing you to do other things in the meantime.
|
||||
|
||||
_**Now that you understand what you have to do, let’s see how to do it.**_
|
||||
|
||||
Warning
|
||||
|
||||
The command line is a double-edged sword. Be extra careful when you are running a command like dd. You must make sure that you are using the correct device for the output file destination. One wrong step and you may format your main system disk and lose your operating system.
|
||||
|
||||
#### Step 0: Download the desired ISO
|
||||
|
||||
This goes without saying that you need to have an ISO image file in order to flash it on a USB.
|
||||
|
||||
I am going to use Ubuntu 20.04 ISO (downloadable [here][5]) to test the dd command I showed earlier.
|
||||
|
||||
#### Step 1: Get the USB disk label
|
||||
|
||||
Plug in your USB disk.
|
||||
|
||||
The specific path I entered for `of` was `/dev/sdb`. The USB disks are usually labelled /dev/sdb but that’s not a hard and fast rule.
|
||||
|
||||
This path may differ on your system, but you can confirm the path of the drive with the `lsblk` command. Just look for a listing that looks like the size of your USB drive, and that’ll be it.
|
||||
|
||||
![][6]
|
||||
|
||||
If you are more comfortable with GUI programs, you can also find the drive’s path with tools like GNOME Disks.
|
||||
|
||||
![][7]
|
||||
|
||||
Now that you have established the path to our external drive, let’s create the live USB.
|
||||
|
||||
#### Step 2: Writing the ISO file to the USB disk
|
||||
|
||||
Open up a terminal at the directory where the ISO file is downloaded, and run the following (remember to replace `/dev/sdb` with the name of your storage device if it’s something different):
|
||||
|
||||
```
|
||||
sudo dd if="./ubuntu-20.04.2.0-desktop-amd64.iso" of="/dev/sdb" status="progress" conv="fsync"
|
||||
```
|
||||
|
||||
After that, just let dd do it’s thing, and it’ll print a completion message once it’s done:
|
||||
|
||||
![][8]
|
||||
|
||||
And just like that, you’ve flashed an ISO with dd command in the Linux terminal!
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
Now you’re on your way to doing even more things through the terminal, allowing you to do things faster and quicker than you might have been able to do before.
|
||||
|
||||
Got any remaining questions about the dd command, or something just not working right? Feel free to leave any of it in the comment section below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/live-usb-with-dd-command/
|
||||
|
||||
作者:[Hunter Wittenborn][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/hunter/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/install-etcher-linux/
|
||||
[2]: https://itsfoss.com/gui-cli-tui/
|
||||
[3]: https://linuxhandbook.com/dd-command/
|
||||
[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/dd-command-for-live-usb-creation.png?resize=800%2C450&ssl=1
|
||||
[5]: https://ubuntu.com/download/desktop/thank-you?version=20.04.2.0&architecture=amd64
|
||||
[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/dd_disks.png?resize=753%2C264&ssl=1
|
||||
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/dd_gnome_disks.png?resize=800%2C440&ssl=1
|
||||
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/dd-iso-write.png?resize=800%2C322&ssl=1
|
@ -0,0 +1,126 @@
|
||||
[#]: subject: "How to Use the dd Command to Create a Live USB Drive in Linux Terminal [For Experts and Adventurers]"
|
||||
[#]: via: "https://itsfoss.com/live-usb-with-dd-command/"
|
||||
[#]: author: "Hunter Wittenborn https://itsfoss.com/author/hunter/"
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "perfiffer"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
怎样在 Linux 终端下使用 dd 命令创建一个 Live USB 驱动器 [针对专家和冒险者]
|
||||
======
|
||||
|
||||
有很多的图形化工具可以用来创建 live USB 驱动器。Linux 上的 [Etcher][1] 可能是最受欢迎的。为此,Ubuntu 开发了自己的启动盘创建工具。
|
||||
|
||||
但是,高级 Linux 用户可能更喜欢使用 dd 命令在 Linux 终端中创建 live USB,这会更快速便捷。
|
||||
|
||||
dd 命令是一个 [客户端][2] 工具,提供了强大的功能用来复制和转换文件。
|
||||
|
||||
一个普通的使用示例,用户使用 dd 命令向他们的外部存储设备(例如 USB 驱动盘)写入 ISO 文件,用来给他们的电脑或者笔记本安装一个 Linux 发型版。
|
||||
|
||||
这就是我将在本教程中展示的内容。我将带你认识需要的命令,从终端找到我们的 USB 驱动器,然后对 ISO 文件进行实际刷写。
|
||||
|
||||
### 使用 dd 命令从 ISO 镜像创建 live USB
|
||||
|
||||
在我向你展示步骤前,让我带你快速过一下你将要使用到的命令并解释它的作用。
|
||||
|
||||
这是一个使用命令刷写 ISO 的例子:
|
||||
|
||||
```
|
||||
dd if="./filename.iso" of="/dev/sdb" status="progress" conv="fsync"
|
||||
```
|
||||
|
||||
让我们来看看 [dd 命令][3] 实际都做了些什么。
|
||||
|
||||
#### 理解 dd 命令
|
||||
|
||||
![Explanation of the dd command for live USB creation][4]
|
||||
|
||||
首先,你输入 `dd`。没错,这就是你要运行的程序的名称。
|
||||
|
||||
接下来,你指定 `if="./filename.iso"`。`if` 代表 input file,告诉 `dd` 命令你将要向外部存储设备写入哪个文件。
|
||||
|
||||
之后,你输入 `of="/dev/sdb"`。和 `if` 一样,`of` 代表的是 output file。
|
||||
|
||||
要记住的是,输出文件在技术上不必是系统上的文件。你还可以指定诸如外部设备路径之类的内容(如示例所示),它看起来像系统上的普通文件,但实际上指向连接到你机器的设备。
|
||||
|
||||
`status` 可以设定为 3 个选项:`none`、`noxfer` 和 `progress`。
|
||||
|
||||
你设置的 `progress` 选项将使 `dd` 任务显示有关已将多少 ISO 文件传输到存储驱动器的定期统计信息,以及对 `dd` 任务完成前需要多长时间的估计。
|
||||
|
||||
如果你改为设置 `none` 选项,`dd` 任务只会在写入 ISO 文件期间打印错误消息,并且删除进度条之类的内容。
|
||||
|
||||
`noxfer` 选项隐藏了传输完成后打印的一些信息,例如从开始到完成所用的时间。
|
||||
|
||||
最后,你将 `conv` 选项设置为 `fsync`。这会导致 `dd` 任务在整个 ISO 文件写入 USB 驱动器之前不会报告成功写入。
|
||||
|
||||
如果你省略这个选项,`dd` 任务会工作的很好(并且实际上可能看起来运行得更快),但你可能会发现你的系统需要很长时间才能告诉你移除 USB 驱动器是安全的,因为它会在后台完成 ISO 的内容写入,从而允许你在此期间做其它事情。
|
||||
|
||||
现在你明白了你必须做什么,让我们看看如何去做。
|
||||
|
||||
注意事项
|
||||
|
||||
命令行是把双刃剑。当你在命令行使用类似于 `dd` 命令时必须十分小心。你必须确保你输入文件写入的地方是正确的设备。一个错误的步骤就可能会格式化你的系统硬盘,你的操作系统也会因此而损坏。
|
||||
|
||||
#### 第一步: 下载所需的 ISO 镜像
|
||||
|
||||
不用说,你需要有一个 ISO 镜像文件才能将其刷写到 USB 上。
|
||||
|
||||
我将使用 Ubuntu 20.04 ISO (可在此处下载[5]) 来测试我之前介绍的 `dd` 命令。
|
||||
|
||||
#### 第二步: 获取 USB 盘符
|
||||
|
||||
插入你的 USB 磁盘
|
||||
|
||||
我为 `of` 参数输入的具体路径是 `/dev/sdb`。USB 磁盘通常会标记为 /dev/sdb,但这不是硬性规定。
|
||||
|
||||
此路径可能因你的系统而异,你可以使用 `lsblk` 命令确认 USB 磁盘的路径。只需从列表中查找一个看起来像你的 USB 磁盘大小的驱动器,就可以了。
|
||||
|
||||
![][6]
|
||||
|
||||
如果你更熟悉 GUI 程序,还可以使用 GNOME Disks 等工具找到驱动器的路径。
|
||||
|
||||
![][7]
|
||||
|
||||
现在你已经确认了外部驱动器的路径,让我们开始创建 live USB。
|
||||
|
||||
#### 第三步:将 ISO 文件写入 USB 磁盘
|
||||
|
||||
在下载 ISO 文件的目录打开一个终端,然后运行以下命令(如果 `/dev/sdb` 与你的存储设备名称不同,请记住将其替换):
|
||||
|
||||
```
|
||||
sudo dd if="./ubuntu-20.04.2.0-desktop-amd64.iso" of="/dev/sdb" status="progress" conv="fsync"
|
||||
```
|
||||
之后,让 `dd` 去做剩下的事情,它会在完成后打印一条完成消息:
|
||||
|
||||
![][8]
|
||||
|
||||
就像这样,你已经在 Linux 终端中使用 `dd` 命令刷写了 ISO 文件!
|
||||
|
||||
### 总结
|
||||
|
||||
现在,你可以通过终端做更多的事情,让你的工作效率大大提高。
|
||||
|
||||
对 `dd` 命令有任何剩余的问题,或者无法正常工作?请随时在下面的评论部分中留下你的问题。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/live-usb-with-dd-command/
|
||||
|
||||
作者:[Hunter Wittenborn][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[perfiffer](https://github.com/perfiffer)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/hunter/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/install-etcher-linux/
|
||||
[2]: https://itsfoss.com/gui-cli-tui/
|
||||
[3]: https://linuxhandbook.com/dd-command/
|
||||
[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/dd-command-for-live-usb-creation.png?resize=800%2C450&ssl=1
|
||||
[5]: https://ubuntu.com/download/desktop/thank-you?version=20.04.2.0&architecture=amd64
|
||||
[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/dd_disks.png?resize=753%2C264&ssl=1
|
||||
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/dd_gnome_disks.png?resize=800%2C440&ssl=1
|
||||
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/dd-iso-write.png?resize=800%2C322&ssl=1
|
Loading…
Reference in New Issue
Block a user