ubuntu 制作 U盘启动盘(Centos的镜像) ---一行命命令制作u盘启动盘 (dd命令)

版权声明:本文为博主原创文章,未经允许不得转载! https://blog.csdn.net/weixin_41919236/article/details/84941755

在这里插入图片描述

一行命令命令制作u盘启动盘-----在ubuntu笔记本

两部;第一部,下载:apt install pv;第二部执行命令:pv -cN source < CentOS-7-x86_64-Minimal-1804.iso | dd of=/dev/sdc

root@hadoop:/home/hairui/centos&.iso# apt install pv
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
下列软件包是自动安装的并且现在不需要了:
  fonts-horai-umefont fonts-unfonts-core gnome-exe-thumbnailer libgif7:i386
  libgsf-1-114 libgsf-1-common libice6:i386 libmsi0
  libp11-kit-gnome-keyring:i386 libsm6:i386 libxt6:i386
  linux-headers-4.13.0-45 linux-headers-4.13.0-45-generic
  linux-headers-4.15.0-24 linux-headers-4.15.0-24-generic
  linux-headers-4.15.0-36 linux-headers-4.15.0-36-generic
  linux-image-4.13.0-45-generic linux-image-4.15.0-24-generic
  linux-image-4.15.0-36-generic linux-image-extra-4.13.0-45-generic
  linux-modules-4.15.0-24-generic linux-modules-4.15.0-36-generic
  linux-modules-extra-4.15.0-24-generic linux-modules-extra-4.15.0-36-generic
  linux-signed-image-4.13.0-45-generic msitools ocl-icd-libopencl1:i386
  odbcinst odbcinst1debian2 p11-kit-modules:i386 p7zip ttf-wqy-microhei
  unixodbc wine-gecko2.21 wine-gecko2.21:i386 wine-mono0.0.8 winetricks
使用'sudo apt autoremove'来卸载它(它们)。
下列【新】软件包将被安装:
  pv
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 47 个软件包未被升级。
需要下载 46.8 kB 的归档。
解压缩后会消耗 170 kB 的额外空间。
获取:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial/universe amd64 pv amd64 1.6.0-1 [46.8 kB]
已下载 46.8 kB,耗时 0秒 (67.6 kB/s)
正在选中未选择的软件包 pv。
(正在读取数据库 ... 系统当前共安装有 407804 个文件和目录。)
正准备解包 .../archives/pv_1.6.0-1_amd64.deb  ...
正在解包 pv (1.6.0-1) ...
正在处理用于 man-db (2.7.5-1) 的触发器 ...
正在设置 pv (1.6.0-1) ...
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# pv -cN source < Cent
Centos1-s001.vmdk                 Centos1-s006.vmdk
Centos1-s002.vmdk                 Centos1.vmdk
Centos1-s003.vmdk                 Centos1.vmx
Centos1-s004.vmdk                 CentOS-7-x86_64-Minimal-1804.iso
Centos1-s005.vmdk                 

pv -cN source < CentOS-7-x86_64-Minimal-1804.iso | dd of=/dev/sdc    
备注:一行命令制作u盘启动盘

制作过程

root@hadoop:/home/hairui/centos&.iso# pv -cN source < CentOS-7-x86_64-Minimal-1804.iso | dd of=/dev/sdc
   source:  906MiB 0:02:09 [7.01MiB/s] [=====================>] 100%            
记录了1855488+0 的读入
记录了1855488+0 的写出
950009856 bytes (950 MB, 906 MiB) copied, 129.168 s, 7.4 MB/s

root@hadoop:/home/hairui/centos&.iso# df -h
文件系统        容量  已用  可用 已用% 挂载点
udev            3.4G     0  3.4G    0% /dev
tmpfs           693M   18M  675M    3% /run
/dev/sdb2       451G  151G  278G   36% /
tmpfs           3.4G   46M  3.4G    2% /dev/shm
tmpfs           5.0M  4.0K  5.0M    1% /run/lock
tmpfs           3.4G     0  3.4G    0% /sys/fs/cgroup
/dev/sda1       511M  4.7M  507M    1% /boot/efi
cgmfs           100K     0  100K    0% /run/cgmanager/fs
tmpfs           693M  124K  692M    1% /run/user/1000
/dev/sdc1       906M  906M     0  100% /media/hairui/CentOS 7 x86_64
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# 


=========================================================

把制作好的u盘启动盘恢复

dd if=/dev/zero of=/dev/sdc bs=512 count=1   
这行命令很重要

root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# dd if=/dev/zero of=/dev/sdc bs=512 count=1
记录了1+0 的读入
记录了1+0 的写出
512 bytes copied, 0.00273168 s, 187 kB/s
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   0 465.8G  0 disk 
├─sdb2   8:18   0 458.3G  0 part /
├─sdb3   8:19   0     7G  0 part [SWAP]
└─sdb1   8:17   0   512M  0 part 
sdc      8:32   1  14.3G  0 disk 
├─sdc2   8:34   1   8.8M  0 part 
└─sdc1   8:33   1   906M  0 part /media/hairui/CentOS 7 x86_64
sda      8:0    0 111.8G  0 disk 
├─sda2   8:2    0 104.4G  0 part 
├─sda3   8:3    0     7G  0 part 
└─sda1   8:1    0   512M  0 part /boot/efi
root@hadoop:/home/hairui/centos&.iso# mkfs.ext4
mkfs.ext4     mkfs.ext4dev  
root@hadoop:/home/hairui/centos&.iso# mkfs.ext4 -f /dev/sd
sda   sda1  sda2  sda3  sdb   sdb1  sdb2  sdb3  sdc   sdc1  sdc2  
root@hadoop:/home/hairui/centos&.iso# mkfs.ext4 -f /dev/sd
sda   sda1  sda2  sda3  sdb   sdb1  sdb2  sdb3  sdc   sdc1  sdc2  
root@hadoop:/home/hairui/centos&.iso# mkfs.ext4 -f /dev/sdc
sdc   sdc1  sdc2  
root@hadoop:/home/hairui/centos&.iso# mkfs.ext4 -f /dev/sdc
sdc   sdc1  sdc2  
root@hadoop:/home/hairui/centos&.iso# fdisk  /dev/sdc

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

/dev/sdc: device contains a valid 'iso9660' signature; it is strongly recommended to wipe the device with wipefs(8) if this is unexpected, in order to avoid possible collisions

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x95ffb65f.

命令(输入 m 获取帮助): p
Disk /dev/sdc: 14.3 GiB, 15376318464 bytes, 30031872 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x95ffb65f

命令(输入 m 获取帮助): q

root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# umount /dev
/dev            /dev/hugepages  /dev/mqueue     /dev/pts        /dev/sda1       /dev/sdb2       /dev/sdc1       /dev/shm
root@hadoop:/home/hairui/centos&.iso# umount /dev
/dev            /dev/hugepages  /dev/mqueue     /dev/pts        /dev/sda1       /dev/sdb2       /dev/sdc1       /dev/shm
root@hadoop:/home/hairui/centos&.iso# umount /dev/sd
/dev/sda1  /dev/sdb2  /dev/sdc1  
root@hadoop:/home/hairui/centos&.iso# umount /dev/sd
/dev/sda1  /dev/sdb2  /dev/sdc1  
root@hadoop:/home/hairui/centos&.iso# umount /dev/sdc1 
root@hadoop:/home/hairui/centos&.iso# df
文件系统           1K-块      已用      可用 已用% 挂载点
udev             3513664         0   3513664    0% /dev
tmpfs             708708     18112    690596    3% /run
/dev/sdb2      472897784 157834684 291018200   36% /
tmpfs            3543528     46896   3496632    2% /dev/shm
tmpfs               5120         4      5116    1% /run/lock
tmpfs            3543528         0   3543528    0% /sys/fs/cgroup
/dev/sda1         523248      4740    518508    1% /boot/efi
cgmfs                100         0       100    0% /run/cgmanager/fs
tmpfs             708708       124    708584    1% /run/user/1000
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# fdisk  /dev/sdc

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

/dev/sdc: device contains a valid 'iso9660' signature; it is strongly recommended to wipe the device with wipefs(8) if this is unexpected, in order to avoid possible collisions

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xe8a51ff8.

命令(输入 m 获取帮助): p
Disk /dev/sdc: 14.3 GiB, 15376318464 bytes, 30031872 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe8a51ff8

命令(输入 m 获取帮助): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
分区号 (1-4, default 1): 
First sector (2048-30031871, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-30031871, default 30031871): 

Created a new partition 1 of type 'Linux' and of size 14.3 GiB.

命令(输入 m 获取帮助): 


命令(输入 m 获取帮助): 


命令(输入 m 获取帮助): 


命令(输入 m 获取帮助): 


命令(输入 m 获取帮助): p

Disk /dev/sdc: 14.3 GiB, 15376318464 bytes, 30031872 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe8a51ff8

设备       启动 Start   末尾   扇区  Size Id 类型
/dev/sdc1        2048 30031871 30029824 14.3G 83 Linux

命令(输入 m 获取帮助): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# 
root@hadoop:/home/hairui/centos&.iso# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   0 465.8G  0 disk 
├─sdb2   8:18   0 458.3G  0 part /
├─sdb3   8:19   0     7G  0 part [SWAP]
└─sdb1   8:17   0   512M  0 part 
sdc      8:32   1  14.3G  0 disk 
└─sdc1   8:33   1  14.3G  0 part 
sda      8:0    0 111.8G  0 disk 
├─sda2   8:2    0 104.4G  0 part 
├─sda3   8:3    0     7G  0 part 
└─sda1   8:1    0   512M  0 part /boot/efi
root@hadoop:/home/hairui/centos&.iso# mkfs.ext4 -f /dev/sdc1 
mkfs.ext4:无效选项 -- f
Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-C cluster-size]
	[-i bytes-per-inode] [-I inode-size] [-J journal-options]
	[-G flex-group-size] [-N number-of-inodes]
	[-m reserved-blocks-percentage] [-o creator-os]
	[-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
	[-O feature[,...]] [-r fs-revision] [-E extended-option[,...]]
	[-t fs-type] [-T usage-type ] [-U UUID] [-jnqvDFKSV] device [blocks-count]
root@hadoop:/home/hairui/centos&.iso# mkfs.ext4  /dev/sdc1 
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 3753728 4k blocks and 940240 inodes
Filesystem UUID: df84ad54-2270-4222-aafc-0f9e7c732811
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成   

root@hadoop:/home/hairui/centos&.iso# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   0 465.8G  0 disk 
├─sdb2   8:18   0 458.3G  0 part /
├─sdb3   8:19   0     7G  0 part [SWAP]
└─sdb1   8:17   0   512M  0 part 
sdc      8:32   1  14.3G  0 disk 
└─sdc1   8:33   1  14.3G  0 part /media/hairui/CentOS 7 x86_64
sda      8:0    0 111.8G  0 disk 
├─sda2   8:2    0 104.4G  0 part 
├─sda3   8:3    0     7G  0 part 
└─sda1   8:1    0   512M  0 part /boot/efi
root@hadoop:/home/hairui/centos&.iso# df -h
文件系统        容量  已用  可用 已用% 挂载点
udev            3.4G     0  3.4G    0% /dev
tmpfs           693M   18M  675M    3% /run
/dev/sdb2       451G  151G  278G   36% /
tmpfs           3.4G   47M  3.4G    2% /dev/shm
tmpfs           5.0M  4.0K  5.0M    1% /run/lock
tmpfs           3.4G     0  3.4G    0% /sys/fs/cgroup
/dev/sda1       511M  4.7M  507M    1% /boot/efi
cgmfs           100K     0  100K    0% /run/cgmanager/fs
tmpfs           693M  124K  692M    1% /run/user/1000
/dev/sdc1        14G   36M   14G    1% /media/hairui/CentOS 7 x86_64
root@hadoop:/home/hairui/centos&.iso# 


猜你喜欢

转载自blog.csdn.net/weixin_41919236/article/details/84941755
今日推荐