Saturday May 23, 2009 |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Running CentOS as my host OS and using VirtualBox to run "everything else", it didn't take long before I was running into USB problems. In my case I had a Windows 2000 guest on a CentOS 5 host (same for RedHat EL) and I wanted to use ActiveSync to connect to my WM5 Windows Mobile device. I'm diverting for a sec, but this is the big reason why I like VirtualBox so much. I do software development for the Windows Mobile platform (http://www.locatea.net/) which requires a lot of software installation for Visual Studio and then even more for the various Windows Mobile SDKs. It is quite a job to get it all installed correctly. Previously that whole install could (and would) easily be screwed up because some completely unrelated application would mess up the registry, forcing you to reinstall the server and start from scratch. Now, by virtualizing my desktop, I have an instance that I solely use for Windows Mobile software development. If I need Microsoft Office I do it in another Windows guest. And if I want to tryout a new software package that I don't really trust, I simply clone my base image and install it in there. If the app doesn't work out or behaves badly, I can simply blow the whole image. So, where many people think that desktop virtualization is just great for running different types of OSes on a single host, IMHO it is even more important because it allows you to create multiple environments, that have very dissimilar functionality, but can have the same platform requirements. Of course I also use it to run OpenSolaris on my Mac. :-) Back to USB in Windows guests. Out of the box it doesn't work, at least not on my platform. A little googling provides a lot of recommendations to add an entry to /etc/fstab (none /proc/bus/usb usbfs devgid=501,devmode=0664 0 0). It seems that for Ubuntu this fixes the problem, but not for RedHat / CentOS. It took me a lot of searching, but finally I found in an obscure corner of some forum a solution. You have to modify your /etc/rc.d/rc/sysinit file.
if [ ! -d /proc/bus/usb ]; then
modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs \
/proc/bus/usb /proc/bus/usb -o devgid=501,devmode=664
else
mount -n -t usbfs /proc/bus/usb /proc/bus/usb -o devgid=501,devmode=664
fi
This piece is mainly already there, but you need to add the "-o" parameters. In here "501" is the GID you have specified in your /etc/group for the vboxusers group. After having done this, the Windows guest recognizes USB sticks, external hard drives and nicely connects to my mobile phone. (2009-05-23 11:16:42.0) Permalink Comments [2] After spending couple of hours editing a webpage, I lost all that effort when copying the file to my webserver. And of course before the automatic backup had been made. :-( As always, there is a lesson to be learned. Try this yourself: $ ftp webserver ftp> prompt Interactive mode off. ftp> mput * local: img_2.gif remote: img_2.gif 227 Entering Passive Mode (192,168,32,72,126,33) 150 Opening BINARY mode data connection for img_2.gif. 226 Transfer complete. 12980 bytes sent in 4.2e-05 seconds (3e+05 Kbytes/s) local: img_3.jpg remote: img_3.jpg 227 Entering Passive Mode (192,168,32,72,126,33) 150 Opening BINARY mode data connection for img_3.jpg. 226 Transfer complete. 28488 bytes sent in 0.017 seconds (1.6e+03 Kbytes/s) local: webpage.html remote: webpage.html 227 Entering Passive Mode (192,168,32,72,164,239) 150 Opening BINARY mode data connection for webpage.html. 226 Transfer complete. 12498 bytes sent in 4.5e-05 seconds (2.7e+05 Kbytes/s) ftp> ls * 227 Entering Passive Mode (192,168,32,72,219,226) 150 Opening ASCII mode data connection for /bin/ls. total 268 -rw-r--r-- 1 wwwillem wwwillem 12980 May 20 09:08 img_2.gif -rw-r--r-- 1 wwwillem wwwillem 28488 May 20 09:08 img_3.jpg -rw-r--r-- 1 wwwillem wwwillem 12498 May 20 09:08 webpage.html 226 Transfer complete. ftp> ls -l 227 Entering Passive Mode (192,168,32,72,207,63) 150 Opening ASCII mode data connection for /bin/ls. total 268 -rw-r--r-- 1 wwwillem wwwillem 12980 May 20 09:08 img_2.gif -rw-r--r-- 1 wwwillem wwwillem 28488 May 20 09:08 img_3.jpg -rw-r--r-- 1 wwwillem wwwillem 12498 May 20 09:08 webpage.html 226 Transfer complete. So far all has gone well. Notice the file-size of webpage.html, 12 kB. Now comes the problem: ftp> ls -l *html 227 Entering Passive Mode (192,168,32,72,142,146) 150 Opening ASCII mode data connection for /bin/ls. 226 Transfer complete. ftp> quit 221-Thank you for using the FTP service on webserver. 221 Goodbye. $ ls -l webpage.html total 62 -rw-r--r-- 1 willem willem 209 May 20 09:07 webpage.html Notice how the file has shrunk from 12 kB to only couple of hundred bytes? Let's have a look at the (new) content. $ cat webpage.html total 123 -rw-r--r-- 1 willem willem 12980 May 20 09:01 img_2.gif -rw-r--r-- 1 willem willem 28488 May 20 09:01 img_3.jpg -rw-r--r-- 1 willem willem 209 May 20 09:07 webpage.html What happened here? The 'ls *' ftp command was ok, same for 'ls -l'. However when we did 'ls -l *html', the result of the 'ls -l' command was written to the local html file, in this case webpage.html. That's definitely not what I would have expected to happen. Very weird behaviour!! Finally, the client was ftp on CentOS 5 and the server was an ancient RedHat 6.2 server. And no, 6.2 is not the successor of EL5. :-) (2009-05-20 08:42:36.0) Permalink If you're like me and over the years you've collected a couple of domain names because at the time they were "way too cool", or when you're serving out of your basement the vacation pictures of a couple of friends, then Apache's "Virtual Host" is what you're looking for. What this web server option allows you to do is to have a single web server handle the traffic for multiple domains. For this example let's assume you got (long time ago, when still available :) the domain name "www.myself.com". And now you claimed for your buddy the domain "www.myfriend.com". And let's also assume that you either have a static IP (probably not) or that your ISP is changing their DHCP leases very infrequently (probably yes). So you've managed to configure (with your registrar) your domain name to point to your current IP address '12.34.56.70'. Now go to the registrars web site for "myfriend.com" and (in the DNS section) let it point similarly to '12.34.56.70'. In the following I'm configuring an Apache server on a Cobalt Qube. However, this works exactly the same on any other Apache server (on Linux). To start, create with the Cobalt's web interface a new user called 'friend'. If that worked as it should, you will be able to browse to your buddy's website by pointing your browser at http://12.34.56.70/~friend/. Probably you will just see the boring standard template page. To help with debugging create a different webpage by editing "/home/users/friend/web/index.html". Now we're going to edit '/etc/httpd/conf/httpd.conf' (better save a copy first!!). At the bottom there is a VirtualHost section, but (at least with a Cobalt) it's all commented out. Leave that as it is, but add the following seven lines: # VirtualHost: Allows the daemon to respond to requests for more than one # server address, if your server machine is configured to accept IP packets # for multiple addresses. This can be accomplished with the ifconfig # alias flag, or through kernel patches like VIF. <VirtualHost www.myfriend.com> ServerName www.myfriend.com ServerAdmin my.friend@his.email.com DocumentRoot /home/users/friend/web TransferLog logs/myfriend-access_log ErrorLog logs/myfriend-error_log </VirtualHost> The only important piece here is the 'DocumentRoot' parameter. You can point it to any place in your directory tree, but to make it the same as '.../~friend' does make sense. On some other platforms this will be '/home/friend/public_html/'. If you omit the two lines for logfiles, the logs for your friend will go to the same files as the rest of the web-server. Now restart the web-server with "/etc/rc.d/init.d/httpd restart" (on some other platforms this is "/etc/init.d/apache restart" or similar variants) or simply restart your computer. That done, point your browser to http://www.myfriend.com/ and you should see the page that you edited as '/home/users/friend/web/index.html'. OK, you're ready to become a mini ISP. But be aware, if you've a standard residential fast Internet line, your ISP probably doesn't allow you to have a web-server in your basement!! On the other hand, they probably don't mind, as long as you keep it small-and-personal. Just a couple of pictures showing off the new house or baby, and probably nobody cares. (2006-06-03 21:11:27.0) Permalink |
Calendar
NavigationSearch
ReferersToday's Page Hits: 13
Recent Entries
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||