dd制作启动U盘

1 Introduction

使用dd命令跨平台制作系统启动U盘,正式开始之前可以自行理解下dd和cp命令的区别

2 Requirements

需要准备如下:

  • 你当前使用的OS:Linux/MacOS
  • 一个容量大小足够的U盘
  • 操作系统镜像ios(具体是什么系统无需关系)

3 Production

已当前使用的系统为MacOS为例:

  1. 首先找到插入的U盘:
$ sudo diskutil list
/dev/disk0 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         500.3 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         500.0 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +500.0 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            200.3 GB   disk1s1
   2:                APFS Volume Preboot                 43.3 MB    disk1s2
   3:                APFS Volume Recovery                518.3 MB   disk1s3
   4:                APFS Volume VM                      5.8 GB     disk1s4

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *32.2 GB    disk2
   1:             Windows_FAT_32 Windows USB             32.2 GB    disk2s1

如上/dev/disk2即为插入的U盘

  1. 卸载分区:
$ diskutil unmountdisk /dev/disk2s1
Unmount of all volumes on disk2 was successful
  1. 格式化(可选):
$ sudo diskutil eraseDisk FAT32 WINDOWS MBRFormat /dev/disk2
Started erase on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk2s1 as MS-DOS (FAT32) with name WINDOWS
newfs_msdos: warning: sectors/FAT limits sectors to 62945248, clusters to 1966078
512 bytes per physical sector
/dev/rdisk2s1: 62914496 sectors in 1966078 FAT32 clusters (16384 bytes/cluster)
bps=512 spc=32 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2048 drv=0x80 bsec=62945248 bspf=15360 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk2

如上WINDOWS是Volume的Name,必须全部大些,然后进行dd之前需要再一次unmount

  1. dd:
$ sudo dd bs=1m if=~/Downloads/cn_windows_10_enterprise_ltsc_2019_x64_dvd_9c09ff24.iso of=/dev/disk2

根据实际情况替换上述ios镜像

  1. 同步:
$ sudo sync

进行上述操作的主要原因是可能存在数据写入缓存,还没有实际写入磁盘的情况

Linux的上述操作如下:

unmount /dev/disk2s1
mkfs.fat32 /dev/disk2
dd bs=1m if=~/Downloads/cn_windows_10_enterprise_ltsc_2019_x64_dvd_9c09ff24.iso of=/dev/disk2
sync

4 References

https://superuser.com/questions/527657/how-do-you-format-a-2-gb-sd-card-to-fat32-preferably-with-disk-utility
http://www.xbatu.com/node/258
https://rollingstarky.github.io/2018/05/14/create-startup-disk-using-dd/
https://blog.csdn.net/menogen/article/details/38059671

Tags:

Categories:

Updated: