Sunday, April 23, 2017

Enabling and Setting up SSD/HDD Storage Tiers in Hyper-V on Server 2012R2

In this post I am going to cover how to create a storage spaces tiered storage array, format it to use ReFS and have Server 2012R2 Mount the drive after/when the system is restarted.  You will have to have the Server 2012R2 installed with the Hyper-V role added before we begin.

When installed you can see from the GUI 4 disks that you have available in my case I have 4 but only three can be pooled because in this list my OS disk is being shown in here.


















This powershell command shows what disks can be pooled.
#List all disks that can be pooled and output in table format (format-table)           

Get-PhysicalDisk -CanPool $True | ftFriendlyName,OperationalStatus,Size,MediaType       

The results of the powershell commands are shown below.









To make our lives easier we create a variable with unspecified disks.
           
#Store all physical disks that can be pooled into a variable, $pd           
$pd = (Get-PhysicalDisk -CanPool $True | Where MediaType -NE UnSpecified)           

#Create a new Storage Pool using the disks in variable $pd with a name of My Storage Pool      

---For 2012R2 and earlier---     
New-StoragePool -PhysicalDisks $pd –StorageSubSystemFriendlyName “Storage Spaces*” -FriendlyName “DATA”         

---For Server 2016 and newer---
New-StoragePool -PhysicalDisks $pd –StorageSubSystemFriendlyName “Windows Storage*” -FriendlyName “DATA”   


#View the disks in the Storage Pool just created           
Get-StoragePool -FriendlyName "DATA" | Get-PhysicalDisk | SelectFriendlyName, MediaType
           







So we have 2 types of disks shown in our storage pool.  SSD and HDD

We run the following commands to create a tiered storage pool.  This will create a ssd pool and hdd pool

#Create two tiers in the Storage Pool created. One for SSD disks and one for HDD disks           
$ssd_Tier = New-StorageTier -StoragePoolFriendlyName "DATA" -FriendlyName SSD_Tier -MediaType SSD           
$hdd_Tier = New-StorageTier -StoragePoolFriendlyName "DATA" -FriendlyName HDD_Tier -MediaType HDD

Now we can switch to the gui and create our VHD which will mount to the HOST OS.  We will also be able to create a writeback cache.  From here we can start the Wizard in the GUI.






Now here is where we can select the option to create tiered storage spaces and name your virtual disk.


Here is where you can specify what kind of setup you want in my case simple or mirrored. However I could not do mirrored as I did not have enough physical disks available so for the purposes of this post I went with simple.  Though for performance and redundancy I would select mirrored.  StorageSpaces allows for 3 types of resilient storage.


Resilient storage. Storage Spaces provides three storage layouts (also known as resiliency types):
  • Mirror. Writes data in a stripe across multiple disks while also writing one or two extra copies of the data. Use the mirror layout for most workloads – it helps protect your data from disk failures and provides great performance, especially when you add some SSDs to your storage pool and use storage tiers.
  • Parity. Writes data in a stripe across physical disks while also writing one or two copies of parity information. Use the parity layout for archival and streaming media workloads, or other workloads where you want to maximize capacity and you’re OK with lower write performance.
  • Simple (no resiliency). Writes data in a stripe across physical disks without any extra copies or parity information. Because the simple layout doesn’t provide any protection from disk failures, use it only when you require the highest performance and capacity and you’re OK with losing or recreating the data if a disk fails. You can also use the simple layout when your application provides its own data protection.
Once you go forward you will see something like this for the following screen.




You will see an alert about the write-back cache, and I will end up with a 700GB drive 1 x 120 GB SSD and 2 x 320 GB HDD.  Now because this lab is a simple setup (3 drives) and if I wanted any kind of redundancy (which I would want for a production environment) I would want to use a mirror setup for the storage spaces instead of simple for the storage layout.

Update - April 24, 2017

After that you will want to get your storage space volume to auto mount

Open an administrative level PowerShell prompt and type in the following.
Get-VirtualDisk | Where-Object {$_.IsManualAttach –eq $True}
This lists off your virtual disks where the IsManualAttach property is turned on and the disks WILL NOT auto-reattach on restart.
Now run the line again but include the following:
Get-VirtualDisk | Where-Object {$_.IsManualAttach –eq $True} | Set-VirtualDisk –IsManualAttach $False
Now the virtual disk will auto mount after a restart/power cycle.

Update - April 26, 2017

I was unable to use the procedure above to work with NVMe based SAS drives. If you want to know how that was setup see my post How to setup Storage Tiers on Server 2012R2 with Powershell and NVMe Drives I go through step by step on how to setup the storage spaces using powershell.


For more information about storage spaces please refer to the following articles


and for referencing some of the powershell commands I used checkout



Automount Storage Spaces Virtual Disk


You can also view the whole process on my youtube channel. https://www.youtube.com/watch?v=hNhX65DDaT4



Wednesday, April 12, 2017

Enabling Trim on 3rd Party SSD on MacOS

Solid State Drives or SSD's as they are commonly referred to are now the easiest and cheapest way to bring new life to your old computer.  Many of the SSD's max out the bandwidth provided by the bus that your computer connects to the hard drive.  On MacOS though if your lucky enough to have an older mac then you can upgrade with any SSD you would like but what you don't know is that Apple doesn't enable TRIM by default even though most SSD's support TRIM. 

Why do you want Trim?  I'm not going to go into it in detail because Techspot has a great article you can read in detail here

Basically SSD's can not directly over write cells with new data, but must first be erase it at the block level.  This is called garbage collection.  The flash memory uses over provisioning used to improve performance and longevity of the SSD.   

The less space not consumed by your data becomes what is called dynamic over provisioning – because it changes as the amount of data stored changes.  When less data is stored by the user, the amount of dynamic over provisioning increases, further improving performance and longevity.

Here is what you need to do to enable Trim on your SSD on your Mac.

1. Close all programs except for Terminal if you

First you can check and see it if Trim is enabled.  You can do this 2 ways.

Terminal.


system_profiler SPSerialATADataType | grep 'TRIM'

You will get a response of TRIM Support: Yes or No

Or go under the Apple Menu -> about this Mac -> and run System Report





If you get a Yes you don't need to do anything trim is enabled.

If you get a No type the following command.

sudo trimforce enable

Then answer yes to the two questions and it will reboot.

Trim will be enabled after the reboot.  You can verify this by using the terminal command
system_profiler SPSerialATADataType | grep 'TRIM' or checking the system report.

Friday, March 31, 2017

Setting Up PFSENSE with OPENVPN using User Authentication

PFSense is a great firewall solution.  It is flexible, easy to customize and comes with built in VLAN and VPN support.  Now I am going to document this for setting up a User Authenticated Open VPN Server in PF using the local database that is in PFSENSE.  This will have to be modified for larger organizations; but would be great for smaller and mid-range shops.  This is the least secure way to set this up but is the easiest to setup.

A couple of things to note.

The PFSense OPENVPN client wizard automatically makes the routing for the WAN which is what is used in most setups as most organizations use one firewall.  If you re-run the export wizard and if you made a change to the rule it will reset any changes you made to the WAN.

If you are using PFSENSE with CARP FAILOVER, you must select the CARP address and change any firewall ports/forwards and NAT/Outbound rules.  On your OPENVPN Server make sure the interface is set to your CARP address as well.

Before you proceed you should install the openvpn-client-export package as seen below.




What this tool does is it adds a client export utility which really just allows you to download a .ovpn of your firewall connection for the Open VPN client.  It makes it really easy to make the .ovpn file you need to use with the Open VPN client.


PFSense supports 3 Server Modes for OPENVPN


The OpenVPN Server Mode allows selecting a choice between requiring Certificates, User Authentication, or both. The wizard defaults to Remote Access (SSL/TLS + User Auth). The possible values for this choice and their advantages are:
  • Remote Access (SSL/TLS + User Auth)
    • Requires both certificates AND username/password
    • Each user has a unique client configuration that includes their personal certificate and key.
    • Most secure as there are multiple factors of authentication (TLS Key and Certificate that the user has, and the username/password they know)
  • Remote Access (SSL/TLS)
    • Certificates only, no auth
    • Each user has a unique client configuration that includes their personal certificate and key.
    • Useful if clients should not be prompted to enter a username and password
    • Less secure as it relies only on something the user has (TLS key and certificate)
  • Remote Access (User Auth)
    • Authentiation only, no certificates
    • Useful if the clients should not have individual certificates
    • Commonly used for external authentication (RADIUS, LDAP)
    • All clients can use the same exported client configuration and/or software package
    • Less secure as it relies on a shared TLS key plus only something the user knows (Username/password)

More in depth documentation can be found here at https://doc.pfsense.org/index.php/OpenVPN_Remote_Access_Server#Authentication

This tutorial will help you setup a Remote Access (User Auth) setup.  There are a few things you need to setup before you begin.
  1. Have a user setup that you plan on using for OPENVPN
  2. Setup up a Certificate
  3. Run the OPEN VPN Wizard
  4. Open Your Firewall ports and setup your routing properly.

STEP 1.  Create a OPENVPN User

I would highly recommend using something separate from the built in account; not only is it best practice it would be stupid to use default account.  Depending on your setup if your using groups etc, you will need to add permissions for what you want.  To just access the network you don't need to have the user setup as a member of the Admins group.  Now you can restrict their access to gui controls in the firewall etc. Just remember this user has access to the firewall so lock it down as best you can.  PFSense supports LDAP and Radius as well as local database.  We will be using the local database installed in PFSense which is used for user management.






STEP 2 - Create your Certificate

You could setup letsencrypt though there is no really good way of automating the renewal of the TLS Certificate every 90 days yet.  For our purposes we are going to use a self-signed certificate.  Create a internal Certificate Authority which is used for self signing.  I used the default a 2048 bit key length with a sha256 digest.  We are creating the Certificate (which is shared for all remote user access) so that the tunnel is encrypted.  The default lifetime of the Cert is 10 years.



Here is a sample of what the cert should look like.




And you should create an internal Certificate Revocation List.  This will allow you to revoke the certificate incase you lose control of the private key.





STEP 3 - OPENVPN Wizard

This is basically a fill in the blank wizard.  When you finish it will generate a OPENVPN server and exported client settings.  This is the easiest way to create the .ovpn file and recommend using it and making changes to the .ovpn file after the fact.







The tunnel network is the network that the client is using to connect to the network you want to access.  An example is the client using the OpenVPN client would have an ip address on the virtual network 192.168.2.0/24 and is trying to the actual LAN network of 192.168.1.0/24.  So the client would get an IP of 192.168.2.3 and would be able to access the NAS on 192.168.1.50.  You may need to add the push "route 192.168.1.0 255.255.255.0" in the advanced section otherwise the routing may not work as expected.  I have found for the most part this is required and further down if your using this to VPN into an Active Directory Network and want to access DFS shares you will also have to push out DNS settings.



After the wizard is completed you will see your VPN Server like in the image below.




You will want to go into the settings and make a few changes.



You will want to make sure that the server mode is set to Remote Access (User Auth) and your interface is what it needs to be WAN or CARP Typically.

You will then want to go to the client Export option. (This is a plugin in PFSense so make sure you install it first.)
Here you can download all your OPENVPN Config Options





4. Confirm your Firewall Ports and Routing are working properly.

Your firewall rules should look something like this.







The exported OpenVNC settings file looks something like this.



persist-tun


persist-key

cipher AES-256-CBC

auth SHA256

tls-client

client

remote X.X.X.X YYYYY udp

lport 0
auth-user-pass
ns-cert-type server
comp-lzo adaptive

-----BEGIN CERTIFICATE-----

-----END CERTIFICATE-----
setenv CLIENT_CERT 0
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----

-----END OpenVPN Static key V1-----
key-direction 1



UPDATE:

If you want access to DFS Shares though AD, you will want to push all traffic through the VPN.  Check the Redirect Gateway.  The default is 10 Concurrent Connections.

I've also set the DNS Server Enable pointing to the DNS for the AD Controllers and I've also enabled Block Outside DNS, and Force DNS cache update.

I've also added a few additional options for custom options for the DNS Server.

push "route xxx.xxx.xxx.0 255.255.255.0"
push "dhcp-option DNS xxx.xxx.xxx.xxx"

You may also have to update your Active Directory settings to enable slow-link mode. (see below)




Once you connect to your VPN you will be working in offline mode because your not connected to the domain right away.  If you click the work online on the client the DFS shares will come right up.


Friday, March 03, 2017

Screensaver Lockscreen using GPEdit

You will need to be an administrator on the local machine or in AD to make these changes.

Open GPEDIT.msc
Under “User Configuration” go to Administrative Templates -> Control Panel -> Personalization


Edit and enable the Following Settings
    1. Enable Screen Saver -> Enable
    2. Prevent Changing Screen Saver -> Enable
    3. Password Protect the Screen Saver -> Enable
    4. Screen Saver Timeout -> Enable and Set to 300 Seconds
    5. Force Specific Screen Saver ->  Enable and set to %Systemroot%\System32\Mystify.scr




Apply and hit ok.

Open up the cmd prompt and type in gpupdate \force and logout when asked.

Timed Lockscreen on Windows with Taskscheduler

Instead of using a screensaver to activate the lock screen you can use the user32.dll to lock your screen.

Open up Task Scheduler:  I called the task lockscreen.  See below.







On the Trigger I've selected idle.  I've set the task to repeat every 10 minutes.



Actions - Start an program. The path is C:\Windows\System32\rundll32.exe   Add the arguments: user32.dll, LockWorkStation



Conditions.  Start the task only if the computer is idle for how ever many minutes you want.  I selected 1 minute.



 Settings:  Configure any additional settings and be on your way.






Wednesday, August 24, 2016

FreeNAS Disaster Recovery

FreeNAS is a fantastic NAS solution it is really robust when it comes to management, backup and restoring from a dead USB Key, Hard Drive failure are fantastic.  However what if your motherboard dies?  What if your using a RAID controller in JOBD and it dies?  

I had the RAID controller die on me and the consensus on the internet was I'm F*cked.  

I had setup a FreeNAS system on a Quadcore AMD Phenom System from 2007, because I needed a system with lots of storage space, for backup purposes, which this chassy allowed.  The Processor is 2.3 Ghz, and has 40 GB of RAM along with dual power supplies.  I had put in an Areca 1120 because the SATA Bus is faster then the onboard SATA (SATA2 Vs SATA1) on the motherboard.  The system was configured with 8 3TB WD RED NAS drives in a Z2RAID, and an 80GB Intel 520 SSD for a arc cache.  The system was working as an iSCSI target and SMB server and performed extremely well, with the slowest part of the system being the network connection.  Then when I came in to work this morning the system was completely unresponsive.  I had 2 virtual machines running off the iscsi target which were in production, a Linux Print Server and a mailforwarder / Scheduling server.  I had a backup up to a few days before which I recovered to but I had to get the the data for the the scheduling software.

After trying a few reboots hoping the ARC RAID controller might magically work I disconnected it and tried to plug the drives into the mainboard and the system booted but FreeNAS couldn't find the Storage Pool.  I was not surprised with this result and no backup raid controller, it was time to get creative.  I had access to 2 different PCI Silicon Image Software RAID cards a 4 port and a 2 port so I thought I would try put them in and hook up 6 of the drives that were on the failed raid controller to these software based controllers I might have a chance to get the data; after all I had configured the 1120 as a JOBD setup and let FreeNAS handle the raid as stated in their best practices. 

It worked.  FreeNAS booted and was able to access the storage pool but in a "Degraded" state.  I was able to pull the VHD from the iscsi target that I needed with NO LOSS of data, and put it back into production.  I also grabbed a few other files while I had the server up, but the recovery was a complete success.

This is the first time I've tried this, but if anyone is having a issue with freenas not reading a storage pool after a hardware failure and your OS USB drive is in good shape give this Silicon Image RAID controllers a try it worked for me it might work for you.

Friday, July 29, 2016

Pokemon Go, You, Your Child, and Privacy


Pokemon Go is all the rage right now, and if your a parent you might not be to sure how to handle this new app craze that is the Angry Birds of 2016. Pokémon Go is a free-to-play location-based, augmented reality game developed and published by Niantic, Inc. for iOS and Android devices.  What you might not be aware of is some of the privacy issues that you may be exposing you and/or your child to.


As you may or may not be aware the way Pokemon Go! uses two ways to sign up for an account.  Using a Pokemon Trainer Account and tieing it to a Google Account.  If you are signing up a child to play this game I highly recommend you use the Pokemon Trainer account.  If you sign up your child with a new google account there are some issues.

1) The Google Terms of service specifies that a user must be at least 13 years of age.

"At the moment, age restrictions don't warrant a single word in Google's Gmail Terms & Privacy details. Google does, however, spell them out on YouTube, buried down in item 12 of its Terms of Service. “If you are under 13 years of age, then please do not use the Service."

You can use the gmail account setup by the schools if the schools are setup for using google because there are additional privacy protections with those accounts.

2) The Pokemon Trainer account is suppose to compliance with the Children's Online Privacy Protection Rule "COPPA" as is the Google Accounts for schools, and has far more privacy restrictions then with a general Google Account. 

Granted that COPPA is a US based law and according so TWIL Episode 353 it is suppose to offer better privacy protection than your typical google account.

HOW TO CREATE POKÉMON TRAINER CLUB ACCOUNT

1. Go to the Pokémon.com official website or click on this link to go to the signup page https://club.pokemon.com/us/pokemon-trainer-club/sign-up/


2. Once you enter the webpage, below the “Join the Pokémon Trainer Club”” click on “Create an Account” button.
3. Click on the button marked, “Continue,” in the section on the right hand side of the page that is marked, “Sign Up! New to Pokémon.com ? Sign up for an account now!”
4. Select your country of residence from the drop-down menu, then enter your date of birth, Next, click on the button marked, “Continue.”
5. Complete the sign up process as directed to activate your account.
6. Done. Now go back to your phone and start the Sign up process. Please make sure to use your Pokémon Trainer Club Account instead of your Google Account.

Thursday, June 16, 2016

Fixing Veeam Hyper-V Replication Failure Caused By VSS Writer


I just had an issue with the Veeam Backup and Replication Software where a replication job was failing.  I have Veeam setup to email error logs to me and I started getting error messages with a replication job where it was not reconciling the differences in the disk on the fail-over server.

Here is a sample of the email error.



After getting a few of these emails I checked the server and discovered on of the VM replication jobs appeared to be stuck on in progress.

A Sample of the log on the Veeam Server

VM {VMNAME} task has finished with 'InProgress' state.
Task details: Failed to create snapshot (Microsoft Software Shadow Copy provider 1.0) (mode: Veeam application-aware processing) Details: Writer 'Microsoft Hyper-V VSS Writer' is failed at 'VSS_WS_FAILED_AT_PREPARE_SNAPSHOT'.

The writer experienced a transient error.  If the backup process is retried,
the error may not reoccur.
--tr:Failed to verify writers state.
--tr:Failed to perform pre-backup tasks.

Make sure VM does not have 'iSCSI Software Target Storage Provider' feature installed.
Retrying snapshot creation attempt (Writer 'Microsoft Hyper-V VSS Writer' is failed at 'VSS_WS_FAILED_AT_PREPARE_SNAPSHOT'.

The writer experienced a transient error.  If the backup process is retried,
the error may not reoccur.

--tr:Failed to verify writers state.
--tr:Failed to perform pre-backup tasks.)

Task has been rescheduled



Googling the issue I only found this blog http://www.insidetechnologies.eu/en/blog/veeam-br-resolve-hyper-v-vss-writer-error/  and after double checking that his solution wouldn't bring down my Hyper-V Server by checking Microsoft Technet https://social.technet.microsoft.com/Forums/en-US/69e6dcbd-fbe3-43e0-a7b3-65111fbdf00a/will-the-running-vms-be-impacted-if-i-restart-the-hyperv-virtual-machine-management-service?forum=winserverhyperv

I disabled the replication jobs and stopped the Hyper-V Virtual Management Management Service on the primary server; while it took a while for the management service to stop but once it did and I restarted it everything came back no problem and the replication jobs started, reconciled and finished without an issue.

Updating your godaddy certs during the G2 intermediate hierarchy to the TLS Root CA - R1 hierarchy

  If you use GoDaddy TLS certificates you should be aware of some changes during the transition from the G2 Intermediate certificates to the...