在Windows7下访问LVM2

来源:http://www.squidoo.com/accessing-an-lvm2-volume-in-windows#module13366671

================ 

LVM2 Virtual Volumes in Windows

If you use both windows and Linux in a dual booting environment, sharing volumes between them is a common requirement. As volume systems go, LVM2 is very handy and progressive.

However, getting to a partition setup with LVM2 while Windows is booted can be a problem. How can this be done in fail safe way?

I tried a number of methods, which I will discuss, but to get you to the information you want first, I will show the one thing that worked first. This method will consistently work even on something else, like a Mac or Solaris box, as well as with Windows 2k, XP, Vista and Windows 7. I have not tried it on earlier versions like Windows 98.

Some of the other methods worked with varying success until I upgraded to Windows Vista. Here I explain a method that consistently works for accessing Lvm2 in Windows, is free and relatively easy to set up.

Contents

  1. Why use LVM2?
  2. The method that worked - Virtual Box
  3. How it appears to Windows
  4. Obtain and install virtual Box
  5. Set Virtual box To Run As Administrator
  6. Finding the drive number in Windows Vista
  7. Make profile for raw disk access
  8. More Info on Windows/Linux environments
  9. Install OpenFiler
  10. Further information on LVM2
  11. Extend your LVM2 Partition
  12. Love This Lens?
  13. Bookmark This Lens
  14. What are your experiences with LVM?
  15. LVM2 and Linux Links
  16. Image Sources
  17. About Me
  18. Covering a very difficult techie area

Why use LVM2?

LVM2 stands for Linux Volume Management. This system is amazing, because you can have one initial drive or group of drives in a volume, and then add drives to it later if you need more space.

A volume is in this context one logical partition - a single file system. Files are portable across the drives or physical partitions that make up the volume - a volume group.

When you need to take away a drive, provided you have sufficient space on the rest of the physical partitions in the volume, you can instruct LVM2 to ensure that the data is distributed so that no data remains on the volume to be removed. You do not manually have to move your files - and it is still considered one complete logical volume.

If you find that you use a lot of disk space quickly, LVM2 is a very good option to future proof yourself a bit.
 

The method that worked - Virtual Box

After trying a number of methods, the one that worked is to use Virtual Box.
Virtual Box allows a user to set up a Virtual Machine - a simulated computer running as software. It uses hardware to accelerate where possible, but it is a sandbox, where the programs running in it are separated from your main operating system. Put simply - it allows you to run Linux within Windows, or Windows within Linux as well as multiple Windows instances and so on.

Virtual Box is also free for personal use.

This method involves in short putting Linux on a virtual box, mounting the drive on the Virtual Machine, mounting the LVM2 partition on Linux, using Samba to share the mounted partition. It means that you will be able to have full browsable read and write access to the drive. By using a minimal Linux installation, you will be able to keep the overhead down by a huge amount.


在Windows7下访问LVM2_第1张图片
Buy at AllPosters.com
Framed   Mounted

How it appears to Windows

Windows will be able to mount a shared drive, which as long as sensible names are chosen, should be easy to find. To windows it would appear to be a normal windows share. Since it is actually local, and written directly to the hard drive, it should be relatively quick.

The virtual machine will be running but it can be set up to run without a GUI, and as a service - so it will become transparent once fully configured. The interface through Windows is the tip of an iceberg. The busy Linux system now become the hidden depths of something that just works.


在Windows7下访问LVM2_第2张图片

Buy at AllPosters.com
Framed   Mounted

Obtain and install virtual Box

Virtual Box is free, and really easy to get hold of.
Download Virtual Box.

Run the downloaded file to install it. On Vista you will need to give it permission to install. You can choose to use VMware or colinux for this, but the procedures will be different and your mileage with raw disk access may vary on them. I chose Virtual Box as this has worked every time for me.

Set Virtual box To Run As Administrator

Raw disk access requires admin priviledges

Bring up the properties dialog on the shortcut you will use to start it. I chose to do both the start menu one and the desktop one so Launchy can be used. Select the "Shortcut" tab and click the "Advanced" button highlighted.

Bring up the properties dialog on the shortcut you will use to start it. I chose to do both the start menu one and the desktop one so Launchy can be used. Select the "Shortcut" tab and click the "Advanced" button highlighted.
On the Advanced properties dialog, tick the "run as administrator" box, and hit Ok.

Finding the drive number in Windows Vista

You will need this to create write though access to the drive

First bring up the control panel. In the Windows Vista Control Panel, select System and Maintenance (highlighted in red).

First bring up the control panel. In the Windows Vista Control Panel, select System and Maintenance (highlighted in red).
Once in System and Maintenance, look for Administrative Tools, under this there will be an item "Create and format hard disk partitions" (highlighted in red). Click this to see Disk Management.
Once on the disk management Window, the disks will be displayed. Note that non-windows partitions will not have any labels, so you will need to note the disk which has a bunch of non-labelled partitions. Here there is a tiny 125mb boot, a larger 4gb swap, followed by the 293 gb LVM partition - which marks it out as my Linux drive.

Make profile for raw disk access

Currently this is the least friendly part of the process and involves a command line. It is also the most crucial step.
If you want to find out more on this, I suggest reading section 9.9 of the Virtual Box user manual. Here are the steps outlined:

  • Consider the path you want to create a virtual disk at - For now I suggest c:\users\<username>\rawdisk.vdmk. You can move it once you have done this.
  • Click start, run then type "cmd" and hit enter.
  • Type "cd c:\program files\Sun\xVM VirtualBox\" so you are in the Virtual Box program directory.
  • For the required disk or partition (changing paths as necessary):
    VBoxManage internalcommands createrawvmdk -filename c:\users\<username>\rawdisk.vdmk -rawdisk \\.\PhysicalDrive0 -register


That last command line explained:

  • internalcommands selects a lower level command set in VboxManage
  • createrawvmdk instructs it to create a VMDK for raw drive access
  • -filename specifies the output filename for the VMDK
  • -rawdisk specifies the drive number. Note the notation here - the correct drive number, obtained from the previous step should be used here.
  • -register ensures that the newly created drive is registered (via the registry) with Vbox and will show up in the virtual box media manager - which will save you plenty a little fiddling and trouble later.

More Info on Windows/Linux environments

If, like me, you have a mixed environment where you regularly use both OS's, there are a number of tips and tricks you will need to really get the best of the situation.
 

Install OpenFiler

A reader put me onto this, as a much simpler way to get an LVM or other linux partition mountable for windows. This is to use the system Openfiler. Having tried it out - I agree and this has replaced the original Ubuntu GEOS recommended in this artical.

Setting up a virtual box filer install to get to an LVM drive (or LVM image)
  • Download OpenFiler - http://www.openfiler.com/ - it is a Free, Open source NAS/Drive management distro. It happens to have LVM setup available and configurable from a web interface. This will be by far the simplest way to gain access. Get an ISO disk image - you will want the latest x86 edition.
  • Set up the OpenFiler VM - open up virtual box, click "New" to create a new VM, then give it the name OpenFiler. Give it some memory - I've given it a gig, which may be too much. Create a virtual disk image for it - I gave it 8Gb - which again may be too much - it is the default.
  • Be sure to set networking to bridged or host-only as you'll need to connect to this device. Other options require more configuration usually.
  • Boot it, and press enter. Skip the disk check.
  • Once the GUI shows up - follow this: http://www.openfiler.com/learn/how-to/graphical-installation.
  • The installer will complete and you'll be asked to reboot.
  • OpenFiler will start.
  • It'll display the IP/url to use - pop this into a browser and you should see the openfiler page load up.
  • You'll now need to stop it, and add your drives to it - this is easier for images than physical drives. Look belwo for the steps to add those.
  • Restart it, and you can now manage your drives from the web interface.
  • Default login is openfiler, password.


FAFFING - had to try the intel (not AMD) virtual network.
DHCP - You may want to give it a static address - although it will tell you on boot what its initial adress is.

Further information on LVM2

LVM is a logical volume manager for the Linux kernel; it manages disk drives and similar mass-storage devices, in particular large ones. The term "volume" refers to a disk drive or partition thereof. It was originally written in 1998 by Heinz Mauelshagen, who based its design on that of the LVM in HP-UX.

The abbreviation "LVM" can also refer to the Logical Volume Management available in HP-UX, IBM AIX and OS/2 operating systems.

The installers for the Arch Linux, CrunchBang, Debian, Fedora, Gentoo, Mandriva, MontaVista Linux, openSUSE, Pardus, Slackware, SLED, SLES, and Ubuntu distributions are LVM-aware and can install a bootable system with a root filesystem on a logical volume.

read the rest of the Wikipedia article

Extend your LVM2 Partition

Why not take advantage of the power of this system by extending your drive space? With an LVM2 partition, you do not need to manually copy files to the new driven and you can keep the old drive so you end up with a much larger net volume size.

你可能感兴趣的:(windows,linux,properties,System,Access,disk)