Upload
colleen-harper
View
214
Download
0
Tags:
Embed Size (px)
Citation preview
How Windows Storage is Changing: Everything’s going VHD!(What's New in Windows Storage)
Presented by Mark Minasicontents copyright 2009 Mark MinasiDo not redistribute
Session Code: CLI302
Overview
Volumes as Seven likes 'em: The Case of the Unlettered DriveWhat's new in Win 7 backupShort ItemsVHDs
Win 7 native supportStoring OS volumes in VHDs Booting from a VHD
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) -- it's free, no advertising
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
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 example
wbadmin 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.iso
Also there's shell support built-inNo native ability to mount ISOs, but…
Short Storage Items…
Google "virtual clone drive" from Slysoft, it's free and does ISO mounting (even on 64-bit)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 7And now on to the BIG topic…
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
20
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 (and easily transport) 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
VHDs Support Snapshots
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 saw in Vista/Win 7's "CompletePC Backup"
And the Most Interesting Part…
Remember, a VHD can hold an entire driveWith Win 7, that can be a bootable drivePlace that VHD onto a system's otherwise-empty hard drive (with a BCD folder)And then you can boot the physical system from that one big hard disk that was packaged as a VHD fileAgain, 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"
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
26
VHD Boot Setup : "Big Picture"
Create two partitions: a 100 MB active partition, give it any drive letter (let's call it R:)
R:
100 MB
27
"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 (system reserved boot partition, "SRBP") code into the small partition with Setup or ImageX
SRBP.wim
VHD Boot Setup : "Big Picture"
SRBP100 MB
Then, use the rest to create a big empty drive -- format it and call it drive S: (Again, the particular drive letter you choose does not matter)S:
Create a folder in S:, call it anything
VHD Boot Setup : "Big Picture"
SRBP100 MB
S:
Into the folder, 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:
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 Supportcommand line tools (overview)
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 letterLet's get more specific
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: CLIFrom 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
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
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
Hey, Wait A Minute…
I copy some VHD – call it "image.vhd" – onto a computer and I can boot from itBut wait… "image.vhd" has a bootable Windows image in it?????How do I get a Windows image into a VHD in the first place?
Create a Bootable VHD: Steps(high level)1. Get a Windows system the way you want it2. Sysprep it3. Boot the system with WinPE and use ImageX to
capture the image to a WIM file – for example, let's call it "system.wim"
4. Create a new VHD5. Mount it as a drive (call it G:)6. Use ImageX to deploy system.wim to G:
Background: More Details(in case WIMs are still strange)
I'll assume that you know how to get Windows installed and sysprepped (remember sysprep is now on all Windows at \windows\system32\sysprep)Get WinPE and ImageX by downloading the Windows Automated Installation Kit (WAIK) from Microsoft (it's free)Learn how to set up WinPE with my newsletter #59 at www.minasi.com
Background: More Details
Create the system.wim from the Windows system with ImageX (see newsletter #61 on my site), save it on a removable drive for simplicityCreate a VHD ("image.vhd") with diskpart, as beforeAttach the VHD and give it a drive letter (G:, for example)Use ImageX /apply to apply the WIM to G:Unmount the VHD, and you now have a usable image.vhd
Worked-Out ExampleStart from the sysprepped system, you're booted into WinPEYou've attached an extra drive called H: (could be removable, could be a network share)Image the system to h:\system.wim:imagex /capture c: h:\system.wim "Basic W7 Image"
Create image.vhd to h:md h:\vhdsdiskpart
Worked-Out Examplecreate vdisk file="h:\vhds\system.vhd" type=expandable maximum=24000select vdisk file="h:\vhds\system.vhd"attach vdiskcreate partition primaryactiveassign letter=gformat fs=ntfs quick
Worked-Out Example
exit (gets out of diskpart)ImageX /apply h:\system.wim 1 g: /verifydiskpartdetach vdiskexitYou now have an imagex.vhd!
The Basic VHD Boot
We'll essentially employ just two steps to add a second bootable image to a Win 7/R2 PC 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
Where BCDEDIT Fits InRemember 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 promptCopy the current "OS entry," the word for a set of commands that tells the computer how to boot from C:, D:, a VHD or whatever, using a bcdedit command I'll show youModify the copied entry that it shouldn't boot from C: but instead from c:\vhds\image.vhd with, again, some bcdedit commands
BCDEDIT Setupour bcdedit tasks
Here, we will use bcdedit toCopy the one existing bootable OS entryGive the new OS entry a nameChange two parameters, "device" and "osdevice" 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 {current} /d "Boot from VHD"
The output, well, won't be pretty:The entry was successfully copied to {f1776970-7ee6-11de-a72e-f4251c6d1ab0}.
"What was that hex thing?"
Okay, the thing is that you can have more than one "OS Entry," and you can give them English names (or German or French or Polish or …) but internally, Windows assigns them GUIDs
BCDEDIT SetupNext, 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} osdevice 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
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 (reference)
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: VHD Only
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
Disk Manager View
Remember, there's really only one hard drive here; "Windows 7 Image" is really a VHD file in "C Physical"
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
Thank You!
I am at [email protected] out about my free newsletter and online www.minasi.comPlease take a moment and do an evaluationTwo more talks!
Why you should learn IPV6 and save your job (1 PM today)Cracking Open Kerberos (5 PM today)
www.microsoft.com/teched
Sessions On-Demand & Community
http://microsoft.com/technet
Resources for IT Professionals
http://microsoft.com/msdn
Resources for Developers
www.microsoft.com/learning
Microsoft Certification & Training Resources
Resources
© 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.