Managing physical disks and disk volumes

Windows Server 2019 requires a computer with at least one disk drive (that is, the C: drive). A disk drive can be connected via different bus types, such as IDE, SATA, SAS, or USB. Before you can utilize a disk in Windows, you need to initialize it and create volumes or partitions.

There are two partitioning schemes you can use: the older format of MBR, and the newer GPT. The MBR scheme, first introduced with the PC DOS 2 in 1983, had a number of restrictions. For example, the largest partition supported with MBR is just 2 TB. And creating more than four partitions required you to create an extended partition and create additional partitions inside the extended partition. The GPT scheme provides much larger drives (partition limits are OS-imposed), as well as up to 128 partitions per drive.

In this recipe, you add two new disk devices to a server, SRV1, and then create new volumes/partitions on those disks.

Getting ready

You run this recipe on SRV1. To perform this recipe, SRV1 needs two additional disks. If you're using a Hyper-V VM to test this recipe, you can use the following script to add the necessary disks. Run this on your Hyper-V Host that runs the SRV1 VM:

# Create Virtual Disks to add to SRV1
New-VHD -Path D:v6SRV1SRV1-F.vhdx -SizeBytes 20gb -Dynamic
New-VHD -Path D:v6SRV1SRV1-G.vhdx -SizeBytes 20gb -Dynamic 
# Add them to the VM
$HDHT1 = @{
  VMName           = 'SRV1'
  Path             = 'D:v6SRV1SRV1-F.vhdx'
  ControllerType   = 'SCSI'
  ControllerNumber = 0
}
Add-VMHardDiskDrive @HDHT1
$HDHT2 = @{
  VMName           = 'SRV1'
  Path             = 'D:v6SRV1SRV1-G.vhdx'
  ControllerType   = 'SCSI'
  ControllerNumber = 0
}
Add-VMHardDiskDrive @HDHT2 

The GitHub repository for this book contains a script, Add-DiskstoSrv1+2.ps1, which creates the disks used in this and other recipes in this chapter. Once you've added the (virtual) disks to the SRV1 server, you can use Disk Management, a Control Panel applet, to view the starting disk configuration for this recipe, like this:

Getting ready

How to do it...

  1. Get physical disks on this system:
    Get-Disk |
      Format-Table -AutoSize
  2. Initialize the disks:
    Get-Disk | 
      Where PartitionStyle -eq Raw |
        Initialize-Disk -PartitionStyle GPT 
  3. Redisplay the disks on SRV1:
    Get-Disk |
      Format-Table -AutoSize
  4. Create a volume in Disk 1:
    $NVHT1 = @{
      DiskNumber   =  1 
      FriendlyName = 'Storage(F)' 
      FileSystem   = 'NTFS' 
      DriveLetter  = 'F'
    }
    New-Volume @NVHT1
  5. Create two volumes in disk 2—first, create G:
    New-Partition -DiskNumber 2  -DriveLetter G -Size 4gb
  6. Create a second partition, H:
    New-Partition -DiskNumber 2  -DriveLetter H -UseMaximumSize
  7. Format the G: and H: drives:
    $NVHT1 = @{
      DriveLetter        = 'G'
      FileSystem         = 'NTFS' 
      NewFileSystemLabel = 'Log'}
    Format-Volume @NVHT1
    $NVHT2 = @{
      DriveLetter        = 'H'
      FileSystem         = 'NTFS' 
      NewFileSystemLabel = 'GDShow'}
    Format-Volume @NVHT2 
  8. Get partitions on this system:
    Get-Partition  | 
      Sort-Object -Property DriveLetter |
        Format-Table -Property DriveLetter, Size, Type
  9. Get volumes on SRV1:
    Get-Volume | 
      Sort-Object -Property riveLetter 

How it works…

In step 1, you look at the disks available on SRV1, noting the two new disks:

How it works…

In step 2, you initialize the two new drives—this produces no output. In step 3, you redisplay the disks, which looks like this:

How it works…

In step 4, you use the New-Volume cmdlet to partition and format a disk volume (F:) in the first added disk, which looks like this:

How it works…

With step 5, you create the first of two new partitions on the second drive added to SRV1, which looks like this:

How it works…

In step 6, you create a second partition on the second disk, the G: drive. That looks like this:

How it works…

In step 7, you format the two partitions you just created, which looks like this:

How it works…

In step 8, you use the Get-Partition cmdlet to return the partitions on the SRV1 server, which looks like this:

How it works…

In step 9, you use the Get-Volume cmdlet to return the volumes (also known as the partitions) on the SRV1 server, which looks like this:

How it works…

There's more...

In the Getting ready section of this recipe, you add two new disks to SRV1. These new disks are uninitialized, thus the first thing to do, in step 1, is to initialize the disks.

In step 4, you create a new volume on Disk 1. This creates the partition and then formats the drive. In step 5 and step 6, you create two new partitions on disk 2 which, in step 7, you format. This shows two ways of creating drives within a disk.

In step 8 and step 9, you use different cmdlets to return what's essentially the same set of objects—the volumes/partitions on SRV1.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.211.166