最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Ubuntu下QEMU启动内核时出错:/etc/qemu-ifup: 19: /etc/qemu-ifup: /usr/sbin/openvpn: not found

QEMU crifan 4749浏览 0评论

【问题】

折腾:

【记录】Ubuntu下使用QEMU启动Linux内核

期间,去通过QEMU启动内核,结果出错:

crifan@ubuntu:etc$ sudo /opt/qemu/bin/qemu-system-arm -M versatilepb -nographic -net nic -net tap,ifname=tap0 -kernel /home/crifan/develop/crosscompile/uboot/u-boot-2013.07/u-boot
/sbin/ifdown: interface eth0 not configured
/etc/qemu-ifup: 19: /etc/qemu-ifup: /usr/sbin/openvpn: not found
/etc/qemu-ifup: 24: /etc/qemu-ifup: /usr/sbin/brctl: not found
/etc/qemu-ifup: 25: /etc/qemu-ifup: /usr/sbin/brctl: not found
/etc/qemu-ifup: 26: /etc/qemu-ifup: /usr/sbin/brctl: not found
/etc/qemu-ifup: 30: /etc/qemu-ifup: /usr/sbin/brctl: not found
SIOCSIFADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
SIOCSIFBRDADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCADDRT: Network is unreachable
/etc/qemu-ifup: 39: /etc/qemu-ifup: /sbin/service: not found
/etc/qemu-ifup: could not launch network script
qemu-system-arm: -net tap,ifname=tap0: Device 'tap' could not be initialized

即:

/etc/qemu-ifup: 19: /etc/qemu-ifup: /usr/sbin/openvpn: not found

【解决过程】

1.去确认了普通用户和sudo都有eth0:

crifan@ubuntu:qemu$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:e4:c8:06  
          inet6 addr: fe80::20c:29ff:fee4:c806/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:1019 errors:0 dropped:0 overruns:0 frame:0
          TX packets:579 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:812145 (812.1 KB)  TX bytes:80433 (80.4 KB)
          Interrupt:19 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:195 errors:0 dropped:0 overruns:0 frame:0
          TX packets:195 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:29594 (29.5 KB)  TX bytes:29594 (29.5 KB)

crifan@ubuntu:qemu$ sudo ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:e4:c8:06  
          inet6 addr: fe80::20c:29ff:fee4:c806/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:1019 errors:0 dropped:0 overruns:0 frame:0
          TX packets:579 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:812145 (812.1 KB)  TX bytes:80433 (80.4 KB)
          Interrupt:19 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:195 errors:0 dropped:0 overruns:0 frame:0
          TX packets:195 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:29594 (29.5 KB)  TX bytes:29594 (29.5 KB)

2.然后突然发现:

/usr/sbin/openvpn: not found

很明显,没找到。

所以去看看:

crifan@ubuntu:qemu$ ls /usr/sbin/
aa-status              cupsreject             install-docs           pppd                     update-default-aspell
accept                 cytune                 install-info           pppdump                  update-default-ispell
accessdb               delgroup               install-sgmlcatalog    pppoeconf                update-default-wordlist
acpid                  deluser                invoke-rc.d            pppoe-discovery          update-dictcommon-aspell
addgroup               dmidecode              ip6tables-apply        pppstats                 update-dictcommon-hunspell
add-shell              dnsmasq                iptables-apply         pptp                     update-fonts-alias
adduser                dpkg-divert            irqbalance             pptpsetup                update-fonts-dir
alsactl                dpkg-preconfigure      ispell-autobuildhash   pwck                     update-fonts-scale
anacron                dpkg-reconfigure       kerneloops             pwconv                   update-grub
apparmor_status        dpkg-statoverride      laptop-detect          pwunconv                 update-grub2
aptd                   e2freefrag             ldattach               radeontool               update-grub-gfxpayload
arp                    e4defrag               lightdm                readprofile              update-gsfontmap
arpd                   fdformat               lightdm-session        reject                   update-icon-caches
aspell-autobuildhash   filefrag               locale-gen             remove-default-ispell    update-icon-caches.gtk2
avahi-autoipd          gconf-schemas          logrotate              remove-default-wordlist  update-inetd
avahi-daemon           gnome-menus-blacklist  lpadmin                remove-shell             update-info-dir
avivotool              groupadd               lpc                    rfkill                   update-initramfs
bccmd                  groupdel               lpdomatic              rmt                      update-java-alternatives
biosdecode             groupmod               lpinfo                 rmt-tar                  update-locale
bluetoothd             grpck                  lpmove                 rsyslogd                 update-mime
chat                   grpconv                luksformat             rtcwake                  update-passwd
chgpasswd              grpunconv              make-ssl-cert          rtkitctl                 update-rc.d
chpasswd               grub-bios-setup        mkinitramfs            safe_finger              update-software-center
chroot                 grub-install           mklost+found           saned                    update-usbids
ck-log-system-restart  grub-mkconfig          mksmbpasswd            select-default-ispell    update-xmlcatalog
ck-log-system-start    grub-mkdevicemap       modem-manager          select-default-wordlist  upgrade-from-grub-legacy
ck-log-system-stop     grub-mknetdir          netscsid               service                  usb_modeswitch
console-kit-daemon     grub-probe             NetworkManager         setvesablank             usb_modeswitch_dispatcher
cpgr                   grub-reboot            newusers               smbd                     usbmuxd
cppw                   grub-set-default       nmbd                   tarcat                   useradd
cracklib-check         guest-account          nologin                tcpd                     userdel
cracklib-format        hciattach              ntpdate                tcpdchk                  usermod
cracklib-packer        hciconfig              ntpdate-debian         tcpdmatch                uuidd
cracklib-unpacker      hciemu                 ownership              tcpdump                  validlocale
create-cracklib-dict   hplj1000               pam-auth-update        toshsat1800-irdasetup    vbetool
cron                   hplj1005               pam_getenv             try-from                 vcstime
cupsaccept             hplj1018               pam_timestamp_check    tunelp                   vigr
cupsaddsmb             hplj1020               paperconfig            tzconfig                 vipw
cups-browsed           hpljP1005              pm-hibernate           ufw                      visudo
cupsctl                hpljP1006              pm-powersave           unity-greeter            vmtoolsd
cupsd                  hpljP1007              pm-suspend             update-alternatives      vmware-checkvm
cupsdisable            hpljP1008              pm-suspend-hybrid      update-apt-xapian-index  vmware-rpctool
cupsenable             hpljP1505              popcon-largest-unused  update-ca-certificates   vmware-vmblock-fuse
cupsfilter             hpssd                  popularity-contest     update-catalog           vpddecode
cups-genppdupdate      iconvconfig            pppconfig              update-cracklib          zic
crifan@ubuntu:qemu$ 

所以的确是没有openvpn。

3.然后注意到之前的教程:

Virtual Development Board

中说的那句:

make two files: qemu-ifup and qemu-ifdown, but do not need openvpn line

所以,再去修改之前自己此处的qemu-ifdown把openvpn去掉:

#!/bin/sh 
# 
# Script to bring down and delete bridge br0 when QEMU exits 
# 
# Bring down eth0 and br0 
#
/sbin/ifdown eth0
/sbin/ifdown br0
/sbin/ifconfig br0 down 
# 
# Delete the bridge
#
/usr/sbin/brctl delbr br0 
# 
# bring up eth0 in "normal" mode 
#
/sbin/ifconfig eth0 -promisc
/sbin/ifup eth0 
#
# delete the tap device
#
#/usr/sbin/openvpn --rmtun --dev $1
#
# start firewall again
# 
/sbin/service firestarter start

同时也把ifup中的openvpn去掉:

#!/bin/sh 
# 
# script to bring up the tun device in QEMU in bridged mode 
# first parameter is name of tap device (e.g. tap0)
#
# some constants specific to the local host - change to suit your host
#
ETH0IPADDR=192.168.0.3
GATEWAY=192.168.0.1
BROADCAST=192.168.0.255
#
# First take eth0 down, then bring it up with IP address 0.0.0.0 
#
/sbin/ifdown eth0
/sbin/ifconfig eth0 0.0.0.0 promisc up
#
# Bring up the tap device (name specified as first argument, by QEMU)
#
#/usr/sbin/openvpn --mktun --dev $1 --user `id -un`
/sbin/ifconfig $1 0.0.0.0 promisc up
#
# create the bridge between eth0 and the tap device
#
/usr/sbin/brctl addbr br0
/usr/sbin/brctl addif br0 eth0
/usr/sbin/brctl addif br0 $1
# 
# only a single bridge so loops are not possible, turn off spanning tree protocol
#
/usr/sbin/brctl stp br0 off 
# 
# Bring up the bridge with ETH0IPADDR and add the default route 
#
/sbin/ifconfig br0 $ETH0IPADDR netmask 255.255.255.0 broadcast $BROADCAST
/sbin/route add default gw $GATEWAY
#
# stop firewall - comment this out if you don't use Firestarter
#
/sbin/service firestarter stop 

4.然后把修改后的拷贝到etc下:

crifan@ubuntu:ifup_ifdown$ gedit qemu-ifdown 
crifan@ubuntu:ifup_ifdown$ sudo cp qemu-ifup qemu-ifdown /etc/
crifan@ubuntu:ifup_ifdown$ gedit qemu-ifup 
crifan@ubuntu:ifup_ifdown$ sudo cp qemu-ifup /etc/

再重新去运行,看看结果,结果还有其他问题:

crifan@ubuntu:ifup_ifdown$ sudo /opt/qemu/bin/qemu-system-arm -M versatilepb -nographic -net nic -net tap,ifname=tap0 -kernel /home/crifan/develop/crosscompile/uboot/u-boot-2013.07/u-boot
/sbin/ifdown: interface eth0 not configured
/etc/qemu-ifup: 24: /etc/qemu-ifup: /usr/sbin/brctl: not found
/etc/qemu-ifup: 25: /etc/qemu-ifup: /usr/sbin/brctl: not found
/etc/qemu-ifup: 26: /etc/qemu-ifup: /usr/sbin/brctl: not found
/etc/qemu-ifup: 30: /etc/qemu-ifup: /usr/sbin/brctl: not found
SIOCSIFADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
SIOCSIFBRDADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCADDRT: Network is unreachable
/etc/qemu-ifup: 39: /etc/qemu-ifup: /sbin/service: not found
/etc/qemu-ifup: could not launch network script
qemu-system-arm: -net tap,ifname=tap0: Device 'tap' could not be initialized

即,

/usr/sbin/brctl: not found

的错误。

5.结果去一搜,发现貌似brctl,也是和openvpn相关的东西。

然后再去掉试试:

ipdown:

#!/bin/sh 
# 
# Script to bring down and delete bridge br0 when QEMU exits 
# 
# Bring down eth0 and br0 
#
/sbin/ifdown eth0
/sbin/ifdown br0
/sbin/ifconfig br0 down 
# 
# Delete the bridge
#
#/usr/sbin/brctl delbr br0 
# 
# bring up eth0 in "normal" mode 
#
/sbin/ifconfig eth0 -promisc
/sbin/ifup eth0 
#
# delete the tap device
#
#/usr/sbin/openvpn --rmtun --dev $1
#
# start firewall again
# 
/sbin/service firestarter start

ifup:

#!/bin/sh 
# 
# script to bring up the tun device in QEMU in bridged mode 
# first parameter is name of tap device (e.g. tap0)
#
# some constants specific to the local host - change to suit your host
#
ETH0IPADDR=192.168.0.3
GATEWAY=192.168.0.1
BROADCAST=192.168.0.255
#
# First take eth0 down, then bring it up with IP address 0.0.0.0 
#
/sbin/ifdown eth0
/sbin/ifconfig eth0 0.0.0.0 promisc up
#
# Bring up the tap device (name specified as first argument, by QEMU)
#
#/usr/sbin/openvpn --mktun --dev $1 --user `id -un`
/sbin/ifconfig $1 0.0.0.0 promisc up
#
# create the bridge between eth0 and the tap device
#
#/usr/sbin/brctl addbr br0
#/usr/sbin/brctl addif br0 eth0
#/usr/sbin/brctl addif br0 $1
# 
# only a single bridge so loops are not possible, turn off spanning tree protocol
#
#/usr/sbin/brctl stp br0 off 
# 
# Bring up the bridge with ETH0IPADDR and add the default route 
#
/sbin/ifconfig br0 $ETH0IPADDR netmask 255.255.255.0 broadcast $BROADCAST
/sbin/route add default gw $GATEWAY
#
# stop firewall - comment this out if you don't use Firestarter
#
/sbin/service firestarter stop 

6.然后再去试试,至少解决了此处的问题,没有openvpn相关的错误了:

no openvpn related error

 

【总结】

此处,当出现:

/etc/qemu-ifup: 19: /etc/qemu-ifup: /usr/sbin/openvpn: not found

/etc/qemu-ifup: 24: /etc/qemu-ifup: /usr/sbin/brctl: not found

应该还是参考QEMU教程中,把相关的openvpn的东西,都去掉,包括openvpn和brctl。

 


结果继续还是剩下的那些“SIOCSIFADDR: No such device ”错误:

【未解决】Ubuntu下用QEMU启动内核时出错:SIOCSIFADDR: No such device

转载请注明:在路上 » 【已解决】Ubuntu下QEMU启动内核时出错:/etc/qemu-ifup: 19: /etc/qemu-ifup: /usr/sbin/openvpn: not found

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.183 seconds, using 22.19MB memory