-
Notifications
You must be signed in to change notification settings - Fork 0
VM Windows Printer with Linux
JTrampQ edited this page Apr 18, 2020
·
11 revisions
Based on: lubuntu-19.10-desktop-amd64.iso
When printer in Linux is not supported and no equivalent driver is enabled, the only choice we have is to host VM windows for running this driver. Usually, Postscript printer is well supported in Linux. Unlike GDI printer which often requires specific driver. First, please be sure the driver is not available here: https://www.openprinting.org/drivers/
sudo apt install qemu qemu-utils qemu-system-x86 qemu-kvm bridge-utils uml-utilities cpu-checker
+------------------------+ +----------------------+
| Linux (Host) | | Printer |
| 192.168.1.200 | | 192.168.1.203 |
| +-----------------+ | +---------^------------+
| | Windows (Guess) | | |
| | 192.168.1.201 |------------------------------+
+---+-----------------+--+
- create VM image
qemu-img create -f qcow2 win7.qcow2 40G
- install win7 iso
qemu-system-x86_64 -m 4096 -cdrom Windows7.iso -boot d win7.qcow2
- clear IP from physical interface (ens33)
ip addr flush dev ens33
- create bridge (br0) and tunnel (tap0) interface
sudo brctl addbr br0
sudo ip link set dev br0 up
sudo tunctl -t tap0
- bridge physical interface (ens33) and tunnel (tap0)
sudo brctl addif br0 ens33
sudo brctl addif br0 tap0
- check the bridge setting
$ brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29002de8 no ens33
tap0
- assign bridge ip
dhclient -v br0
- check interfaces settings
$ ifconfig -a
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.200 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 2001:41d0:fe16:600:20c:29ff:fe00:2de8 prefixlen 64 scopeid 0x0<global>
inet6 2001:41d0:fe16:600:e0f7:aa3c:74c0:4907 prefixlen 64 scopeid 0x0<global>
ether 00:0c:29:00:2d:e8 txqueuelen 1000 (Ethernet)
RX packets 4566 bytes 714756 (714.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 764 bytes 99669 (99.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:0c:29:00:2d:e8 txqueuelen 1000 (Ethernet)
RX packets 49635 bytes 25988592 (25.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6147 bytes 641351 (641.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 859 bytes 80693 (80.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 859 bytes 80693 (80.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::fcb0:f4ff:fe00:5519 prefixlen 64 scopeid 0x20<link>
ether fe:b0:f4:00:55:19 txqueuelen 1000 (Ethernet)
RX packets 4384 bytes 392997 (392.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15579 bytes 16611057 (16.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- check routing table
$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 0 0 0 br0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br0
- check KVM support
$ sudo kvm-ok
INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used
- start VM with KVM (optimized)
sudo qemu-system-x86_64 -m 4096 -enable-kvm -cpu host -smp 2 -nic tap,ifname=tap0,mac=00:00:00:00:00:01 win7.qcow2
- start VM without KVM (slower)
sudo qemu-system-x86_64 -m 4096 -smp 2 -nic tap,ifname=tap0,mac=00:00:00:00:00:01 win7.qcow2
- install network printer (follow classic windows printer instruction)
- VM Windows should have local network IP as 192.168.1.201 in our example
- https://gist.github.com/extremecoders-re/e8fd8a67a515fee0c873dcafc81d811c
- https://wiki.qemu.org/Documentation/Networking
- https://www.qemu.org/2018/05/31/nic-parameter/
- https://www.linux-kvm.org/page/Networking
- https://brezular.com/2011/06/19/bridging-qemu-image-to-the-real-network-using-tap-interface/
- https://ahelpme.com/linux/howto-do-qemu-full-virtualization-with-bridged-networking/
- https://people.gnome.org/~markmc/qemu-networking.html