Getting a list of logical and physical drives from the command line

Standard

It’s often useful to know what logical and physical drives are available to Windows, and sometimes this needs to be done from the command line.

Logical drives

Here’s a handy command to return a list of logical drives in Windows.

The Win32_LogicalDisk WMI class represents a data source that resolves to an actual local storage device on a computer system running Windows. While Caption, Description, DriveType, ProviderName, and VolumeName are useful in most cases, more properties are available, and a complete list is available at http://msdn.microsoft.com/en-us/library/windows/desktop/aa394173(v=vs.85).aspx. The output will be formatted as a table, the properties will be the column headings, and they will be placed into alphabetical order.

Caption is the drive letter of the logical disk. The Name property also returns the drive letter.

Description is the type of disk. For example: Local Fixed Disk, CD-ROM Disc, or Removable Disk.

DriveType is returned as an integer that corresponds to the type of disk drive the logical disk represents (and this matches the Description, making DriveType sort of superfluous).

0 = Unknown
1 = No Root Directory
2 = Removable Disk
3 = Local Disk
4 = Network Drive
5 = Compact Disc
6 = RAM Disk

ProviderName is the network path to the logical device.

VolumeName is the volume name of the logical disk.

Physical drives

And here is a command to return a list of physical drives.

The Win32_DiskDrive WMI class represents a physical disk drive as seen by a computer running Windows. Like the Win32_LogicalDisk WMI class, it has lots of properties, as listed at http://msdn.microsoft.com/en-us/library/windows/desktop/aa394132(v=vs.85).aspx.

For simplicity, though, and ease of reading in command window, wmic diskdrive list brief /format:list does the trick, particularly in combination with wmic logicaldisk.

631 total views, no views today

More Trickiness With SSH

Standard

http://nick.zoic.org/art/etc/ssh_tricks/

 

More Trickiness With SSH

I saw an article on reddit about SSH trickery. SSH is a very subversive protocol, able to work around many kinds of unwise security policies. Here’s a couple more useful things to know.

1. Better Lurking Through .ssh/config-ery.

Where you’ve got machines lurking behind other machines, inaccesible from the Internet, you can add a clause like this to your .ssh/config file:

Host: lurker
ProxyCommand: ssh gateway.work /bin/nc %h %p
This causes ‘ssh lurker’ to open an ssh connection to gateway.work, then use nc (may be called netcat on your system, or you may have to install it yourself) to connect on to lurker (the %h %p interpolates the target hostname and port into the proxy command)

2. Reverse Tunnelling

So you’ve noticed the -L option, right, and you understand that by running:

ssh -L 3128:localhost:3128 gateway.home
you are establishing a tunnel home to your proxy server, and you can now configure your web browser to use localhost:3128 as its proxy server to keep your web traffic private.

But did you know this one? Let’s say you’ve got a machine stuck out in DMZ land and you want to apt-get upgrade the poor thing, pronto. You can’t access the web from this box: security policy. You can’t access your internal proxy: ditto. All you can do is ssh into it. Try this:

ssh -R 3128:proxy.work:3128 dmzbox.work
From your shell on dmzbox, you can now configure the http proxy as localhost:3128 and start sucking down packages via the reverse tunnel.

3. Tunnel Tunnelling

Every now and then, you need to get control of a box which is sadly hidden away behind a broken hotel NAT network or some kind of Get Smart style VPN setup. You can’t even get an ssh in. It’s either read Unix commands over an international phone line at 3am your time, or train a pigeon to tap out the following:

ssh -L 2222:localhost:22 gateway.work
which, when run on the remote box, opens an ssh tunnel back home, through which you can ssh back into the remote box with ssh -p 2222 localhost

4. ssh tunnels with tap and -w

There’s also a (newish) “-w” option, which turns ssh into a full-on VPN solution rather than just a port-at-a-time port forwarder.

The useful piece of information which I haven’t seen elsewhere is this: you don’t need to allow root ssh logins to use it. Instead, you can use ‘tunctl’ to preconfigure tun or tap devices on each end with the -u option to set their permissions to a non-root user. The easiest place to do this, on Debian/Ubuntu systems, is in /etc/network/interfaces, for example, in host1:/etc/network/interfaces:

auto tap9
iface tap9 inet static
pre-up tunctl -u nick -t $IFACE
post-down tunctl -d $IFACE
address 10.1.9.1
netmask 255.255.255.0
and in host2:/etc/network/interfaces:

auto tap9
iface tap9 inet static
pre-up tunctl -u nick -t $IFACE
post-down tunctl -d $IFACE
address 10.1.9.2
netmask 255.255.255.0
Now you can ‘ifup’ those interfaces, and then start the VPN by running:

user@host2$  ssh -o Tunnel=Ethernet -w9:9 host1
And the tunnel will be up and running, without needing to create the tunnel as root. You could easily take this one further for an automatic tunnel, setting

 

© 2009-2011 Nick Moore. Published at: http://nick.zoic.org/art/etc/ssh_tricks/

553 total views, no views today

Physical to Virtual in VirtualBox – VirtualBox P2V

Standard

From: Physical to Virtual in VirtualBox – VirtualBox P2V.

VirtualBox P2V Physical to Virtual in VirtualBox

This article explains how you can do VirtualBox P2V convert physical machine to virtual machine in Sun VirtualBox. It’s not straight forward method since there no tools available for VirtualBox P2V Physical to Virtual conversion. But still it’s possible with free VMware tool.

Before start the procedures, let me tell you how it’s going to work.

VirtualBox P2V

We will use a free VMware converter tool to convert physical  to virtual machine which will create VMX and VMDK files according to physical computer and disks configuration.

Then import the created VMDK file to VirtualBox as hard disk, create a virtual machine and boot from VMDK file hard disk. That’s it. It will work fine.

Don’t waste your time to search a tool VirtualBox P2V convert Physical to Virtual in VirtualBox directl, its not available till today if I’m not wrong.  If you are a VirtualBox fan and you want to try P2V and run in Sun VirtualBox, then this is the only VirtualBox P2V option available.

Physical to Virtual in VirtualBox – VirtualBox P2V – Step by step methods

1)      Download VMware Converter here

2)      Convert your physical computer to virtual using free VMware vCentre converter as mentioned here. Make sure you select correct physical partitions, processors and memory size for new virtual  machine. Don’t split the virtual disks during the conversion.

3)      Once successfully created, locate the VMX and VMDK files. Don’t bother about VMX files.

4)      Now add the newly created vmdk file to VirtualBox media manager as shown below.

VirtualBox P2V

5)      Read more about adding and accessing vmdk disk files in sun VirtualBox here. This article explains how you can access vmdk disk file as partition in side virtual machine in sun VirtualBox. We don’t require that much now. Just to know how to add vmdk file to sun VirtualBox media manger.

6)      After successfully added vmdk disk file, create a new virtual machine in VirtualBox. Select the correct guest OS, processor type and memory size. In virtual hard disk box  select ‘Use existing Hard Disk’ and browse the disk you added by vmdk file in VirtualBox media manager. So your new virtual machine will boot from vmdk disk which we converted from physical to virtual.

Physical to Virtual VirtualBox P2V

7)      That’s it. Boot the virtual machine now. It will be booting and working fine. Sometimes it may install additional required drivers on sun virtual machine. Let it complete and install the Sun guest additions  to get better display performance with additional features.

8)      You must see your physical computer on Sun VirtualBox as virtual machine now. This is the easiest method to convert Physical to Virtual in VirtualBox – VirtualBox P2V with free tool.

9)      If you are still interested in running pure sun VirtualBox machine with VDI files, you can convert your newly created VMDK files to VDI format with free tool as mentioned here. After created vdi file add it to media manager and boot virtual machine from vdi files.

If you face any problem let me know, we can solve it together. if I’m wrong about VirtualBox P2V tools tell me where I can download  it and do P2V in Sun VirtualBox in one shot.

Physical to Virtual VirtualBox P2V

804 total views, no views today

How to migrate existing Windows installations to VirtualBox

Standard

From: http://www.virtualbox.org/wiki/Migrate_Windows

Windows installations, unlike Linux, cannot easily be moved from one hardware to another. This is not just due to Microsoft’s activation mechanism but the fact that the installed kernel and drivers depend on the actual hardware.

This document explains the common pitfalls and how to workaround these. We assume that either a physical Windows installation or a VMware image is the source of migration. It is also assumed that a suitable virtual disk image (either VDI or VMDK for VirtualBox >= 1.4) is already present.

There’s a step by step description below. Continue reading

574 total views, no views today