CLI302 - How Windows Storage Is Changing: Everything's Going VHD!
-
Upload
louis-goehl -
Category
Technology
-
view
1.890 -
download
2
description
Transcript of CLI302 - How Windows Storage Is Changing: Everything's Going VHD!
What's New in Windows Storage Presented by Mark Minasi
contents copyright 2009 Mark MinasiDo not redistributeSession Code: CLI302
Overview
Volumes as Seven likes 'em: The Case of the Unlettered DriveVHDs
Win 7 native supportStoring OS volumes in VHDs Booting from a VHD
What's new in Win 7 backupShort Items
How Win 7 Setup Arranges Disks
Quick Review: BCD/BCDEDITLet's back up and review something about how Vista boots and how W7 adapts thatVista doesn't use the NT boot loader that we've had since 3.1; instead, it uses a new "boot configuration database" (BCD), a hidden/system folder containing the boot loader and boot instructionsIt's why boot.ini's gone and bcdedit is essentialDownload the (free) first chapter of my Vista Security book for background and examples of bcdedit (Administering Windows Vista Security: The Big Surprises)
BCD in Win 7
If you install Win 7 on a system with a C: drive larger than about 24 GB in size, you'll end up with just one lettered ("C:") drive… but you will not be able to find the BCD folder on that drive, even with "dir c: /as"The reason: it's sitting on a separate partition that is not letteredFor example:
This system is a simple laptop with a single 100 GB C: drive. I wiped the drives, told Win 7 to install to the one drive and did not tell it to chop the drive up… but here you see that it
does that, creating an unlettered partition that contains the boot loader
Now Compare Explorer
The Explorer view, in contrast, looks just like a Vista one-drive system – the unlettered volume doesn't appear at all
Why Did Microsoft Do This?
Vista introduced the BitLocker drive encryption toolIt's useful, but it required you to boot from a separate 1.5 GB partition that contained nothing more than the BOOT folderIt was a pain to set up and didn't really need all that space, but MS put it in for compatibilityThis 100 MB volume now does the job
Why Do This?
Additionally, having a "Drive S:" (or whatever letter the little active partition eventually got) looked strangeWin 7's an improvement because
Separate partition's automatic, no after-the-fact fumbling with partitions to use BitLockerSeparate active partition supports booting from VHDs Win 7 active partition only uses 0.1 gig on your drive rather than 1.5 gigs
No Unlettered Volume?no problem!
You probably don't have the unlettered volume, if you upgraded in place from Vista or Server 2008/3!Upgrades won't rearrange the existing disk structure to create the unlettered volumeUpgrades won't "un-letter" an existing 1.5 GB system partition created for BitLocker under Vista
It Can Go at the Front or Back
Must the 100 MB volume be the volume first physically placed on the hard drive? No – I've set it up both ways, and it works fine in both cases
Native VHD Support in Windows 7
Agenda
What VHDs do for Windows 7Native VHD support in Win 7 introCreating VHDs step by stepAttaching VHDs (nope, it ain't "mounting")
Boot from VHD (BFV)Simple "add a second image via VHD" stepsBcdedit in detail: BFV's screwdriver and wrenchExpert boot from VHD setup – boot your computer from one file
13
Originally a Format for VM Disks
VHDs were (and still are) a useful format for storing virtual machines – when you power down a VM, basically it's nothing but a bunch of filesVirtual machines can have more than one imaginary hard disk, and each of those imaginary hard disks are stored in a file format with the quite sensible extension ".vhd"
VHDs Store Structures and ACLs
A VHD-format file can be a handy way to package an entire drive into one file, incorporating the folder structure and its NTFS permissions – way more useful than a ZIP file!Thus, they can provide "non-virtual service" replacing ZIP and CAB files
Snapshots Assist Backups
Virtual machine managers support the notion of "snapshots," a way to store the entire state of a VM that is both quick and that doesn't burn up a lot of hard disk space(Consider how large VMs are and how quickly snapshots happen!)VHDs, then, offer a useful format for backups and maintaining many incremental backups, as we see in Vista/Win 7's "CompletePC Backup"
And the Most Interesting Part…
Windows 7 lets you package an entire bootable Windows system drive into a single large VHDPlace that VHD onto a system's otherwise-empty hard drive (with a BCD folder)And then you can boot the system from that one big hard diskAgain, not a "virtual" application at all
First, Some Pictures
There's a lot to learn here, but let me do a quick overview of one of the outcomes of native VHD supportConsider this the "10,000 foot view" of something that I will later explain step by stepIt presents what is perhaps the simplest-to-see design (if not the simplest to create!)
VHD Boot Setup: "Big Picture"
19
Start off with a clean hard disk, a WIM of the System Reserved Boot Partition and a VHD containing a Windows OS partition (you have to create those yourself, more info on that later)
Boot WinPE
Using DiskPart, chop it up
VHD Boot Setup : "Big Picture"
20
Create two partitions: a 100 MB active partition, give it any drive letter (let's call it R:)
R:
100 MB
"R:?"
Doesn't the drive letter matter?No – as we've seen, the system reserved boot partition won't have a drive letter eventually anywayWe just need a drive letter now so that ImageX can do the next step
VHD Boot Setup : "Big Picture"
R:
100 MB
SRBM.wim
Get the boot manager code into the small partition with Setup or ImageX
SRBPM.wim
VHD Boot Setup : "Big Picture"
SRBP100 MB
Then, use the rest to create a partition, format it and call it drive S: (again, the letter doesn't matter, but I'll use S: in this example)
S:
VHD Boot Setup : "Big Picture"
SRBP100 MB
S:
Create a folder on S: and copy an already-created Win 7 VHD which I've called image.vhd (and that I'll explain how to create later) to the folder
image.vhdimage.vhd
Notice the "Copy"
If you've already got an OS image inside a VHD, then "deploying" it is as simple as XCOPYing the VHD file… no Ghost, no ImageX(Again, we'll see how to create a VHD with an OS image in it in a moment)Note also:
We've got a drive S: that contains the file s:\vhds\image.vhd that we want to boot from
Then we'll do some bcdedit (details later)And reboot…
After You Reboot: "Big Picture"
SRBP100 MB
E:
As before, the 100 MB partition has no letter
S: has been renamed to some other letter just above C:, like D: or E:, and has just one file in it
The attached VHD – which is just a VHD file sitting in a folder on "E:" – now shows up as a separate C: drive with the OS on it
image.vhdimage.vhd
C:
What it looks like when booted
So on to the details!
Native VHD Supportwhat Win 7/R2 can do
Win 7 lets you create, from the CLI or (less completely) the GUI a brand-new VHDYou can then access it by "attaching" it, which fools Windows into thinking that you've just added a new physical hard disk to the systemYou can then partition it, format it, etcFrom that point on, any other system that attaches that VHD sees its partitions, NTFS security and the like
VHD Attachmentsimpler example that we can quickly see
Take a computer with one physical hard disk and just one volume on that disk (except the hidden partition)We'll carve out a 1 GB fixed-size VHD file named "image.vhd" from C:Then we'll partition it, format it and make it drive D: with a volume label of "VHD Disk" or the like
Win 7 VHD Workflowwhat we'll do to create the "extra" drive
Initially create a VHD with logical disk manager (LDM), diskpart or, in some cases, start from an existing VHDFollowing that, "select" the VHDThen you "attach" the VHDOnce it's attached, it looks like a new hard driveNow you treat it just like a regular drive – partition it, format it, etc
Using Win 7's VHD Supportoverview (command line, all in diskpart)
Create VHDs from create vdisk file=…Connect to a VHD file with select vdisk file=…Then view it as if it were a physical with the attach vdisk commandOnce it's attached, you can treat it like a physical disk – create/delete partitions and volumes, format the volumes, give them a letter
VHD Creation from the CLI
Three Kinds of VHDs
Fixed: when you create the VHD, you tell Windows how large it should be, and that space gets allocated immediatelyExpandable: when created, you tell Windows the VHD's maximum size, but Windows only actually allocates the space as neededDifferencing: based on an existing "parent" VHD, this is a space-saving way to create several VHDs that are based on a "baseline" VHD
Creating a VHD: CLI
From the CLI:diskpartcreate vdisk file=filename maximum=sizeinmegabytes [type=fixed|expandable] (we'll skip differencing for now)
ex: create vdisk file="c:\vhds\image.vhd" maximum=1000"Fixed" is default, "expandable" can be much faster for big VHDs
Selecting a VHD: CLI
Necessary intermediate step in using diskpart on a VHDAlso, it's the first step if you want to use a VHD that you got from somewhere elseConnect to a VHD file in diskpart with "select vdisk file=filename" – example:select vdisk file=c:\vhds\image.vhdNo options
Attaching a VHD: CLI
Next, a simple one:attach vdiskAttaches whatever disk you named in the last commandCan take "readonly" as an option, or create new in-the-vdisk permissions with the "usefilesd" or "SD=" optionsNow it's like you have an extra hard drive on your system… partition it, give it drive letters
Disk Manager w/VHD drive
Really just a piece of C:
Explorer w/VHD drive
Remember, this system in actuality has only one physical hard disk and only visible partition, no matter what it looks like
Taking VHDs Further:using "boot from VHD"
Boot From VHD: Basics
We've seen that a VHD can "become" a diskBut what if that disk contained a bootable operating system image?Then you could (with Windows 7 Ultimate or Enterprise) tell Windows at boot time to automatically attach the VHD, essentially "unpacking it on the fly" and booting from the OS inside that VHDBetter: you could have several VHDs for multi-boot, and deploying is basically XCOPYing
First, We Need a VHD with a System Image
The VHDs that we'll deploy contain an operating system image, (although with some work you could probably use a a VHD from an existing VM) so let's see how to create thatStart from a WIM (create with ImageX, newsletter #60) and a VHD (which we just saw how to create)Attach the WIM so it's got a drive letterUse ImageX /apply to apply the WIM to the VHD
Example: Creating a VHD with a System Image
Suppose I've created "image.vhd" which isat least 24 GB (it's got to hold a Win 7 image)attached as drive G:, no data in it so far
And I've got a Win 7 image in "system.wim" as image number 1 (best if sysprepped, of course)Then I just typeImageX /apply system.wim 1 g: /verifyThis can then be copied to a target system and booted from
The Basic VHD Boot
We'll essentially employ just two steps to add a second bootable image to a computer using a VHD with a system image on it:
Copy the VHD to a local hard drive on the system (for example put "image.vhd" into C:\VHDs)Use BCDEDIT to create a new OS entry and point that entry at the VHD
Installing a VHD image to boot from
Start from a system running R2 or Win 7 Enterprise/Ultimate with enough space on a drive (any drive's fine, I'll use C:) to store an extra OS imageCopy a VHD file containing a Win 7 system image onto that drive (in my example, I'm copying image.vhd into C:\VHDs)And now, do a bit of relaxation breathing so we can tackle BCDEDIT
Where BCDEDIT Fits In
Remember the 100 MB boot partition?For the first few seconds, that is the only code running, and bcdedit is the main tool to tell it what to doWindows Setup configured bcdedit to boot (usually) from c:\windows\system32\winload.exeBut Win 7's boot partition can do the VHD stuff, if we tell it toThe only problem is that the syntax is pretty ugly… so here goes!
Using BCDEDIT
First, start from an elevated command prompt and type "bcdedit /v" to see the current state of boot instructions; there will always be at least two – ignore the first, as it's a set of overall commandsWe need the "/v" to get the long ugly GUID for the current OS entryIn this case, it turned out to be {f177696b-7ee6-11de-a72e-f4251c6d1ab0} but yours will be different
BCDEDIT Output
Not this entry,
this entry
BCDEDIT Setupour bcdedit tasks
Here, we willCopy the one existing bootable OS entryGive it a new nameChange its "device" and "osdevice" parameters (see previous screen shot for examples) to point to the VHDOptionally, tell it to rescan for plug and play changes with a "detecthal" parameter
BCDEDIT Setup
To copy the current OS entry, typebcdedit /copy {GUID} /d "Boot from VHD"(Don't type "{GUID}," type your actual GUID)Now we need a new GUID, the one that Windows generated when we created this new OS entryIt'll be reported in the bcdedit output; we'll note it (actually, I copy it into the clipboard for easy typing later) for the next commands
BCDEDIT Setup
In my case, it ran like this:C:\>bcdedit /copy {f177696b-7ee6-11de-a72e-f4251c6d1ab0} /d "Boot from VHD"The entry was successfully copied to {f1776970-7ee6-11de-a72e-f4251c6d1ab0}.
So I copy the {f1776970-7ee6-11de-a72e-f4251c6d1ab0} GUID to the clipboard
BCDEDIT Setup
Next, tell it where the boot device is, which looks likebcdedit /set {guid} device vhd=VHD-filespecUnfortunately this, too, is a bit ugly, as the drive letters will be different after the reboot, meaning the C:\VHDs ain't gonna be on C:\ any moreSo surround the drive letter in brackets:bcdedit /set {f1776970-7ee6-11de-a72e- f4251c6d1ab0} device vhd=[C:]\VHDs\image.vhd
Almost Done…
We next need the same command for a parameter named not "device" but "osdevice:"bcdedit /set {f1776970-7ee6-11de-a72e-f4251c6d1ab0} device vhd=[C:]\VHDs\image.vhdFinally, set "detecthal" on:bcdedit /set {f1776970-7ee6-11de-a72e-f4251c6d1ab0} detecthal on You can see those commands in this screen shot
Summary Run
Can't Figure Out the [Drive]?
Sometimes typing in the current drive letter in the bcdedit /device/osdevice commands doesn't work so wellIn that case, there's a neat alternative that lets you tell the computer, "you go find the stupid VHD!"Instead of [C:] or [D:] or whatever, just type [locate], likebcdedit /set {guid} device vhd=[locate]\vhds\image.vhd
Booting an Existing VHDsummary
Copy the VHD (call it "image.vhd" in this example) – assume it's in c:\VHDsCreate a new OS entry in bcdedit, copy from your current one withbcdedit /copy {current} /d "Boot Win7 VHD"That will result in a long GUID; copy that and do a bit of configuration:bcdedit /set {GUID} device vhd=[locate]\image.vhdbcdedit /set {GUID} osdevice vhd=[locate]\image.vhd
Adding A Second VHD
So now we've got a complete "standard" Win 7 install and a VHD-based Win 7, allowing a mult-boot situationWhat if we want to add another VHD? No problem – just reproduce what we did hereExcept for the bcdedit hassles (which aren't bad once you've done them a few times and [locate] helps), this essentially allows "xcopy deployment" of extra images
The Final Step: VHDs Only (1)
So we could imagine a system with, say, five images on it – one "standard," the other four "VHD"But what about a simpler arrangement:
100 MB partitionBig C: drive with just one file on it… image.vhd?
Overview: Pure Boot From VHD
Run Win 7 SetupShift-F10 for a command promptWipe the hard diskPartition it with
100 MB partition, set activethe rest as one large partition; format
Create a \VHDs folder on the large driveCreate, select, attach a 24+ GB VHDPoint Setup at the new "drive" now available
Step by Steps
Start Win 7 StartupPress shift-F10 to get a command promptCommands to create 100 MB partition:
diskpartselect disk 0cleancreate partition primary size=100
Step by Steps
Create large drive (still in diskpart):create partition primaryformat fs=ntfs label="Cdrive" quickassign letter=sexitmd s:\VHDsdiskpart
Step by Steps this should look sort of familiar by now
Create VHD, attach it and partition itcreate vdisk file="s:\vhds\image.vhd" type=expandableselect vdisk file="s:\vhds\image.vhd"attach vdiskexitexit
Now for the trick
You're back in SetupRun the install; where it asks, "Where do you want to install Windows?," look at the new space you created (the size is the clue, it's probably the last one)Setup will say "Windows cannot be installed to this disk. (Show details)"Click it an Next anyway; it'll install
What It Looks Like
Set up roughly as we just did, here are the Explorer and Disk Manager views
Disk Manager View
Remember, there's really only one hard drive here; "Windows 7 Image" is really a VHD file in "C Physical"
Explorer View: All Drives
Explorer View: C:
Explorer View: E:
This is the only folder on C:, containing just one VHD file
All-VHD Gotchas: Insomnia
In my experience, running a system from VHD does have a couple of down-sides:
hibernate seems not to workyou can't put a system to sleep
CompletePC Backup Changes in Windows 7/R2
What's New
Nothing major – this is basically the Vista/2008 backup toolBackup and Restore isn't in Accessories, it's in Control Panel / System and Security / Backup and Restore / Create an image backupYou can also "Create a system repair disc," a WinRE CD/DVD from Control Panel (System and Security / Backup and Restore / Create a system repair disc"
Difference From Vista
If you use Win 7's backup to do "bare metal" backups from the "wbadmin" CLI then be sure to include the "-allcritical" switch to ensure that the unlettered volume gets backed up, as in this examplewbadmin start backup –backuptarget:m: -allcritical –include:e:
What's New in Server Backup
System State Backup (on 2008 R2) uses VSS now and is five times faster than Server 2008; no corresponding changes in W7, as SSB isn't meaningful on a desktop OSParticular file/folder backup (as Vista had but Server 2008 did not) is in Server 2008 R2Still no tape or Exchange backup capability
Short Storage Items…
Built-in support for burning ISOs to CD, DVD and Blu-Ray Command-line tool in System32; syntax:isoburn /q [burner drive letter:] [file to burn]Example:isoburn /q e: myimage.isoAlso there's shell support built-inNo native ability to mount ISOs, though, although it may yet appear in the final version?
Short Storage Items…
DFS and FRS are, believe it or not, not just deprecated but gone from 2008 R2 apparentlyException is if you're still using FRS for SysvolYou can now do RAID 1 (mirroring) on the desktop OS, Windows 7
Thank You!
I am at [email protected] out about my free newsletter and online www.minasi.comPlease take a moment and do an evaluation
Complete an evaluation on CommNet and enter to win an Xbox 360 Elite!
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,
IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.