Huge Discounts on Mobiles, Books, Cameras, Computers etc: @Flipkart
Flipkart.com

Friday, November 16, 2007

How to copy directories remotely in Linux

FTP/SFTP has commands like get and mget (put/mput) but they work only on a file or multiple files. Both commands cannot handle a directory. So how do you remotely copy a directory in linux, especially say between two Linux machines?

SCP - Secure Copy Protocol
To use the scp command to copy files between systems, use the following command:

scp filename1 userid@hostname:filename2

where filename1 is the file on the local system that you wish to copy, userid@hostname is the userid and hostname where you wish to copy it, and filename2 is the name you want to call the file on the remote system. For example:

scp /home/file1 root@mysystem.com:/root/file1

When you issue the command, you'll be prompted for the password on the remote system. You will then be given the stats of the transfer. Pay attention to the second item on the stat line; it's how much of the file got transferred (eg: 100%).

Note: SCP may also be used to copy files from a remote system to a local system. To do this in the first example above, reverse the order of filename1 and userid@hostname:filename2.

scp root@mysystem.com:/root/file1 /home/file1


To use the scp command to copy directories between systems, use the following command:

scp -r directoryname userid@hostname:directoryname2

where directoryname is the directory on the local system you wish to copy, userid@hostname is the userid and hostname where you wish to copy it, and directoryname2 is the name you want to call the file on the remote system. For example:

scp -r /home/ root@mysystem.com:/root/dir1

Note: SCP may also be used to copy directories from a remote system to a local system. To do this in the first example above, reverse the order of directoryname and userid@hostname:directoryname2.

scp -r root@mysystem.com:/root/dir1 /home/

How to increase the size of an existing VM - VMware

I created a new linux VM but it is set to a max of just 4GB. Once I started installing applications into it, soon my disk is full!! Tried using the VMware Server Console of VMware Server (a free VM hosting application and is much better than the VMware player). From the console you can change the Memory (RAM) in VM settings, but not hard disk size. Tried google and found the followings options:

1) Create a new clone/replica with increased disc size

2) Add another disc to the VM

3) Use the vdiskmanager command

I used the vdiskmanager command and following is the output:
D:\VM\linux_taddm>"C:\Program Files\VMware\VMware Server\vmware"-vdiskmanager -x 15GB linux_taddm.vmdk
Using log file C:\Users\admin\AppData\Local\Temp\vmware-admin\vdiskmanager.log
Grow: 100% done.
The old geometry C/H/S of the disk is: 522/255/63
The new geometry C/H/S of the disk is: 1958/255/63
Disk expansion completed successfully.

WARNING: If the virtual disk is partitioned, you must use a third-party utility in the virtual machine to expand the size of the partitions. For more information, see:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647


It increased the size of the disc from 4GB to 15GB in couple of minutes!

















You may also want to see these:
http://www.vmware.com/support/reference/common/virtual_disks.html
http://communities.vmware.com/message/290776

How to clone a Linux VM - VMware

I had to create a new Linux virtual machine, and I wanted it to be similar to one of the existing Linux Servers (RHEL 4). A colleague of mine told to try the free software called 'VMware Converter'. It can create a virtual machine out of a physical machine. I downloaded it and gave it a try. But unfortunately it can convert only a windows based machine to VM. If you have a windows machine, it can remotely connect to that machine and create a VM for you, which would be like a clone of the physical machine (heard it takes a long time, perhaps running overnight might be a good idea). But I have to clone a linux machine, so what do I do???

Tried googling and came upon many options.

1) http://www.vmware.com/products/converter/faqs.html
Says that experimental support available for Linux-based physical to virtual machine conversions using the Vmware Converter BootCD (cold cloning) if the source physical machine has SCSI disks.
Also read: http://communities.vmware.com/thread/76266

This blog explains how to do the above:
http://virtualaleph.blogspot.com/2007/04/cloning-linux-machine-with-converter.html
It is a bit complex and you have to do a few configuration steps to get the VM running.

2) Using g4l, Ghost for Linux
http://www.windley.com/archives/2007/08/p2v_how_to_make_a_physical_linux_box_into_a_virtual_machine.shtml

3) P2V instructions for Linux
http://vmwiz.com/


All the above didn't seem quite viable. I tried creating a new VM using ESX Server, but when I powered up the VM it said "Missing operating system". I thought of cloning one of the other linux VMs in the ESX server, but you need 'Virtual Center" for that. Then suddenly the 'idea bulb' lighted and I remembered that VMware converter had an option to select a ESX server
as source. Voila!! so easy and I created a new virtual machine within a few minutes (took me just 10 mins)!!!