手动制造报错_制作U盘自动和手动安装的ISO文件

在我们平时的工作中,偶尔需要装个系统什么的,一般会有通过网络PEX安装或者cobbler安装的,但是万一没网呢?那这时候就需要一个U盘来拯救你啦。

首先我们说一下思路:

(1)选择一个文件夹,把本机上的光盘文件全部拷贝进去(注意别丢了隐藏文件哟)

(2)用sys-config-kickstart命令制作应答文件

(3)修改isolinux下面的isolinux.cfg启动菜单配置

(4)重新创建ISO的元数据

(5)打包那个文件做成

(6)用isohybrid转换一下格式,用于U盘启动

实验过程:

1、复制文件并查看一下[root@centos6 ~]# pwd

/root

[root@centos6 ~]# cp -r /misc/cd    /root/app/centos6

[root@centos6 ~]# cd app/centos6/;ls -a

.                EFI     isolinux                  RPM-GPG-KEY-CentOS-6           TRANS.TBL

..               EULA    Packages                  RPM-GPG-KEY-CentOS-Debug-6     .treeinfo

CentOS_BuildTag  GPL     RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Security-6

.discinfo        p_w_picpaths  repodata                  RPM-GPG-KEY-CentOS-Testing-6

[root@centos6 centos6]#

2、在主机上用system-config-kickstart制作一个应该文件,这里的步骤和平时手动安装的内容一样,只是展现的形式不同而已,自己一项一项的选择好自己需要的配置点击左上角File里面的save保存到/root/app/centos6下即可,保存位置有图形界面可以自己选择,这里我就不一一截图了 (如果愿意深入了解kickstart的用法可以看一下一位网友的博客:http://blog.csdn.net/taiyang1987912/article/details/42176709  或者这一个网络连接: http://jingyan.baidu.com/article/5d368d1eedc8ac3f60c057e1.html   )

a3a15c9c2c69de08d99cd1109ad2f0f7.png

3、修改引导菜单文件,直接保存会报错,记得用强行保存[root@centos6 centos6]# ls

centos6.cfg      GPL       RELEASE-NOTES-en-US.html    RPM-GPG-KEY-CentOS-Security-6

CentOS_BuildTag  p_w_picpaths    repodata                    RPM-GPG-KEY-CentOS-Testing-6

EFI              isolinux  RPM-GPG-KEY-CentOS-6        TRANS.TBL

EULA             Packages  RPM-GPG-KEY-CentOS-Debug-6

[root@centos6 centos6]# vim isolinux/i

initrd.img    isolinux.bin  isolinux.cfg

[root@centos6 centos6]# vim isolinux/isolinux.cfg

default vesamenu.c32

#prompt 1

timeout 600

display boot.msg

menu background splash.jpg

menu title Welcome to CentOS 6.9!

menu color border 0 #ffffffff #00000000

menu color sel 7 #ffffffff #ff000000

menu color title 0 #ffffffff #00000000

menu color tabmsg 0 #ffffffff #00000000

menu color unsel 0 #ffffffff #00000000

menu color hotsel 0 #ff000000 #ffffffff

menu color hotkey 7 #ffffffff #ff000000

menu color scrollbar 0 #ffffffff #00000000

label Desktop

menu label ^Automatic Desktop Install

menu default

kernel vmlinuz

append initrd=initrd.img ks=cdrom:/centos6.cfg

label man

menu label ^Manual ^Install

kernel vmlinuz

append initrd=initrd.img

label local

menu label Boot from ^local drive

localboot 0xffff

4、查看一下复制过来的iso文件的元数据,并删除了重新生成一次,因为之前的不能用[root@centos6 centos6]# ls  /root/app/centos6/repodata/

1cde788f77b08a7eb3dfdba12fa384a5f0214147a717a1e2d4504368037fba90-c6-x86_64-comps.xml.gz

43d8fd068164b0f042845474d6a22262798b9f0d1f49ad1bf9f95b953089777d-c6-x86_64-comps.xml

594889376c2452dc8178bbaed982deba4dff38a42716ac03fc84576c17b1d79b-filelists.sqlite.bz2

92299bd89d0ef9e4030e78d31399a96b41712239f032d0092f2345ba5cb01404-other.xml.gz

9f2ef5087547b18bdccc798b0cad7456047fc69ca17db69d3159b6dd84ed1c11-primary.xml.gz

ad73b7fa76bb45feea7e4cdb2d896279524039545e8764ceaa515665f897a0c5-primary.sqlite.bz2

dc8a406c3cc1c5103ff2e22a1b9d3d0d09a13a6fda831ffecebdd55484bf5146-filelists.xml.gz

f18d3f35ab887f27a5acc563138bd58a0c9b668e8cd79dbb32c4fc610c88e320-other.sqlite.bz2

repomd.xml

TRANS.TBL

[root@centos6 centos6]# cp   /root/app/centos6/repodata/43d8fd068164b0f042845474d6a22262798b9f0d1f49ad1bf9f95b953089777d-c6-x86_64-comps.xml   /root/

[root@centos6 centos6]# rm -rf /root/app/centos6/repodata/*

[root@centos6 centos6]# ls /root/app/centos6/repodata/

[root@centos6 centos6]# createrepo -g /root/43d8fd068164b0f042845474d6a22262798b9f0d1f49ad1bf9f95b953089777d-c6-x86_64-comps.xml  /root/app/centos6/

Spawning worker 0 with 3240 pkgs

Workers Finished

Gathering worker results

Saving Primary metadata

Saving file lists metadata

Saving other metadata

Generating sqlite DBs

Sqlite DBs complete

[root@centos6 centos6]# ls /root/app/centos6/repodata/

1cde788f77b08a7eb3dfdba12fa384a5f0214147a717a1e2d4504368037fba90-c6-x86_64-comps.xml.gz

43d8fd068164b0f042845474d6a22262798b9f0d1f49ad1bf9f95b953089777d-c6-x86_64-comps.xml

5113e542b34891f5f6dd037f23cf2948c9014fbc852a8f7eec41f0323e2ae271-filelists.sqlite.bz2

6311d0e7a1fdcd08b425d8874500482c3910ed5ce921fa6e29dd9d5ab4418b28-filelists.xml.gz

8ddb832924451aebf1f64376f4e35bd7f3a48896b3f2b82e18346095afdaba07-primary.xml.gz

b97e8f350c99ed991f87e748a98cf1c2b6fb17e8ce3fb27d578e8bb4fbb51f00-other.sqlite.bz2

e91391eb5ceb40d428c81767ea369dc3c37b10bed9d382f482054e58f4b53359-other.xml.gz

fd29a4c1ae16874afec555e620fa18f3573951aacc776bbd569186ccf0d77193-primary.sqlite.bz2

repomd.xml

[root@centos6 centos6]#

5、把刚刚做的软件包封装成一个iso文件[root@centos6 centos6]# mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "Centos 6.9 x86_64 boot" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/centos6.iso  /root/app/centos6

…………

99.19% done, estimate finish Sat Jun 24 10:12:43 2017

99.45% done, estimate finish Sat Jun 24 10:12:43 2017

99.71% done, estimate finish Sat Jun 24 10:12:43 2017

99.96% done, estimate finish Sat Jun 24 10:12:43 2017

Total translation table size: 821601

Total rockridge attributes bytes: 361464

Total directory bytes: 548864

Path table size(bytes): 112

Done with: The File(s)                             Block(s)    1955144

Writing:   Ending Padblock                         Start Block 1955630

Done with: Ending Padblock                         Block(s)    150

Max brk space used 362000

1955780 extents written (3819 MB)

6、做成的ISO文件就已经可以直接使用,如图,就可以直接安装完成。

0e0d1d59638937d5fd5bdbd5c6c5eb07.png

1979d0571a491d911648d77fe5e1c606.png

ee42c131fa9d5809f4878c218d7d4bcd.png

303fcbc51d8c9f8244fc0fc943c86541.png

6、需要做给U盘使用的话转换一下就ok[root@centos6 ~]# isohybrid /root/centos6.iso

isohybrid: Warning: more than 1024 cylinders: 3820

isohybrid: Not all BIOSes will be able to boot this device

[root@centos6 ~]# lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT

sr0     11:0    1   3.7G  0 rom  /media/CentOS_6.9_Final

sda      8:0    0   200G  0 disk

├─sda1   8:1    0  1000M  0 part /boot

├─sda2   8:2    0  97.7G  0 part /

├─sda3   8:3    0  48.8G  0 part /app

├─sda4   8:4    0     1K  0 part

├─sda5   8:5    0     1G  0 part

├─sda6   8:6    0     2G  0 part [SWAP]

└─sda7   8:7    0 203.9M  0 part

sdb      8:16   1    30G  0 disk

└─sdb1   8:17   1    30G  0 part

[root@centos6 ~]# mount /dev/sdb1 /mnt/

mount: you must specify the filesystem type

[root@centos6 ~]# mkfs.ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

1970416 inodes, 7872472 blocks

393623 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

241 block groups

32768 blocks per group, 32768 fragments per group

8176 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@centos6 ~]# dd if=/root/centos6.iso of=/dev/sdb1

7823360+0 records in

7823360+0 records out

4005560320 bytes (4.0 GB) copied, 448.366 s, 8.9 MB/s

7823360+0 records in

7823360+0 records out

4005560320 bytes (4.0 GB) copied, 448.366 s, 8.9 MB/s

附件:

制作的应答文件centos6.cfg#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use network installation

cdrom

# Root password

rootpw --plaintext magedu

# System authorization information

auth  --useshadow  --passalgo=sha512

# Use graphical install

text

reboot

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --disabled

# Do not configure the X Window System

skipx

# Installation logging level

logging --level=info

# System timezone

timezone Asia/Shanghai

# Network information

network  --bootproto=dhcp --device=eth0 --onboot=on

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all

# Disk partitioning information

part /boot --fstype="ext4" --size=500

part / --fstype="ext4" --size=50000

part swap --fstype="swap" --size=4096

part /app --fstype="ext4" --size=20000

%post

useradd wang

echo magedu |passwd --stdin wang

rm -rf /etc/yum.repos.d/*

cat > /etc/yum.repos.d/base.repo <

[base]

name=base

baseurl=http://172.16.0.1/centos/6

gpgcheck=0

EOF

%end

%packages

@core

@server-policy

@workstation-policy

%end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值