Tuesday, January 13, 2009

copy svn working dir without svn hidden dirs and files?

I'm using svn to work on a JSP app which must be compiled and zipped into a fairly large .war file before deployment. I would like to be able to do this without having all the .svn directories and hidden files put into the archive as well. How can I just make a copy of my svn working directory (/home/user/progname) that doesn't include all svn's hidden files?



You could use the old "copy with tar" trick and pass it the --exclude option. The command would go something like this:
Code:
tar --exclude='.svn' -c -f - /path/to/sourcedir/* | (cd /path/to/destdir ; tar xfp -)
This command builds a tar archive of the files in sourcedir, excluding anything that matches the pattern '.svn' (i.e. the hidden Subversion directories). It writes the command to standard output, changes directory to destdir, and then extracts that standard output from a tar archive back to the filesystem.

Or, if you're too lazy for a command that complicated, you can just copy the entire directory and then delete the Subversion stuff with a plain-old:
Code:
find /path/to/destdir -name '.svn' -exec rm -r {} \;

-----------------------------------------------------------------------------------------
rysnc is a very powerful alternative to cp. It provides basic things like you want here, progress meters, copying to remote sites, a diff algorithm to efficiently maintain mirrors, compression, etc.

I think you want something like this:

Code:
rsync -r --exclude=.svn /home/user/progname/ /home/user/progname.copy
I almost always use -a (archive) instead of -r (recursive) because it means -r and more (see the man page). The trailing / on progname means `contents of' (otherwise progname.copy will contain progname and everything will be one more level down). Put a trailing / on .svn to only exlude directories with that name, instead of both directories and files with that name, if for some reason you had files named .svn that you wanted to keep in the copy.

rsync is awesome

Sunday, January 11, 2009

FreeBSD|shutdown -h now

shutdown now will not shutdown freebsd but enter into single user mode, to shutdown, use shutdown -h now

howzit

use cmd like this shutdown -h now h means halt. I guess it is a way to take into single user mode without restarting the box compltely.

chow

HOWT0: Go from single-user to multi-user
Miscellaneous Posted by Jason on Sunday May 12, @09:52AM
from the dept.
As many of you may already know, UNIX is separated into two main camps. The BSD camp and the system V camp. System V Unix OS's have many run levels which they can run in and each level starts up different services. On the other hand, BSD(FreeBSD included) has only two: single-user and multi-user mode. Also, you can switch between these two modes without a reboot. Here's how...

For this to work, you have to start FreeBSD in single-user mode, after that you can switch to multi-user mode and back to singe-user mode without rebooting.


[Boot in single user mode]

As the operating system is starting, it will display the following message:

Hit [Enter] to boot immediately, or any other key for command prompt.

Booting [kernel] in 10 seconds...


You should now press the space bar, and you will see the following message:

Type '?' for a list of commands, or 'help' for more detailed help.

ok


Now type boot -s and press the enter key to start FreeBSD in single user mode. After the system boots, you should see the statement:

Enter full pathname of shell or RETURN for /bin/sh:

Press the enter key and you will have a # prompt.


[Mount the filesystems]

Next, you will have to mount your filesystems manually. At the command prompt, issue the mount command. This command will mount all the filesystems listed in your /etc/fstab file. You may also wish to enable your swap.

# mount -t ufs -a
# swapon -a


[Switch to multi-user mode]

At the command prompt, issue the exit command. This command will run your normal startup scripts and start FreeBSD in multi-user mode.

# exit


[Switch back to single-user mode]

At the command prompt, issue the shutdown now command. This will not shutdown the computer, but instead will drop you back to single-user mode.

# shutdown now



[Shutting down]

To shutdown the OS in either single-user or multi-user mode, issue the halt command:

# halt



To learn more about the commands listed in this post please refer to the man pages.

man mount
man swapon
man shutdown
man halt


< | >



Re: HOWT0: Go from single-user to multi-user
by ATorres on Friday April 18, @10:36AM
Good day, Please excuse my ignorance. I'm a DOS/Windows guy. How can I setup BSD to execute an application program after boot (just like Autoexec.bat in DOS) automatically? In the same line, is there a way to setup BSD so that it doesn't ask me for a user name to login? Again, imitating my DOS computer, I'd like to turn on the computer and the system would boot and run an application. Thanks much.
[ Add a Reply to this ]
  • No user and password prompt
    by Doug on Wednesday July 13, @09:43AM
    You could install a "display manager" like xdm or kdm or gdm if you want to get to a pretty login screen. I believe that kdm will do auto-login if you set it up properly.
    [ Reply to this ]
Re: HOWT0: Go from single-user to multi-user
by Gary on Saturday June 14, @02:31PM
add a line to /etc/rc.local or a script to /usr/local/etc/rc.d

Saturday, January 10, 2009

Qemu|Useful hint

Qemu on FreeBSD as host

worked for me:
qemu -monitor stdio -boot c -m 2020 -hda '/apps/qemuroot/winxproot/winxpdisk' -net nic -net tap,macaddr=00:bd:64:d8dhw -soundhw es1370e s1370 -kernel-kqemu -vnc :2 -usbdevice tablet


Qemu is a very fast generic and open source processor emulator by Fabrice Bellard. It runs under Windows 2000, Windows XP, GNU/Linux (RedHat, Debian) and FreeBSD "host" systems. After reading this page you should know:

* How to install qemu from the Ports tree
* How to run Qemu in FreeBSD 7.X or later

Installation notes

The installation of Qemu is pretty fast and easy. You can just install it from the Ports. The two Qemu ports we have in the Ports tree as of this writing are "emulators/qemu" and "emulators/qemu-devel". Installing "qemu-devel" for example should be as easy as:

*

# cd /usr/ports/emulators/qemu-devel
# make install && make clean

*

Note: It may be a good idea to enable the KQEMU accelerator when you install one of the Qemu ports (otherwise qemu is much slower).

Running Qemu

To successfully run Qemu, you should make sure that you have:

* IDE bus-master DMA support
*

The aio, if_tap and if_bridge modules in the "host" system

If you forget to load aio, then Qemu may crash with an error message of:

*

Bad system call: 12 (core dumped)

The if_tap and if_bridge modules are mandatory only when you plan to connect the "hosted" FreeBSD system with your existing network. If you don't need networking inside Qemu, it's ok to fire it up without these two networking modules in the host kernel.

*

Note: if you use kqemu make sure your kqemu.ko module is always in sync with your kernel (like with any kld installed outside of base), i.e. rebuild its port whenever you update the kernel — especially if you are switching branches or are following a -STABLE or -CURRENT branch!

You can enable autoloading of kqemu (and aio) at boot by adding a line to your /etc/rc.conf file:

*

kqemu_enable="YES"
*

Note: it is impossible to continue to use existing Windows 2000/XP disk images, since driver has been changed by activating IDE Bus-master DMA support.

Networking on FreeBSD 7

Contributed by: Marten Vijn.

Default, network is configured inside of the emulator; not visible from outside. if you use fxp0, then:

* # ifconfig tap create
* # ifconfig bridge create
* # ifconfig bridge0 addm tap0 addm fxp0 up

Also, /usr/local/etc/qemu-ifup script is needed. Networking Default, network is configured inside of the emulator; not visible from outside. This is not absolutely confotable! There are pros and cons: you must be the root and your qemu virtual machine is visible from outside. Assume you know your network interface name. In this case it is fxp0. you can check this by:

* % dmesg | grep Ethernet

First, as root,

* # sysctl net.link.ether.bridge_cfg=fxp0,tap0
* # sysctl net.link.ether.bridge.enable=1

create /usr/local/etc/qemu-ifup script as

*

#!/bin/sh
/sbin/ifconfig ${1} up

and make this script runnable.

* # chmod 755 /usr/local/etc/qemu-ifup

To do this at every boot time, write /etc/sysctl.conf

*

net.link.ether.bridge_cfg=fxp0,tap0
net.link.ether.bridge.enable=1

and in /boot/loader.conf

*

bridge_load="YES"

Invoke qemu by:

* # qemu -net nic -net tap

This was originally taken from freebsd vde helpp Qemu as VNC server Display writing is very slow in QEMU, so run qemu as vnc server is very useful.

* % qemu -hda /work/qemu/win2000ja/win2000.img -localtime -m 384 -vnc :1 -usbdevice tablet

Run vncviewer like (you can install via /usr/ports/net/tightvnc)

% vncviewer :1

You should wait for while until Windows starts up. Full Screen mode (slow) QEmu uses SDL to output the screen. Modern video card supports VESA 2.0, so you can use SDL with VESA 2.0. While using SDL you need additional settings. First, reconfigure kernel with this configuration.

*

include GENERIC
ident MAHO
device atapicam
options VESA

save as /usr/src/sys/i386/conf/MAHO or something like that. Then,

* # cd /sys/i386/compile/MAHO

# made cleandepend ; make depend ; make ; make install

you need additional setting:

* # setenv SDL_VIDEODRIVER vgl

and you can run with full-screen in the console. Again, you must be the root. As far as I tested,

* # kldload vesa

DOESN'T WORK (FOR ME). Unfortunately this is very slow, slower than X11 mode... Summary (My setting and command line) As summary, I present my setting for qemu 0.8.0.

* # qemu -localtime -hda /work/qemu/win2000ja/win2000.img -m 256 -net nic -net tap

/boot/loader.conf

* kqemu_load="YES"

bridge_load="YES" snd_driver_load="YES" snd_pcm_load="YES"

/etc/sysctl.conf

* net.link.ether.bridge_cfg=fxp0,tap0

net.link.ether.bridge.enable=1

/etc/qemu-ifup (chmod 755 /etc/qemu-ifup)

*

#!/bin/sh
ifconfig ${1} 0.0.0.0

Reconfigure kernel with this configuration file

*

include GENERIC
ident MAHO
device atapicam
options VESA

and additional enviromnent variable:

* # setenv SDL_VIDEODRIVER vgl

I don't want to be the root

* Network bridge
* Full screen mode

Links

*

Qemu

Virtual Machines...

I really like vmware, but I'm not thrilled about the licensing, pay-for-server, or proprietary virtual-disk format. So instead, I use Qemu. Qemu can boot from a dd image of a disk. (Cool!) And Qemu includes tools for converting disk images to vmware's format and vice versa. (For these goodies, I put them in my book, Hacking Ubuntu.)

The problem is, the virtual machine from Qemu does not seem to like the mouse when using Synergy. What happens is that the VM window says it grabbed the mouse, but no mouse is present. And if you move the mouse far enough to the other side, then Synergy takes it to another monitor.

The solution I use has two steps and uses VNC. VNC is normally used to see and control a remote desktop.

1. Run Qemu with the VNC setting. "-vnc 2" will start the virtual machine's desktop in VNC display 2. You can then use vncviewer localhost:2 to access the system.
2. The second problem is with mouse alignment. If your virtual machine is running Windows, then the real pointer and mouse pointer are not lined up. Fix this by specifying a pointer device that uses absolute coordinates: "-usbdevice tablet". Poof -- the mouse is aligned.


My full command-line (for my Windows 2000 image) looks like: qemu -hda win2k.hd -m 256 -win2k-hack -vnc :2 -usbdevice tablet. Works like a champ. Granted, Qemu + VNC is probably not refreshing fast enough for streaming real-time video, it is fine for basic word processing (which is the only reason I still keep a Windows system around).

Friday, January 9, 2009

1.3. Changing IP Addresses and Routes
Prev Chapter 1. Basic IP Connectivity Next
1.3. Changing IP Addresses and Routes

This section introduces changing the IP address on an interface, changing the default gateway, and adding and removing a static route. With the knowledge of ifconfig and route output it's a small step to learn how to change IP configuration with these same tools.
1.3.1. Changing the IP on a machine

For a practical example, let's say that the branch office server, morgan, needs to visit the main office for some hardware maintenance. Since the services on the machine are not in use, it's a convenient time to fetch some software updates, after configuring the machine to join the LAN.

Once the machine is booted and connected to the Ethernet, it's ready for IP reconfiguration. In order to join an IP network, the following information is required. Refer to the network map and appendix to gather the required information below.

*

An unused IP address (Use 192.168.99.14.)
*

netmask (What's your guess?)
*

IP address of the default gateway (What's your guess?)
*

network address [5] (What's your guess?)
*

The IP address of a name resolver. (Use the IP of the default gateway here [6]. )

Example 1.5. ifconfig and route output before the change

[root@morgan]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:80:C8:F8:4A:53
inet addr:192.168.98.82 Bcast:192.168.98.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:9 Base address:0x5000

[root@morgan]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.98.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.98.254 0.0.0.0 UG 0 0 0 eth0


The process of readdressing for the new network involves three steps. It is clear in Example 1.5, “ifconfig and route output before the change”, that morgan is configured for a different network than the main office desktop network. First, the active interface must be brought down, then a new address must be configured on the interface and brought up, and finally a new default route must be added. If the networking configuration is correct and the process is successful, the machine should be able to connect to local and non-local destinations.

Example 1.6. Bringing down a network interface with ifconfig

[root@morgan]# ifconfig eth0 down


This is a fast way to stop networking on a single-homed machine such as a server or workstation. On multi-homed hosts, other interfaces on the machine would be unaffected by this command. This method of bringing down an interface has some serious side effects, which should be understood. Here is a summary of the side effects of bringing down an interface.

Side effects of bringing down an interface with ifconfig

*

all IP addresses on the specified interface are deactivated and removed
*

any connections established to or from IPs on the specified interface are broken [7]
*

all routes to any destinations through the specified interface are removed from the routing tables
*

the link layer device is deactivated

The next step, bringing up the interface, requires the new networking configuration information. It's a good habit to check the interface after configuration to verify settings.

Example 1.7. Bringing up an Ethernet interface with ifconfig

[root@morgan]# ifconfig eth0 192.168.99.14 netmask 255.255.255.0 up
[root@morgan]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:80:C8:F8:4A:53
inet addr:192.168.99.14 Bcast:192.168.99.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:9 Base address:0x5000



The second call to ifconfig allows verification of the IP addressing information. The currently configured IP address on eth0 is 192.168.99.14. Bringing up an interface also has a small set of side effects.

Side effects of bringing up an interface

*

the link layer device is activated
*

the requested IP address is assigned to the specified interface
*

all local, network, and broadcast routes implied by the IP configuration are added to the routing tables

Use ping to verify the reachability of other locally connected hosts or skip directly to setting the default gateway.
1.3.2. Setting the Default Route

It should come as no surprise to a close reader (hint), that the default route was removed at the execution of ifconfig eth0 down. The crucial final step is configuring the default route.

Example 1.8. Adding a default route with route

[root@morgan]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.99.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
[root@morgan]# route add default gw 192.168.99.254
[root@morgan]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.99.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.99.254 0.0.0.0 UG 0 0 0 eth0


The routing table on morgan should look exactly like the initial routing table on tristan. Compare the routing tables in Example 1.1, “Sample ifconfig output” and Example 1.8, “Adding a default route with route”.

These changes to the routing table on morgan will stay in effect until they are manually changed, the network is restarted, or the machine reboots. With knowledge of the addressing scheme of a network, and the use of ifconfig and route it's simple to readdress a machine on just about any Ethernet you can attach to. The benefits of familiarity with these commands extend to non-Ethernet IP networks as well, because these commands operate on the IP layer, independent of the link layer.
1.3.3. Adding and removing a static route

Now that morgan has joined the LAN at the main office and can reach the Internet, a static route to the branch office would be convenient for accessing resources on that network.

A static route is any route entered into a routing table which specifies at least a destination address and a gateway or device. Static routes are special instructions regarding the path a packet should take to reach a destination and are usually used to specify reachability of a destination through a router other than the default gateway.

As we saw above, in Section 1.2.3, “Static Routes to Networks”, a static route provides a specific route to a known destination. There are several pieces of information we need to know in order to be able to add a static route.

*

the address of the destination (192.168.98.0)
*

the netmask of the destination (255.255.255.0)
o

EITHER the IP address of the router through which the destination (192.168.99.1) is reachable
o

OR the name of the link layer device to which the destination is directly connected

Example 1.9. Adding a static route with route

[root@morgan]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.99.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.99.254 0.0.0.0 UG 0 0 0 eth0
[root@morgan]# route add -net 192.168.98.0 netmask 255.255.255.0 gw 192.168.99.1
[root@morgan]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.99.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.98.0 192.168.99.1 255.255.255.0 UG 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.99.254 0.0.0.0 UG 0 0 0 eth0


Example 1.9, “Adding a static route with route” shows how to add a static route to the 192.168.98.0/24 network. In order to test the reachability of the remote network, ping any machine on the 192.168.98.0/24 network. Routers are usually a good choice, since they rarely have packet filters and are usually alive.

Because a more specific route is always chosen over a less specific route, it is even possible to support host routes. These are routes for destinations which are single IP addresses. This can be accomplished with a manually added static route as below.

Example 1.10. Removing a static network route and adding a static host route

[root@morgan]# route del -net 192.168.98.0 netmask 255.255.255.0 gw 192.168.99.1
[root@morgan]# route add -net 192.168.98.42 netmask 255.255.255.255 gw 192.168.99.1
[root@morgan]# route add -host 192.168.98.42 gw 192.168.99.1
SIOCADDRT: File exists
[root@morgan]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.99.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.98.42 192.168.99.1 255.255.255.255 UGH 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.99.254 0.0.0.0 UG 0 0 0 eth0


This should serve as an illustration that there is no difference to the kernel in selecting a route between a host route and a network route with a host netmask. If this is a surprise or is at all confusing, review the use of netmasks in IP networking. Some collected links on general IP networking are available in Section I.1.3, “General IP Networking Resources”.

[5] The network address can be calculated from the IP address and netmask. Refer to Section H.1, “ipcalc and other IP addressing calculators”. Especially handy is the variable length subnet mask RFC, RFC 1878.

[6] Many networks are configured with the name resolution services on a publicly connected host. See Section 12.6, “DNS Troubleshooting”.

[7] It is possible for a linux box which meets the following three criteria to maintain connections and provide services without having the service IP configured on an interface. It must be functioning as a router, be configured to support non-local binding and be in the route path of the client machine. This is an uncommon need, frequently accomplished by the use of transparent proxying software.

Network|11.8.2 Configuring the Network Card

11.8.2 Configuring the Network Card

Once the right driver is loaded for the network card, the card needs to be configured. As with many other things, the network card may have been configured at installation time by sysinstall.

To display the configuration for the network interfaces on your system, enter the following command:

% ifconfig
dc0: flags=8843 mtu 1500
inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255
ether 00:a0:cc:da:da:da
media: Ethernet autoselect (100baseTX )
status: active
dc1: flags=8843 mtu 1500
inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255
ether 00:a0:cc:da:da:db
media: Ethernet 10baseT/UTP
status: no carrier
lp0: flags=8810 mtu 1500
lo0: flags=8049 mtu 16384
inet 127.0.0.1 netmask 0xff000000
tun0: flags=8010 mtu 1500

Note: Old versions of FreeBSD may require the -a option following ifconfig(8), for more details about the correct syntax of ifconfig(8), please refer to the manual page. Note also that entries concerning IPv6 (inet6 etc.) were omitted in this example.

In this example, the following devices were displayed:

*

dc0: The first Ethernet interface
*

dc1: The second Ethernet interface
*

lp0: The parallel port interface
*

lo0: The loopback device
*

tun0: The tunnel device used by ppp

FreeBSD uses the driver name followed by the order in which one the card is detected at the kernel boot to name the network card. For example sis2 would be the third network card on the system using the sis(4) driver.

In this example, the dc0 device is up and running. The key indicators are:

1.

UP means that the card is configured and ready.
2.

The card has an Internet (inet) address (in this case 192.168.1.3).
3.

It has a valid subnet mask (netmask; 0xffffff00 is the same as 255.255.255.0).
4.

It has a valid broadcast address (in this case, 192.168.1.255).
5.

The MAC address of the card (ether) is 00:a0:cc:da:da:da
6.

The physical media selection is on autoselection mode (media: Ethernet autoselect (100baseTX )). We see that dc1 was configured to run with 10baseT/UTP media. For more information on available media types for a driver, please refer to its manual page.
7.

The status of the link (status) is active, i.e. the carrier is detected. For dc1, we see status: no carrier. This is normal when an Ethernet cable is not plugged into the card.

If the ifconfig(8) output had shown something similar to:

dc0: flags=8843 mtu 1500
ether 00:a0:cc:da:da:da

it would indicate the card has not been configured.

To configure your card, you need root privileges. The network card configuration can be done from the command line with ifconfig(8) but you would have to do it after each reboot of the system. The file /etc/rc.conf is where to add the network card's configuration.

Open /etc/rc.conf in your favorite editor. You need to add a line for each network card present on the system, for example in our case, we added these lines:

ifconfig_dc0="inet 192.168.1.3 netmask 255.255.255.0"
ifconfig_dc1="inet 10.0.0.1 netmask 255.255.255.0 media 10baseT/UTP"

You have to replace dc0, dc1, and so on, with the correct device for your cards, and the addresses with the proper ones. You should read the card driver and ifconfig(8) manual pages for more details about the allowed options and also rc.conf(5) manual page for more information on the syntax of /etc/rc.conf.

If you configured the network during installation, some lines about the network card(s) may be already present. Double check /etc/rc.conf before adding any lines.

You will also have to edit the file /etc/hosts to add the names and the IP addresses of various machines of the LAN, if they are not already there. For more information please refer to hosts(5) and to /usr/share/examples/etc/hosts.
11.8.3 Testing and Troubleshooting

Once you have made the necessary changes in /etc/rc.conf, you should reboot your system. This will allow the change(s) to the interface(s) to be applied, and verify that the system restarts without any configuration errors.

Once the system has been rebooted, you should test the network interfaces.
11.8.3.1 Testing the Ethernet Card

To verify that an Ethernet card is configured correctly, you have to try two things. First, ping the interface itself, and then ping another machine on the LAN.

First test the local interface:

% ping -c5 192.168.1.3
PING 192.168.1.3 (192.168.1.3): 56 data bytes
64 bytes from 192.168.1.3: icmp_seq=0 ttl=64 time=0.082 ms
64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=0.074 ms
64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=0.076 ms
64 bytes from 192.168.1.3: icmp_seq=3 ttl=64 time=0.108 ms
64 bytes from 192.168.1.3: icmp_seq=4 ttl=64 time=0.076 ms

--- 192.168.1.3 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.074/0.083/0.108/0.013 ms

Now we have to ping another machine on the LAN:

% ping -c5 192.168.1.2
PING 192.168.1.2 (192.168.1.2): 56 data bytes
64 bytes from 192.168.1.2: icmp_seq=0 ttl=64 time=0.726 ms
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.766 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.700 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.747 ms
64 bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=0.704 ms

--- 192.168.1.2 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.700/0.729/0.766/0.025 ms

You could also use the machine name instead of 192.168.1.2 if you have set up the /etc/hosts file.
11.8.3.2 Troubleshooting

Troubleshooting hardware and software configurations is always a pain, and a pain which can be alleviated by checking the simple things first. Is your network cable plugged in? Have you properly configured the network services? Did you configure the firewall correctly? Is the card you are using supported by FreeBSD? Always check the hardware notes before sending off a bug report. Update your version of FreeBSD to the latest STABLE version. Check the mailing list archives, or perhaps search the Internet.

If the card works, yet performance is poor, it would be worthwhile to read over the tuning(7) manual page. You can also check the network configuration as incorrect network settings can cause slow connections.

Some users experience one or two “device timeout” messages, which is normal for some cards. If they continue, or are bothersome, you may wish to be sure the device is not conflicting with another device. Double check the cable connections. Perhaps you may just need to get another card.

At times, users see a few “watchdog timeout” errors. The first thing to do here is to check your network cable. Many cards require a PCI slot which supports Bus Mastering. On some old motherboards, only one PCI slot allows it (usually slot 0). Check the network card and the motherboard documentation to determine if that may be the problem.

“No route to host” messages occur if the system is unable to route a packet to the destination host. This can happen if no default route is specified, or if a cable is unplugged. Check the output of netstat -rn and make sure there is a valid route to the host you are trying to reach. If there is not, read on to Chapter 31.

“ping: sendto: Permission denied” error messages are often caused by a misconfigured firewall. If ipfw is enabled in the kernel but no rules have been defined, then the default policy is to deny all traffic, even ping requests! Read on to Chapter 30 for more information.

Sometimes performance of the card is poor, or below average. In these cases it is best to set the media selection mode from autoselect to the correct media selection. While this usually works for most hardware, it may not resolve this issue for everyone. Again, check all the network settings, and read over the tuning(7) manual page.

Tuesday, January 6, 2009

Qemu|在BSD下使用qemu开源的虚拟机

在BSD下使用qemu开源的虚拟机

大家在windows 下都用什么虚拟机?可能大多数都是用VM ware 吧,那在BSD下呢?在我还用4.10的时候我也是用VM ware,但是VM ware是要授权文件的,不过这个文件是可以下载到的。但是现在,在BSD下,有了更好的选择,那就是qemu,一个开源的虚拟机,小巧而快速,好了不多说,我现在 是在BSD下打算虚拟出一个win来,并且让 win能上网


1 首先,用ports安装

CODE:
[Copy to clipboard]
#cd /usr/ports/emulators/qemu
#路径不怎么记得了,不好意思

CODE:
[Copy to clipboard]
#make WITH_KQEMU=yes install clean
#这里有个选项,with_kqemu,当初我就是没装个,导致出错,用了这个选项后 会在BSD启动时加入 kqemu.ko
然后就是几分钟的时间,很快的就可以装好qemu了(呵呵,比VM 时间短)


2 接下来就是使用qemu了,
首先建议您重启BSD,当然,不重启也可以,用下面的步骤就可以了:

CODE:
[Copy to clipboard]
#rehash
#kldload kqemu.ko
3 要用虚拟机,当然先要为虚拟机准备一块磁盘,这里推荐使用img格式的文件做为虚拟磁盘,当然,qemu兼容vm的文件,有兴趣你也可以试试。个人感觉似乎img的磁盘文件会更快点。往下看

CODE:
[Copy to clipboard]
#mkdir /tmp/qemu #找个地方安装你的虚拟机,要注意下自己的空间哦,不要像我,直接放在了 /下,造成空间不足。强烈建议你先 df -h下


CODE:
[Copy to clipboard]
#cd /tmp/qemu
#qemu-img create windows.img 2G #这个就是创建虚拟机磁盘,后面的2G意思是创建一个2G的磁盘
4 接下就是要安装虚拟机了,我有两手准备,一是光驱,二是ISO文件。下面就开始安装

CODE:
[Copy to clipboard]
#qemu -hda windows.img -cdrom /dev/acd0 -boot d -m 512 -enable-audio -localtime
解释下上面的语法:
-hda 是指定硬盘,在本文里我们使用的是刚才创建的/tmp/qemu/windows.img

-cdrom 指定使用光驱,这个参数后面必须要跟个文件名,在上面的例子里我用的是我的物理光驱/dev/acd0,如果你要使用ISO文件,那就写上文件的路径,比如我第二安装时用的就是/mtn/e/xp.iso


-m 是指定虚拟机使用的内存大小,后面的数字即是你要指定的内存数,我的是512M

-boot 当然就是指定虚拟机启动用的设备,-boot后可以选择的参数是 a ,c ,d .其中a 是指从软盘启动,c 就是用硬盘启动,d 当然就是光驱启动了。

-enable-audio 这个意思我就不说了。

-localtime 就是说要使用你的实际主板bios上的时间。

好了,按以上的步骤做了以后,就可以顺利的进入虚拟机了,并开始安装了。

*注意:如果你在安装QEMU没有选择 WITH_KQEMU,那么你将不能使用ISO文件来安装,这一点要注意。要想自己是否安装了kqemu.ko就自己看下:

CODE:
[Copy to clipboard]
#kldstat
下面是引用Linux下的Qemu的使用,由天Qemu是跨平台的,所以应该通用,当然,我只是为可能出现的问题提供一个解决参考:

CODE:
[Copy to clipboard]
安装过程中,要求换盘:

在qemu中按ctrl+alt+2切换到qemu monitor模式 输入?或help可以查看可用命令及使用说明。

(在其他版本的qemu中,运行qemu加载OS后,这个shell就会自动变成qemu monitor模式)

change device filename -- change a removable media

看来它就是用来换盘的了 : change cdrom /rhel4/EL_disc2.iso
5 虚拟机装好以后就可以用了,这里要给大家说几个常用的快捷键:

CODE:
[Copy to clipboard]
ctrl+alt+F 全屏切换
ctrl+alt 鼠标在虚拟机和主机间切换
6 虚拟XP上网的问题:
其实用上面的方法安装完后,你的XP已经能上网了,当然你要用DHCP方式。你也可以在启动时加上 -user-net 这个参数。我觉得qemu可能是默认就带了这个参数了,因为我没用任何参数就可以上网。

不过要说的是,采用这种默认的参数你只能 ping 你的BSD主机,不能ping 外网的,而且你得到的IP是10.0.2.X,Gateway 也一定是10.0.2.2,所以你不要奇怪。这种上网方式主机跟虚拟机的通讯不方便,至少我的samba就不行,也没有解决掉。

qemu也提供了第二种上网方案:tun方式,这个方式其实就是在你的BSD下虚拟一张网卡tun0,这样你的BSD就是双网卡上网,这种方式最大好处就是虚拟机跟主机还有外网通讯比较方便。不过首先你的内核要支持tun设备才行。我的是5.4 release-p6

针对5.0以前的应该先这样做:

CODE:
[Copy to clipboard]
#cd /dev
# sh MAKEDEV tun0
如果你跟我一样,是5。X那就先:

CODE:
[Copy to clipboard]
#mknod tun0 c 20 0
#ls /dev
接下来:

#ifconfig tun0 XXX.XXX.XXX.XXX #设定tun0的IP,一般用192.168开头的,也有人喜欢10开头的,随便啦,我的是192.168.0.1

然后进入虚拟机XP里,设定你的IP为:192.168.0.XXX,网关为 192.168.0.1(*也就是tun0)dns 就是BSD主机的dns。

这样设定之后,虚拟机还不能上网,但已经能用samba 了。要想用虚拟机上网,这就要用到nat 了,设置方法完全跟NAT是一样的,我就不多说了,下面的东西就只有请你参考FreeBSD 的NAT来完成了。


Article submitted by Michael Williamson. We are running out of articles! Please help DPOTD and submit good articles about software you like!

QEMU lets you emulate a machine —in other words, you can run a virtual computer on top of your real computer. This makes it perfect for trying and testing the latest release of a distribution, running older operating systems, or just testing.

So, let’s say you wanted to run a LiveCD, which you have stored on your hard drive. Easy enough! We just type:

qemu -cdrom path/to/livecd.iso -boot d

The -cdrom option tells QEMU the path to the CD you want to use, while -boot dictates what device we’re booting from —in this case, we want to boot from the CD, which is always device d.

You might get a message about kqemu —you can safely ignore this for now.

Alternatively, you may want to boot from a real CD in your computer —so, you simply use the path to your CD drive in /dev. For instance, if your CD drive is /dev/hdc, then we would use:

qemu -cdrom /dev/hdc -boot d

Of course, we don’t just want to use CDs all the time —we might want to actually install something! So, we’ve got to make a hard drive image first. This is achieved by using qemu-img, like so:

qemu-img create virtualharddrive.qcow 5G -f qcow

This creates an image called virtualharddrive.qcow, which is 5 gigabytes big. If you wanted it to be 5 megabytes, you could type 5M instead, for ten gigabytes, type 10G, and so on.
Finally, the -f option tells qemu-img what format you want to use. While there are a few to choose from, qcow is the norm - it works well enough, and only takes up the space on the hard drive that it needs. If the virtual hard drive had a capacity of 5 gigabytes, but only contained 2 gigabytes of data, then it would only take up about 2 gigabytes on your real hard disk.

So, now we want to get installing. Simply type:

qemu virtualharddrive.qcow -cdrom path/to/installcd.iso -boot d

Then, you can simply follow the instructions just as with an ordinary installation.

Now, not all distributions come on one CD —in some cases, you’ll need to swap CDs. To achieve this, we need to do two things. First of all, we make the QEMU monitor appear on the command line by adding the option -monitor stdio, so we end up with something like:

qemu virtualharddrive.qcow -cdrom path/to/installcd.iso -boot d -monitor stdio

When you run this command, QEMU should let you enter commands. To change CDs, simply type in the commands:

eject cdrom

change cdrom path/to/newcd.iso

Voila! The virtual machine should now have changed CDs so you can continue the installation. Naturally, you can change CDs at any time, not just during installation.

Once the installation has finished, you’ll want to boot from the hard drive. Since QEMU does this by default, simply remove the -boot d part of the command:

qemu virtualharddrive.qcow -cdrom path/to/installcd.iso -monitor stdio

If you have no intention of using the CD after the installation, then you can cut that out as well:

qemu virtualharddrive.qcow -monitor stdio

This should let you play around with your newly installed system at your heart’s content without endangering your own PC. If you want to fiddle with something, but don’t want the changes written to the image, then add the option -snapshot. If, after using this option, you decide that you actually want to save the changes made to the hard drive, then simply type commit into the QEMU monitor, and the changes will be written.

While these commands work, unless you’re using lightweight distributions, you might find things going a little slowly. This is due to QEMU, by default, only taking up 128MB of RAM. You can increase the amount available by using the -m option, followed by the amount of RAM in megabytes. For instance, if I wanted to allocate 256MB to QEMU for running a LiveCD, then I would type:

qemu -cdrom path/to/livecd.iso -boot d -m 256

That should speed things up nicely! But don’t give QEMU too much memory —you want some left for your other applications. Unfortunately, things are probably still fairly slow— to speed things up even more, you’ll probably want to use kqemu, otherwise known as the QEMU accelerator.

Installing kqemu from the repositories is reasonably straightforward. First of, grab the kqemu-source package —if you apt-get is your package manager of choice, then the command used is:

apt-get install kqemu-source

If you don’t have module assistant already, you’ll need that installed as well:

apt-get install module-assistant

Then, type in the following commands (as root):

m-a prepare

m-a auto-install kqemu

That should be it! Now, every time you want to use the kqemu module, you first need to become root, and then type:

modprobe kqemu major=0

Then, as an ordinary user, QEMU will automatically use kqemu, which should help speed things up. If QEMU complains that it still cannot use kqemu, then you might not have the necessary permissions —try typing the following as root:

chmod 666 /dev/kqemu

Hopefully, kqemu should now be usable by QEMU.

There is one final option: -kernel-kqemu. This, in theory, speeds up the emulation even further. Unfortunately, it isn’t as simple as that. Firstly, the version of QEMU in the Debian repositories cannot use -kernel-kqemu. Secondly, even if it could, not all guest operating systems would work with this enabled —for instance, a recent distribution of GNU/Linux would probably work faster with this option (if it worked!), but Windows 98 just crashes.

QEMU is available from Debian Sarge and Ubuntu Warty.


虚拟机qemu的使用

Redflag Workstation 下已经带了qemu

#qemu-img create windows.img 2G #这个就是创建虚拟机磁盘,2G大小

#qemu -hda windows.img -cdrom /dev/acd0 -boot d -m 512 -enable-audio -localtime

-hda 是指定硬盘

-cdrom 指定使用光驱,这个参数后面必须要跟个文件名,可以是物理光驱/dev/hda,可以使用ISO文件,为文件的路径

-m 是指定虚拟机使用的内存大小,如512M

-boot 指定虚拟机启动用的设备,-boot后可以选择的参数是 a ,c ,d .其中a 是指从软盘启动,c 就是用硬盘启动,d 是光驱启动。

-enable-audio

-localtime 使用实际主板bios上的时间。

应该可以顺利的进入虚拟机了,并开始安装了。

Redflag Workstation 下已经带了qemu

#qemu-img create windows.img 2G #这个就是创建虚拟机磁盘,2G大小

#qemu -hda windows.img -cdrom /dev/acd0 -boot d -m 512 -enable-audio -localtime

-hda 是指定硬盘

-cdrom 指定使用光驱,这个参数后面必须要跟个文件名,可以是物理光驱/dev/hda,可以使用ISO文件,为文件的路径

-m 是指定虚拟机使用的内存大小,如512M

-boot 指定虚拟机启动用的设备,-boot后可以选择的参数是 a ,c ,d .其中a 是指从软盘启动,c 就是用硬盘启动,d 当然就是光驱启动了。

-enable-audio

-localtime 使用实际主板bios上的时间。

应该可以顺利的进入虚拟机了,并开始安装了。

安装过程中,要求换盘: 在qemu中按ctrl+alt+2切换到qemu monitor模式 输入?或help可以查看可用命令及使用说明。 (在其他版本的qemu中,运行qemu加载OS后,这个shell就会自动变成qemu monitor模式)

change device filename — change a removable media

如change cdrom /tmp/xp1.iso

常用的快捷键:

ctrl+alt+F 全屏切换

ctrl+alt 鼠标在虚拟机和主机间切换
虚拟机上网设置两种方式:

1. user mode network :
这种方式实现虚拟机上网很简单,类似vmware里的nat,qemu启动时加入-user-net参数,虚拟机里使用dhcp方式,即可与互联网通信,但是这种方式虚拟机与主机的通信不方便。

2. tap/tun network :
这种方式要比user mode复杂一些,但是设置好后 虚拟机互联网 虚拟机主机 通信都很容易
这种方式设置上类似vmware的host-only,qemu使用tun/tap设备在主机上增加一块虚拟网络设备(tun0),然后就可以象真实网卡一样配置它.

前提:

首先内核中支持tap/tuns设备:
Device Drivers —>
Networking support —>
[M] Universal TUN/TAP device driver support

在Redflag Workstation中已经有了支持

如果没有编译内核模块:make modules

将它cp到当前内核的模块目录的相应位置:
cp /usr/src/linux/drivers/net/tun.ko /lib/modules/`uname -r`/kernel/drivers/net
重新建立模块依赖关系:
depmod

再加载就OK了

如果成功了应该存在设备文件 /dev/net/tun

若使用这种方式需要以下几步:
a.需要一个tun/tap的初始化脚本 :
/etc/qemu-ifup :
#!/bin/sh
/sbin/ifconfig $1 172.20.0.1

再给予qemu-ifup x执行权限放在/etc下就可以了,这是有qemu自动执行的
这个脚本只能root用户执行,如果需要普通用户使用qemu,就需要改成sudo /sbin/ifconfig …..再设置sudo相关权限。 启动qemu后,它会在主机上增加一块虚拟网络设备(tun0)

b.设置虚拟机网络参数

和vmware host-only一样:
ip与tun0相同网段,gateway为tun0 ip 其余参数与tun0相同,dns与主机相同:
tun0 : ip :172.20.0.1 broadcast:172.20.255.255 netmask :255.255.0.0
qemu : ip :172.20.0.100 broadcast:172.20.255.255 netmask :255.255.0.0 gateway:172.20.0.1

与host-only一样,这样只实现了虚拟机主机间通信,还需要设置router,nat才可以连上互联网
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 172.20.0.0/24 -j MASQUERADE

图形界面的使用:

首先安装qemu
我使用Debian, 一句apt-get install qemu命令即可安装, 或者你使用其它的方法.

安装qemu的图形界面前端qemu-laucher
因为我也不是完全的命令行爱好者, 所以我安装qemu-laucher来启动运行qemu. 见截图:

设置qemu, 安装WinXP
从桌面菜单启动qemu-launcher后, 1. 取消Snapshot Mode, 因为这个选项表示只有你按Ctrl+a s后才将虚拟机的运行结果写入虚拟机的磁盘文件.

2.选中Use CD-ROM, 因为我们需要光驱安装操作系统.

3. 在Hard Disk 0 一栏里填入你的虚拟磁盘在Linux下的文件, 只需要填入, qemu自会创建.

4. 默认内存为128MB, 你可以设置为192MB. 太大了qemu会无法运行虚拟机.

5. CPU, 声卡, 显卡等设置

Sunday, January 4, 2009

svn|命令

svn命令 通常都有帮助,可通过如下方式查询:

$ svn help 

知道了子命令,但是不知道子命令的用法,还可以查询:

$ svn help add 

开发人员常用命令

(1) 导入项目

$ cd ~/project
$ mkdir -p svntest/{trunk,branches,tags}
$ svn import svntest https://localhost/test/svntest --message "Start project"
...
$ rm -rf svntest

我们新建一个项目svntest,在该项目下新建三个子目录:trunk,开发主干;branches,开发分支;tags,开发阶段性标签。然后导入到版本库test下,然后把svntest拿掉。

(2) 导出项目

$ svn checkout https://localhost/test/svntest/trunk

修订版本号的指定方式是每个开发人员必须了解的,以下是几个参考例子,说明可参考svn推荐书。

$ svn diff --revision PREV:COMMITTED foo.c
# shows the last change committed to foo.c

$ svn log --revision HEAD
# shows log message for the latest repository commit

$ svn diff --revision HEAD
# compares your working file (with local changes) to the latest version
# in the repository

$ svn diff --revision BASE:HEAD foo.c
# compares your “pristine” foo.c (no local changes) with the
# latest version in the repository

$ svn log --revision BASE:HEAD
# shows all commit logs since you last updated

$ svn update --revision PREV foo.c
# rewinds the last change on foo.c
# (foo.c's working revision is decreased)

$ svn checkout --revision 3
# specified with revision number

$ svn checkout --revision {2002-02-17}
$ svn checkout --revision {15:30}
$ svn checkout --revision {15:30:00.200000}
$ svn checkout --revision {"2002-02-17 15:30"}
$ svn checkout --revision {"2002-02-17 15:30 +0230"}
$ svn checkout --revision {2002-02-17T15:30}
$ svn checkout --revision {2002-02-17T15:30Z}
$ svn checkout --revision {2002-02-17T15:30-04:00}
$ svn checkout --revision {20020217T1530}
$ svn checkout --revision {20020217T1530Z}
$ svn checkout --revision {20020217T1530-0500}

(3) 日常指令

$ svn update

$ svn add foo.file
$ svn add foo1.dir
$ svn add foo2.dir --non-recursive
$ svn delete README
$ svn copy foo bar
$ svn move foo1 bar1

$ svn status
$ svn status --verbose
$ svn status --verbose --show-updates
$ svn status stuff/fox.c

$ svn diff
$ svn diff > patchfile

$ svn revert README
$ svn revert

修改冲突发生时,会生成三个文件:.mine, .rOLDREV, .rNEWREV。比如:

$ ls -l
sandwich.txt
sandwich.txt.mine
sandwich.txt.r1
sandwich.txt.r2

解决修改冲突方式之一:修改冲突的文件sandwich.txt,然后运行命令:

$ svn resolved sandwich.txt

方式之二:用库里的新版本覆盖你的修改:

$ cp sandwich.txt.r2 sandwich.txt
$ svn resolved sandwich.txt

方式之三:撤销你的修改,这种方式不需要运行resolved子命令:

$ svn revert sandwich.txt
Reverted 'sandwich.txt'
$ ls sandwich.*
sandwich.txt

确保没问题后,就可以提交了。

$ svn commit --message "Correct some fatal problems"
$ svn commit --file logmsg
$ svn commit

(4) 检验版本历史

$ svn log
$ svn log --revision 5:19
$ svn log foo.c
$ svn log -r 8 -v

$ svn diff
$ svn diff --revision 3 rules.txt
$ svn diff --revision 2:3 rules.txt
$ svn diff --revision 4:5 http://svn.red-bean.com/repos/example/trunk/text/rules.txt

$ svn cat --revision 2 rules.txt
$ svn cat --revision 2 rules.txt > rules.txt.v2

$ svn list http://svn.collab.net/repos/svn
$ svn list --verbose http://svn.collab.net/repos/svn

$ svn checkout --revision 1729 # Checks out a new working copy at r1729

$ svn update --revision 1729 # Updates an existing working copy to r1729

(5) 其他有用的命令

svn cleanup

为失败的事务清场。

(6) 分支和合并

建立分支方法一:先checkout然后做拷贝,最后提交拷贝。

$ svn checkout http://svn.example.com/repos/calc bigwc
A bigwc/trunk/
A bigwc/trunk/Makefile
A bigwc/trunk/integer.c
A bigwc/trunk/button.c
A bigwc/branches/
Checked out revision 340.

$ cd bigwc
$ svn copy trunk branches/my-calc-branch
$ svn status
A + branches/my-calc-branch

$ svn commit -m "Creating a private branch of /calc/trunk."
Adding branches/my-calc-branch
Committed revision 341.

建立分支方法二:直接远程拷贝。

$ svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/branches/my-calc-branch \
-m "Creating a private branch of /calc/trunk."

Committed revision 341.

建立分支后,你可以把分支checkout并继续你的开发。

$ svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch

假设你已经checkout了主干,现在想切换到某个分支开发,可做如下的操作:

$ cd calc
$ svn info | grep URL
URL: http://svn.example.com/repos/calc/trunk
$ svn switch http://svn.example.com/repos/calc/branches/my-calc-branch
U integer.c
U button.c
U Makefile
Updated to revision 341.
$ svn info | grep URL
URL: http://svn.example.com/repos/calc/branches/my-calc-branch

合并文件的命令参考:

$ svn diff -r 343:344 http://svn.example.com/repos/calc/trunk
$ svn merge -r 343:344 http://svn.example.com/repos/calc/trunk
$ svn commit -m "integer.c: ported r344 (spelling fixes) from trunk."
$ svn merge -r 343:344 http://svn.example.com/repos/calc/trunk my-calc-branch
$ svn merge http://svn.example.com/repos/branch1@150 \
http://svn.example.com/repos/branch2@212 \
my-working-copy
$ svn merge -r 100:200 http://svn.example.com/repos/trunk my-working-copy
$ svn merge -r 100:200 http://svn.example.com/repos/trunk
$ svn merge --dry-run -r 343:344 http://svn.example.com/repos/calc/trunk

最后一条命令仅仅做合并测试,并不执行合并操作。

建立标签和建立分支没什么区别,不过是拷贝到不同的目录而已。

$ svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/tags/release-1.0 \
-m "Tagging the 1.0 release of the 'calc' project."

$ ls
my-working-copy/
$ svn copy my-working-copy http://svn.example.com/repos/calc/tags/mytag
Committed revision 352.

后一种方式直接把本地的工作拷贝复制为标签。

此外,你还可以删除某个分支。

$ svn delete http://svn.example.com/repos/calc/branches/my-calc-branch \
-m "Removing obsolete branch of calc project."

管理人员常用命令

(7) 版本库管理

$ svnadmin help
...
$ svnadmin help create
...
$ svnadmin create --fs-type bdb /usr/local/repository/svn/test
$ chown -R svn.svn /usr/local/repository/svn/test

建立版本库,库类型为bdb(使用Berkeley DB做仓库),库名称为test。
svn版本库有两种存储方式:基于Berkeley DB(bdb)或者基于文件系统(fsfs),通过 –fs-type可指定存储方式。

(8) 查询版本库信息

$ svnlook help
...
$ svnlook help tree
...
$ svnlook tree /usr/local/repository/svn/test --show-ids

咏春拳|和太极拳一起学

佛山咏春拳作为南派传统武术的著名拳种之一,具有招式多变、运用灵活、出拳弹动、短桥窄马、擅发寸劲等特点。套路主要有小念头、寻桥和标指三套拳及木人桩,对抗训练为黐手。

黐手是咏春拳特有的双人攻防对抗训练,由两人面对面互搭双手,以咏春拳的耕拦摊膀、推托拉按、缠撞挂漏等手法互为攻防。熟练有成者可以双双用布条蒙住双眼,在八仙桌上救手攻防,把对手打落下桌为胜,称为“蒙眼救手”。所以咏春拍手要求练习者的双手练就极好的知觉。

我跟招源、陆柏衡、谢国钲三位佛山的师傅学习咏春拳多年,已将“蒙眼救手”运用自如与武林界的朋友曾多次友好切磋,让对方深感咏春拳在近身搏击中有显著的功效。但在各场切磋过程中心有所动,总感觉传统的佛山咏着拳也有不足之处,但又苦于找不出突破点。在取得2000年的首届佛山、广州、香港、澳门四地咏春救手擂台邀请赛85公斤级冠军后,我开始思考咏春拳技击方法的一些创新探索。在一个机缘巧合的情况下,我和来自陈家沟的张师傅来了一场咏春与太极的比试。就因这场比试我俩成为好友,也互相传授术,从而促使我将两家拳术揉合于一起。

经过对咏春拳和太极拳技击方法的大量比较试验,我认为咏春拳与太极拳在技击招式上的取长补短、相互糅合非常可行,而且大有裨益。

首先,咏春拳和太极拳(尤其是陈式太极拳)在练习关系上有不少相似之处。太极拳拳架为体,散手为用,黐手介于其向。而咏春攀登路为体,散打为用,酒手介于其间,其次在身法上,太极拳有掤捋挤按、采捋靠、进退顾盼定,而咏春拳的身法则有耕拦摊膀、推托拉按、缠撞挂漏,曲手留中、甩手直冲、以桥占桥等,其实技击含义是非常相似的。在手法上更是有异曲同工之妙,如咏春拳最有特点的摊伏手,摊手一出则似太极的顺缠,伏手一收则似太极的逆缠。咏春拳有螺旋劲,太极拳有缠丝劲。从心法上讲,咏春拳的连消带打、以快打快与太极拳的引进落空、后发先至简直同出一辙。实际上,中华传统武术的拳良多都是相通的。

正因为咏春拳和太极拳这一南一北著名的拳种有许多相通的拳理,使两种拳术在实战中的探合有了先天良好的基础。咏春拳在搏击时凭手臂皮肤知觉粘住对方的手,用耕、拦。膀、摊伏手等手法去击打对方。但有时两者在博击中又会出现搂打缠绕在一起的时候,这时陈式太极的快摔又起很大的作用,运用螺旋劲将对方摔倒,摔打过程中不能用蛮力。在咏春拳和太极拳的探合实践中,我体会最深的是,取咏春拳的短线消打,结合太极拳的缠丝弹抖,先曲中求直,以短桥窄马催动寸劲化解对方进攻,进而似太极拳的旋腰缠丝,由直转曲,以采拿或肘靠将其摔打重创,以佛山咏春拳的知觉、技击手法和陈式太极拳的快摔结合。两家拳种所发出的功劲基本相同,不同的地方只是咏春拳许多手法向内旋直线打出,兼走细内圈,陈式太极拳出拳向外旋而且带有缠丝劲,所走的是外大困,正因如此,两家拳术在技击中正好互补不足。如此结合,快上加快,屡有奇效!

举例说,咏春勾漏手是李小龙最著名的制胜手法。勾漏手的打法是手腕向外扣,手指向下,使人手可以形成一个钢勾将对方的手向外勾离人体子午线,在运用时手腕不能在整个过程灌力,要松、柔、刚三位一体才能完整,恰到好处。当然,由勾漏手变成横掌痛击对方身体是完全的咏春的打法,若与太极探合,则可以勾漏手消去对方的攻击点后,趁对方的人体子午线出现空当,顺势进步贴身靠将其打倒在地,非常奏效。

又如,以咏春的伏手为例。伏手是咏春拳中常用制敌的手法,学咏春拳不学好伏手就等于是白学了。伏手能在离身和近身搏击中完全控制对手的直捶和各路底掌,运用时是靠腕劲打对手的手桥和腿。如在离身搏击时,对手面对面瞬间向你打一拳,你在对手的拳差不多到时运用伏手将对方的拳向斜下方击打(这与太极的道破何其相似,只是线路短很多),再反变拳打向对手面门上,这是咏春最本能的打法。若是想将对方摔打倒地则探合太极的身法是顺理成章的:先偏身以伏手引进对方落空,伏手反弹以转腰顺缠再加上腿脚的顶绊将其螺旋摔倒。

上述两种反击的举例,其主要目的是要令对方受击倒地,以便自己连续进货控制主动。简单来说就是先改化(太极)为打(咏春),再不间断地由打(咏春)变摔(太极),将二者有机地结合起来综合运用而已。当然,真正打起来,奥妙之处难以用文字解说。

当这两种拳术糅合在一起时,又会变化出许多擒拿和反擒拿的手法出来,这是两家拳术中的螺旋劲和缠丝劲融合于一起,所产生的内外旋劲的作用反应,使运用者在运动中有得心应手的知觉。只要运用者在应接对方的手的同时不要马上抽回,而是黏住对方的手直入,对方的关节用擒拿手法将其锁住,然后用推接的手法将其摔倒在地。如果被对方用擒拿手法扣住时,也可以用咏春拳的手法化解的同时反擒对方。用咏春拳化解擒拿手的方法很简单,只要你将肘归中,然后你的身体走偏使对方进入你的网,将其反擒拿后以太极的摔法击倒。

“练习这两种拳术的探合时注意,不要盲目追求招式,一定要在功劲方面下苦功。如果没有将自身的死力去除,将腰胯练松,那么你就不能有效地化解对手的劲力,反被对方击实。要抽出不少时间练习咏春拳反应。也不能忽视太极腿上功夫。所以说到底也是为了达到“刚柔相济,内外兼修”的目的。

之所以将这两种南北拳术糅合在一起运用,纯粹是自己的喜爱而已,并非为了标新立异。但凡武林中人都明白,从来就没有全无敌的“绝招”,所谓拳无定式,任何招式在实战中能克敌制胜便是好功夫。将这两种南北博大精深的拳种释合应用,需要对这两种拳法都有研究、练习,个中艰辛只有付出的人才能体会。不过我始终相信,懂得多一点总比不思进取要好,探索实践多一点总比夸夸其谈要好。

佛山古来尚武之风大盛,学武之人在其中便如种子得遇沃土般幸运。这几年我对传统武术运用上的这一点点尝试,得到了佛山武林同仁的爱护和支持,不至于无端背上“胡乱造拳、炒作出位”的罪名,所以我感谢佛山精武会一直倡导的“摒弃门户之见”的理念和提供给我的实践资源。而在2004年11月的佛山武术节暨首届全国武术功力大赛闭幕式上,我和演练拍档陈卫文在晚会表演中将这些成果展示出来并得到良好的反响、让我深深体会到佛山武林自古的兼容。在佛山这—武术名城中,南拳北腿一家亲!