debian_用iso文件创建本地apt源

1.将N个debian-506-amd64-DVD-N.iso存放于本地或其他媒介内,本例是放在本机/iso/目录下

2.创建N个挂载点目录

如下:

debian:~#mkdir –r /media/dvd1

debian:~#mkdir –r /media/dvd2

debian:~#mkdir –r /media/dvd3

….

debian:~#mkdir –r /media/dvdN

 

3.挂载iso文件

debian:~#cd /iso

debian:/iso#mount –o loop debian-506-amd64-DVD-1.iso /media/dvd1/

debian:/iso#mount –o loop debian-506-amd64-DVD-2.iso /media/dvd2/

debian:/iso#mount –o loop debian-506-amd64-DVD-3.iso /media/dvd3/

debian:/iso#mount –o loop debian-506-amd64-DVD-N.iso /media/dvdN/

 

4.将旧apt源列表文件做备份,然后更改其内容

debian:/iso#cd /etc/apt/

debian:/etc/apt/#cp sources.list sources.list.bak

debian:/etc/apt/#vim sources.list

 

(在编辑器中仅列入如下内容)

deb file:///media/dvd1/ lenny main contrib non-free

deb-src file:///media/dvd1/ lenny main contrib non-free

deb file:///media/dvd1/ stable main contrib non-free

deb-src file:///media/dvd1/ stable main contrib non-free

 

deb file:///media/dvd2/ lenny main contrib non-free

deb-src file:///media/dvd2/ lenny main contrib non-free

deb file:///media/dvd2/ stable main contrib non-free

deb-src file:///media/dvd2/ stable main contrib non-free

 

deb file:///media/dvd3/ lenny main contrib non-free

deb-src file:///media/dvd3/ lenny main contrib non-free

deb file:///media/dvd3/ stable main contrib non-free

deb-src file:///media/dvd3/ stable main contrib non-free

 

deb file:///media/dvd4/ lenny main contrib non-free

deb-src file:///media/dvd4/ lenny main contrib non-free

deb file:///media/dvd4/ stable main contrib non-free

deb-src file:///media/dvd4/ stable main contrib non-free

。。。

deb file:///media/dvdN/ lenny main contrib non-free

deb-src file:///media/dvdN/ lenny main contrib non-free

deb file:///media/dvdN/ stable main contrib non-free

deb-src file:///media/dvdN/ stable main contrib non-free

 

5.更新目录

debian:/etc/apt/#apt-get update

 

有些报错(fail或error)可能是因为/media/dvdN/dists/下没有相关目录条目,没关系。最后恭喜您可以本地安装大部分(本例为debian 506 ,代号为lenny)的稳定版本软件包啦。

 

延伸:存放如此大容量的iso文件在本地服务器内,浪费存储资源,后续会实现在远程、局域网、移动媒介等设立自己的apt源。移动媒介仅第1、2步略有不同,其他步骤均相同。

相关推荐