定制centos之rootfs

如何定制化自己的centos?下面来讲解一下,怎么制作rootfs

 

1    Create RPM database

[root@localhost ~]# mkdir –p /home/arron/centos

[root@localhost ~]# cd /home/arron/centos

[root@localhost centos]# mkdir rootfs

[root@localhost centos]# mkdir -p rootfs/var/lib/rpm

[root@localhost centos]# rpm --root /home/arron/centos/rootfs/ --initdb

 

  1.     Download and install centos-release package

rpm -ivh --nodeps --root /home/arron/centos/rootfs/ http://vault.centos.org/7.4.1708/os/x86_64/Packages/centos-release-7-4.1708.el7.centos.x86_64.rpm

 

The rootfs like this:

[root@localhost centos]# ls rootfs/

etc/ usr/ var/

[root@localhost centos]# ls rootfs/etc/

centos-release      redhat-release      yum/

issue               rpm/                yum.repos.d/

issue.net           system-release 

pki/                system-release-cpe

 

  1.     Install yum

yum --installroot=/home/arron/centos/rootfs install yum --nogpgcheck

 

  1.     Copy the configure

[root@localhost centos]#cp -L /etc/resolv.conf ./rootfs/etc/resolv.conf

[root@localhost centos]#cp –r /etc/yum.repos.d/ /home/arron/centos/rootfs/etc/

 

  1.     Mounting the necessary directories

[root@localhost centos]# mount --bind /dev ./rootfs/dev

[root@localhost centos]# mount -t proc /proc ./rootfs/proc

[root@localhost centos]# mount -t sysfs /sys ./rootfs/sys

 

Refer to this link:

https://raw.githubusercontent.com/psachin/bash_scripts/master/ch-mount.sh

 

  1.     Run chroot

[root@localhost centos]# chroot ./rootfs /bin/bash

 

Refer to this link:

 

https://linux.cn/article-8310-1.html

 

http://ask.xmodulo.com/enable-elrepo-repository.html

 

  1.     Change root password

bash-4.2# yum install net-tools

bash-4.2# yum install passwd

bash-4.2# passwd

passwd: unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 is not authorized to change the password of root

 

  1.     Copy .bash*  scripts to root directory

bash-4.2# cp -v /etc/skel/.bash* /root/

bash-4.2# exit

 下一篇build kernel

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值