有了上篇GPXE的启动方法,我们来启动一个Ubuntu来玩:

简单的修改boot2.php即可:

  case '\ec:f4:bb:d9:96:40':
    $ip="172.16.36.2:172.16.37.254:255.255.254.0:myhost-16-36-2";
    $ipa=explode(':',$ip);
    echo "ifopen net0\n";
    echo "set net0/ip $ipa[0]\n";
    echo "set net0/netmask $ipa[2]\n";
    echo "set net0/gateway $ipa[1]\n";
    echo "set net0/dns $dns\n";
    echo "kernel http://172.16.8.1/ks/ubuntu/vmlinuz.efi root=/dev/nfs boot=casper netboot=nfs nfsroot=172.16.11.6:/root/ubuntu ip=172.16.36.2::172.16.37.254:255.255.254.0:renhe-16-36-2:eno1 ro\n";
    echo "initrd http://172.16.8.1/ks/ubuntu/initrd.lz\n";
    echo "boot\n";
    break;

注意:变的就是kernel和init那两行,netboot支持nfs和cifs,不支持http啊,试了半天!另外ip那一行,如果是动态的,ip=dhcp,如果是静态的,格式如下:

ip=客户端ip:服务器端ip:网关:掩码:主机名:网卡

服务器端ip不填,主机名也可以不填。

首先我们要去下个ISO

wget http://mirrors.163.com/ubuntu-releases/16.04/ubuntu-16.04-desktop-amd64.iso  

然后把vmlinuz.efi和initrd.lz弄出来,放到[http://172.16.8.1/ks/ubuntu]目录下

mount -o loop ubuntu-16.04-desktop-amd64.iso /mnt/iso  
cp /mnt/iso/casper/vmlinuz.efi /var/www/html/ks/ubuntu  
cp /mnt/iso/casper/initrd.lz /var/www/html/ks/ubuntu  

然后建立nfs,把iso里的东西都弄到nfs共享里去:

mkdir -p /export/ubuntu  
vi /etc/exports  
/export/ubuntu *(rw,sync,no_subtree_check,fsid=0,no_root_squash)

yum install -y nfs-utils rpcbind  
service nfs start  

ok,启动pxe,就看到桌面了。

comments powered by Disqus