In the computing world, an “appliance” is a computer that is “dedicated to a single task, and has limited configuration ability”. If you have a router in your home, you have an appliance. If you work for a medium to large-size company, they might have an “anti-spam appliance”: a computer that sits between the Internet and your email server, removing spam. Although appliances are usually dedicated to a single task, what really makes a “computer” an “appliance” is the limited interface. Although your home router is basically a small computer, you cannot click a couple of things and turn it into a file server, or play Solitaire on it.
With the rise of software virtualization, people have started referring to some virtual machines as “appliances”. Although this isn’t, strictly speaking, accurate – most virtual machines run a traditional desktop operating system instead of one dedicated to the task at hand – they can be appliances in the “dedicated to a single task” meaning. In this article, I’ll show you how to create a “Bittorrent appliance”.
But first… why have a “Bittorrent appliance” in the first place? Well, there are several reasons why you might want to run Bittorrent as an appliance:
Compatibility: Many Bittorrent applications don’t work at all in Windows Vista, and many don’t work nearly as well in Vista as they did in XP. By creating an XP-based virtual machine, you can use Vista and still enjoy all of the BT programs that work better in Windows XP. Also, if you have a computer that dual-boots between XP and Vista, you can use the appliance in either OS with minimal disruption. If you’re in XP but need to reboot into Vista and have several downloads going, simply shut down the appliance, reboot into Vista, then restart the appliance! You’ll be back where you left off in seconds!
Portability: The appliance can be installed on (or easily moved to) a portable USB hard drive. So if you have a friend with a crazy fast Internet connection, you can shut down the appliance on your computer, remove the USB drive from your system, drive to your friend’s house, connect the USB drive to his computer, and restart your downloads immediately. Or let’s say you have a desktop computer in your college dorm room, and want to take your downloads home with you to Mom & Dad’s house. Just shut down the appliance, remove the USB drive and hook it up to the desktop PC at your folk’s house – and you’re instantly back where you were at school!
Security: I know that someone’s going to jump on me for this, but I don’t care! Let’s pretend that you’re a heavy downloader. One day you get a letter in the mail from a law firm that states that you’re being sued by the music industry. By having all of your downloading apps on a virtual machine, you’ll necessarily have no downloading apps on your physical machine. If your hard drive were to be seized in a lawsuit, forensics investigators wouldn’t find any evidence of downloading on your computer… because there aren’t any “illicit” programs on your computer!
The following tutorial assumes that you’re familiar with installing and configuring programs, as well as have the ability to complete basic Windows tasks (like sharing a folder). It’s not a “step by step” tutorial. There are no screen caps, and I’m not going to show you how to do each and every step. If you don’t understand any of these steps, find a tech-savvy friend to help you set this up.
To set up the appliance, we’ll need the following programs (all are free):
Microsoft’s Virtual PC 2007
Microsoft’s TweakUI for Windows XP
uTorrent (I recommend this BT client)
PeerGuardian
Timeout (an old command-line app from Microsoft)
You will also need a spare copy of Windows XP. It can be any version (Home, Professional), although if you have a domain at home, you’ll probably want to use XP Pro, as Home cannot join a domain. The XP CDs may also come from any source (retail CD, OEM CD, etc.). It’s up to you to make sure that it’s fully licensed.
1) Download all of the programs linked above and save them somewhere handy, like your desktop.
2) Install Virtual PC 2007 on your computer. It’s as simple as installing any other Windows program, so I don’t need to give you any special help here. If VPC setup asks you to reboot when done, do so.
3) Now we need to create a virtual machine on your system. If you are unfamiliar with Virtual PC, have a thorough look at this tutorial; although the tutorial is about using Virtual PC 2004 to install Windows 98 into a virtual machine, the procedure is more or less the same for installing Windows XP using Virtual PC 2007.
The important things to consider when creating a virtual machine are the amount of RAM it’ll use and the size of the virtual hard disk.
How much RAM you assign to the virtual machine depends on how much RAM you have in your physical machine. If you have less than 1GB of RAM in your machine, you might want to rethink the concept of using virtual machines altogether. If you have 1GB of RAM in your physical computer, you should probably dedicate no more than 256MB of RAM to the virtual machine; any less and the virtual machine will perform poorly, any more and your physical machine will perform poorly. If you have 2GB of RAM in your system, I’d tell you to assign the virtual machine 384MB of RAM – anything above that is simply a waste of RAM, as the XP VM will hardly touch that much memory.
When it comes to the size of your virtual hard drive (VHD), you’ll need to consider the size of the XP install (around 2.5GB) and the average size of the files you download at any given time. The appliance will initially download the files to the virtual machine, then copy them to the physical machine once the download is complete. So if you normally download 10 100MB files at once, you’ll need a virtual hard drive that’s at least 4GB (2.5GB for XP and 1GB for the files that are downloading). The virtual hard drive on my system is 8GB – which gives me around 6GB of “downloading space”. For me, this is plenty. If you normally download 10GB worth of stuff at any given time, you’ll probably want to have a much larger VHD. Later on we’ll discuss a workaround if you need to download larger files; in the meantime, we just want to have a VHD file that can fit both XP and the average sizes of the files your download.
Lastly, make sure to install the virtual machine on one of your fixed drives for now. Most fixed drives are much faster than portable USB drives, so we’ll install the virtual machine to a fixed drive to take advantage of that speed during the initial setup steps. We can move it to a portable drive later (if you’d like).
4) Now we need to install XP on the virtual machine. To do this, simply put the XP setup disc in one of your optical drives, then start the virtual machine and quickly choose CD > “Use Physical Drive L:” (or whatever the drive letter of the optical drive you put XP CD into is). If you have an ISO file of the XP setup CD, you can choose CD > “Capture ISO Image” instead. In any case, once Virtual PC has the correct drive\image file, the virtual machine will boot off the CD and Windows XP setup will begin.
5) Once setup is complete, allow XP to boot into the OS. You will probably need to create a user on this computer. You might also need to configure the network settings or join a domain. Whatever you need to do to get the virtual machine online, do it. If anything you do requires a reboot, hold off on rebooting for now. The first thing we need to do is change a performance setting. Click on Start > Settings > Control Panel > System and then click on the “Advanced” tab. Click on the “Settings” button under “Performance”. Select the “Adjust for best performance” radio button, then click “OK”. OPTIONAL: if you’re using XP professional, you might want to enable remote access so you can administer the virtual machine via RDP. To enable this, click the “Remote” tab on the System applet and choose “Allow users to remotely connect to this computer” option. Close the System applet. We next need to install the “Virtual Machine Additions”. The additions will greatly increase the video and mouse performance of the virtual machine, and will also allow us to drag and drop files between the physical and virtual desktops. To install the additions, click on File > “Install Virtual Machine Additions”. A setup routine will start; accept all the default options and reboot the virtual machine when asked.
6) Once the computer is back from the reboot, go to Windows Update and download all the available updates, hotfixes and patches for Windows XP. This may take a while, and it may take several reboots, so do what you’ve gotta do. You will not need any updates to Windows Media Player, nor will you need any of the .NET Framework packages, so you can skip installing these.
6a) OPTIONAL: Once you’ve fully updated the virtual machine, you may wish to burn a copy of the VMC and VHD files to a DVD disc, or keep a backup copy of the files on a portable drive. This way you’ll have a fully updated “backup virtual machine” ready to go at any time. So if you were to do something in the following steps that completely screws up the virtual machine, you can simply go back to this backup copy, and not have to bother with reinstalling Windows XP again.
7) Unzip the TIMEOUT.ZIP file you downloaded at the beginning of this tutorial, as well as any other files that might be zipped. Drag and drop the unzipped files (and all the other remaining files you downloaded in step 1) from your physical desktop to the virtual desktop.
8) Install TweakUI on the virtual machine, then start TweakUI and set the computer to log in to the system automatically (Logon > Autologon). You may also wish to use TweakUI to remove desktop icons, disable balloon tips, turn taskbar grouping ON or OFF… whichever tweaks you like to do, do them! I prefer removing or disabling everything I can with TweakUI, since I want the machine to have the smallest UI and footprint possible.
9) Install PeerGuardian on the virtual machine. PeerGuardian is like a firewall for P2P programs; it downloads “blocklists” of known or suspected RIAA\MPAA computers and keeps your computer from connecting to them – thus, keeping you out of trouble. By default, PeerGuardian will block P2P offenders, so you don’t need to sign up for any additional blocklists (if this were your physical computer, you might want to subscribe to the ad-blocking list, for example). Once PeerGuardian is installed, allow it to download the latest P2P blocklist, then click the “Settings” tab. Choose the following options:
UNCHECK “Show allowed connections”
UNCHECK “Log allowed connections”
(Click the “Next” button to select the following options)
UNCHECK “Start with Windows”
UNCHECK “Always start hidden”
UNCHECK “Show splash”
CHECK “Check PeerGuardian”, “Check Lists”, and “Auto-Update every x days” under “Updates”
SET Auto-Update to every 1 day(s)
CHECK “Hide window on close”
10) Create a folder on the virtual computer. It can be anywhere you like, and can have any name you’d like. In this example, I’ll use “c:\utorrent”. Share this folder to your network and make sure that EVERYONE has full control over the folder.
11) Click Edit > Settings in the Virtual PC window. (You will get a message saying that some settings are disabled when the VM is powered on; click “OK” to skip this message). Click “Shared Folders” in the left-hand pane. Click “Share folder” in the right hand pane and select the folder you normally use for downloads on your physical computer. In my case, I chose “d:\video” as the shared folder from my physical computer, and gave it the drive letter J: on the virtual computer. If you plan on using the appliance on a portable USB hard drive: shut down the virtual machine and close the Virtual PC console. Move the VMC and VHD files to the portable hard drive, then restart the virtual machine by double-clicking on the VMC file. Then proceed with this step, but make sure to choose a folder on the USB drive as a shared folder.
12) Drag the “webui_v0.310_beta_2” folder into the “Program Files” folder on your virtual machine. Open the folder and click on UTORRENT.EXE. You will probably see a “uTorrent Setup Wizard”, go through this wizard and continue to the next step.
13) Once your at the main uTorrent UI, click on Options > Preferences and select the following options:
GENERAL
UNCHECK “Check for updates automatically”
UNCHECK “Confirm when deleting torrents”
UNCHECK “Show confirmation dialog on exit”
CHECK “Always show tray icon”
UNCHECK: “Show balloon notifications in tray”
CHECK “Minimize to tray”
CHECK “Alternate list background color” (optional)
CHECK “Check association on startup”
UNCHECK “Start uTorrent on system startup”
DOWNLOADS
CHECK “Put new downloads in:”
CHOOSE a location to save the files on the virtual machine (I chose “c:\downloads”)
CHECK “Always show dialog on manual add”
CHECK “Move completed downloads to:”
CHOOSE the shared folder you set up in step 11
CHECK “Only move from the default download directory”
CONNECTION
CHOOSE a port number for uTorrent
CHOOSE “Enable UPnP port mapping” if your router supports it
UNCHECK “Add uTorrent to Windows Firewall” if you don’t use the built-in firewall
QUEUEING
CHOOSE an overall ratio you want to share the files to (I use 150%)
CHECK “Limit the upload rate to” and enter a ZERO in the box.
SCHEDULER
No changes made here
OTHER
CHECK the “Auto-Load Torrents” button
CHOOSE the folder you shared in step 10
CHECK “Delete torrent instead of renaming”
ADVANCED > WEBUI
CHECK “Enable Web Interface”
ENTER a user name and password
Before we continue to the next step, let’s review what we did in uTorrent:
Under “General” settings, we tweaked a bunch of settings that have to do with the overall performance of the program; there’s nothing too confusing here, so I’ll skip ahead.
Under “Downloads”, we told uTorrent to download all files to a particular directory on the virtual machine, then told it to move the files to the shared folder (j:) when the downloads are completed (you will still be able to seed the files once the files are moved, moving them only makes then easier for you to access on your physical machine). We also told uTorrent to always show the default “save” dialog when we manually tell it to open a torrent (this will let us choose a different download location for large torrents). We also told uTorrent to only move files downloaded to the default directory; this stops uTorrent from moving files which are saved manually from one location to another (important for those 30GB downloads).
Under “Connection”, we chose a port for uTorrent and enabled UPnP for those routers that support it. UPnP allows programs (like uTorrent) to open the ports on your router that they need automatically, and close them when the program exits. This is a much more elegant solution than mapping ports manually, although some are convinced that UPnP is a security risk. I say “Bah, humbug!” to them, and go with UPnP anyway. Since I have a Windows Server 2003 domain at home and a hardware-based firewall, I disable Windows Firewall on all my systems. If you don’t have a router (with firewall) at home, you SHOULD enable Windows Firewall on your computers, and make exceptions for Virtual PC (on the physical computer) and uTorrent (on the virtual computer).
Under “Queueing”, I chose a default ratio of 150%. Note that you can override this on any given torrent you want; 150% just happens to work out well for the average BT sites I visit. I also stop those torrents once the ratio gets to 150%; you might want to continue seeding, but at a lower rate. This is the option to choose for that.
I didn’t do anything under “Scheduler” in this example, but I *do* use Scheduler on a daily basis. I have VoIP phone service, and so I have uTorrent limited to 10kbps upstream from 5pm to 11pm during the week, and 9am-11pm on weekends (I am usually here during the day and can manually stop uTorrent if a call comes in).
Under “Other” I created a uTorrent “watch folder”. Instead of manually copying torrent files to the virtual machine, and instead of manually clicking “OK” for every torrent I start, I created a shared folder on the virtual computer called “c:\uTorrent”. As mentioned previously, EVERYONE has full control over the folder. I’ve added this folder as the mapped drive Q: to the domain login script, so any time I want to download a file via uTorrent I just save the .torrent file to the Q: drive. Since Q; is mapped to every computer in my domain, I can also start torrents from Lisa’s computer downstairs, simply by saving the torrent file to the Q; drive on her computer. I also checked the “delete torrent instead of renaming” option; this deletes any .torrent file from the c:\uTorrent folder once it has successfully been loaded by uTorrent. So instead of c:\uTorrent becoming clogged with weeks-old .torrent files, it’s almost always empty instead.
Lastly, I went to the “WebUI” options and enabled the WebUI interface. This allows me to check the status of my downloads from any computer connected to the Internet. By the way, the default address for the WebUI is http://yourIP:portnumber/gui. Locally, it might be http://192.168.1.10:12345/gui. If you subscribe to a free dynamic hosting service, you (obviously) would use your external hosting name outside of your network (but you would still need :portnumber/gui).
14) Next, you’ll need to drag the TIMEOUT.EXE file to the c:\windows folder of the virtual machine. After you’ve done this, click Start > Run on the virtual machine and type CMD, then press ENTER. At the command-prompt, type TIMEOUT 5 and press ENTER. You should see “Waiting 5 seconds, press a key to continue”. If you do, skip to the next step; if you don’t make 100% sure that TIMEOUT.EXE is in the c:\windows folder.
15) Open Notepad on the virtual machine and cut and paste the following text:
timeout 20
C:
cd "C:\Program Files\PeerGuardian2\"
start /min pg2.exe
timeout 45
cd "C:\Program Files\webui_v0.310_beta_2"
start /min utorrent.exe
exit
Save the file as STARTUP.CMD (make sure that the “Save as type:” option is set to “all files”; else you’ll create a text file called startup.cmd.txt). Drag and drop the CMD file to the Startup folder.
This batch file is pretty self-explanatory. It opens with Windows startup, but waits 20 seconds before doing anything (because when Windows boots, there’s still a lot of stuff going on in the background). Once the 20 seconds are up, it starts PeerGuardian in a minimized state , then waits 45 seconds (for PeerGuardian to load completely) before starting uTorrent (also in a minimized state). The batch file then exits. The reason you want to use this batch file (instead of putting shortcuts to PG and UT in the Startup folder, or enabling “Start with Windows” in the program options) is to a) give Windows a chance to finish booting before starting any of the programs; and b) to start the programs in a particular order (you don’t want uTorrent starting before PeerGuardian). You may, of course, need to change the paths in the batch file, but these are the defaults chosen in the tutorial.
We are almost done! We have a virtual machine that boots up and automatically logs in, waits 20 seconds and starts PeerGuardian, then waits 45 seconds and starts uTorrent. We can save torrent files to the virtual computer’s shared folder, and uTorrent will automatically load them, then delete the .torrent file. When uTorrent is done downloading the file(s), it will move it\them to a shared folder on your physical computer, where you can watch, play or install them. uTorrent will automatically share the file(s) until the ratio gets to 150%, at which point it will automatically stop the file. We have also configured the WebUI, so we can check on the progress of the downloads from any computer with IE 7 or Firefox. If the virtual machine is running XP Pro, we’ve also enabled Remote Desktop, so we can check the status of uTorrent that way, too.
16) If everything looks good so far, click on Start > Settings > Control Panel > System and click the “System Restore” tab. Check the “Turn off System Restore”, then “OK” at any “nag screens” that come up.
17) Open Windows Explorer on the virtual machine and go to the c:\windows directory. You will probably see several folders with names like “$NtUninstallKB921503$”. Delete all of these folders, but do not delete the folder called “$hf_mig$”.
18) OPTIONAL: You might wish to delete any unnecessary icons from the Start Menu. I know I delete the “Windows Media Player”, “Outlook Express”, “Remote Assistance” icons and more. You might think you’d be better off my simply deleting or uninstalling these programs; sadly, you won’t save that much space, and it’s possible that you might break something. The only program I normally get rid of is Windows Messenger, which I do simply by making sure that the program is closed and renaming the Program Files\Messenger folder to Messenger.old
17) Click Start > Programs > Accessories > System Tools > Disk Cleanup, then use Disk Cleanup to remove any extra files you might have lying around on the system. Make sure that you click the “More Options” tab and remove any leftover Restore Points, too.
19) OPTIONAL: Customize the Quick Launch toolbar on the virtual machine. I have the following icons, from left to right, in my Quick Launch toolbar: uTorrent, PeerGuardian, Windows Explorer, Lock Workstation, RDP Kill, Restart and Shutdown. The first three icons I added simply by dragging shortcuts from the Start Menu. The final four I made by right-clicking the desktop, Choosing New > Shortcut and entering the following into the shortcut box:
LOCK WORKSTATION: %windir%\system32\Rundll32.exe User32.dll,LockWorkStation
RDP KILL: %windir%\System32\tscon.exe 0 /dest:console
RESTART: %windir%\system32\shutdown.exe -r -t 0
SHUTDOWN: %windir%\system32\shutdown.exe -s -t 0
As you might guess, “Lock Workstation” locks the computer, exactly like WIN+L or CTRL+ALT+DEL+Lock Workstation does. RDP Kill disconnects a remote session, by logging the remote user off and logging back in to the console (exiting an RDP session “normally” leaves the console locked). RESTART and SHUTDOWN restart or shutdown the virtual PC immediately with the click of a button. The last bit on both of those commands is a zero; you can change this to a 5 to give 5 seconds warning before shutting down the system (if you wish).
20) OPTIONAL: Right-click on the VMC file and drag a copy to your Startup folder. This will start the virtual computer when you restart your physical computer.
21) OPTIONAL: You might want to copy TIMEOUT.EXE into the c:\windows folder of your physical computer and add a batch file that waits 2-3 minutes before mapping the VM drive on your computer. This is because the domain login script will fail on your computer when you first boot up (because the virtual computer hasn’t had a chance to boot up yet). Adding a small batch file like the following makes life easier for you:
timeout 120
net use q: \\virtualmachine\utorrent
exit
ASSORTED NOTES:
– If you want to download a file that is much larger than your virtual hard drive, simply download the TORRENT file to your desktop, drag it to the desktop on the virtual machine, then click on it. uTorrent’s “Save dialog” will open up, and you can choose an alternate download location for the file. For example, I normally have around 5.5GB worth of free space on my virtual machine; I once wanted to download a 30GB file. I did the above procedure and opted to save the file to J: (the shared download directory) instead of the virtual machine.
– If you want to make your appliance completely portable, make sure that you choose a shared folder that is on the USB drive. Also, you might want to keep a copy of the Virtual Pc 2007 installation files on the USB drive, so that you can easily install Virtual PC 2007 on other computers.
– For some reason, double-clicking on a VMC file doesn’t open the virtual machine in Windows Vista; it only open the Virtual PC Console instead. You have to manually start the virtual machine if you double-click on the VMC file or have a shortcut to the VMC file in your Startup folder. In Windows XP, the virtual computer simply starts. I don’t know why Vista acts like this.
– Virtual PC comes with a feature called “Undo Disks”. This lets you boot up a virtual machine, change the configuration or install some software, then have the option of saving those changes to disk, or ignoring them when the computer shuts down. This is great for people that have to test software, but annoying for those who use virtual machines as appliances. Click on Edit > Settings and disable “Undo disks” when the virtual machine is off. Note that you can enable them if you want to test something, then shutdown and disable the feature.
– Note also that virtual machines come with sound enabled by default. Since there’s little purpose to sound with this appliance, you can disable it by clicking on Edit > Settings and unchecking “Enable sound card” with the virtual machine off.
– On my system, the virtual and physical machine can slow to a crawl if the virtual machine is set to a non-standard resolution (once you have the Virtual Machine Additions installed, you can resize the virtual machine window like any other window). Since it’s easy to accidentally resize the virtual machine window, I set Virtual PC to always use the virtual machine’s screen resolution as the window size (Edit > Settings > Display > Use guest operating system screen resolution).
– Always use the “shared folder” option instead of simply mapping a drive to your physical computer within the virtual machine. For some reason, that much traffic over TCP/IP causes all sorts of errors in both Azureus and uTorrent. By using the “shared folder” option you won’t have those problems (even if it looks exactly like a shared drive on the virtual machine).