Tuesday, 11 June 2013

How to Set Up RAID on Your PC

Configuring two or more hard drives in a RAID (Redundant Array of Inexpensive Disks) setup can increase performance and/or provide automatic protection against data loss from drive failure. RAID used to be expensive, hard to implement, and limited to businesses with dedicated IT departments. Now, motherboards in most desktop PCs support RAID, and Windows 7 provides software RAID that requires no special hardware at all. The technology is easily within the reach of the wallet and skills of any reasonably tech-savvy PC user.

What type of RAID do I want?

RAID comes in a number of flavors--or levels--that offer data protection, enhanced performance, or both. In addition to the seven core levels (RAID 0 through RAID 6), you'll encounter a number of variants and combinations. Some controllers (and dedicated external storage and NAS boxes) can layer and even abstract RAID levels, allowing you to mix and match different capacity drives and add capacity without any additional configuration.
Here are a few of the RAID levels you'll find on affordable, consumer-level RAID adapters, motherboard chipsets, and Windows software RAID:
JBOD (extend, spill over): JBOD, or Just a Bunch Of Disks simply allows you to extend a volume (drive letter, e.g. C:\) onto other disks. Data is written to the first disk until it's full, then to the second disk, then the third, etc. It offers no boost in performance or redundancy and is a holdover from the days when smaller disks had to be chained to handle large amounts of data. It's largely irrelevant given today's more capacious hard drives.
RAID 0 (Striping): This setup increases hard-drive performance by splitting, or striping, data across two drives. By leveraging two data busses, data can be read and written more quickly. Unfortunately, RAID 0 provides no data protection--in fact, it actually increases the chances of data loss since the failure of either drive in the array results in the loss of the data stored on both drives. RAID 0 setups are standard on high-end gaming PCs and graphic design workstations, and provide a measurable, albeit modest performance boost for hard-disk-intensive programs.
RAID 1 (Mirroring): A RAID 1 setup protects data from drive failure by simultaneously writing the same data to two hard drives. Since each drive is an exact duplicate of the other, you can continue working if one fails. RAID 1 offers no gain in performance and effectively reduces available capacity by half -- two 2TB drives provide only 2TB of storage.
RAID 5 (Distributed Parity): Though you get both faster disk performance and data protection from this setup, it requires a minimum of three hard drives. Instead of using an entire hard drive as a backup, RAID 5 spreads redundancy information--called parity bits--across all of the array's drives. Where RAID 1 requires 50% of available storage for redundancy, RAID 5 requires only 33%.
When one of the drives in a RAID 5 array fails, the data content of that failed drive is reconstructed using the parity bits on the surviving drives and written to a new, replacement drive. The array is still usable in the meantime.
RAID 1+0, 0+1, 10: Some adapters combine (referred to as nesting) RAID 0 and RAID 1 to provide both data redundancy and increased disk performance. This works by either striping data across a pair of drives then mirroring (0+1) them with another pair, or striping data across two mirrored pairs (1+0, aka 10). RAID 0+1, 1+0, and 10 require a minimum of four hard drives.

What do I need to set up RAID?

A Fresh Backup (existing data only): If you're installing and configuring hardware RAID on a fresh system with no OS (your best option), or are adding disks for a separate array, skip this. Otherwise, back up your important data. Best practice is to have three copies of your data: the original, a backup, and a backup of the backup, preferably offsite.
If you have existing data that you want on the array, you'll need to back it up, then restore it from a backup you make before creating your array--a process that writes new data to your hard drives regardless of what's there. This is not necessary with Windows software RAID 0, however, it's far faster than letting Windows re-sync (copy the data to) the mirror in the background.
Transferring an existing operating system is tricky, and with older versions of Windows, sometimes impossible. See "Transferring Existing Windows Installations to RAID" on the next page for instructions.
Windows Software RAID: Starting with Windows XP, Microsoft integrated RAID functionality into its operating systems. What type depends on the flavor of Windows:
  • Windows XP allows spanned volumes (one volume over two or more disks), aka JBOD.
  • Windows Vista Ultimate allows JBOD and RAID 1 striping.
  • Windows 7 Home allows JBOD and RAID 1 while Professional and Ultimate add RAID 0 mirroring. Windows 2000 Professional also has JBOD, 0, and 1.
  • Windows Server operating systems from 2000 on have JBOD, 0, 1, plus support for RAID 5 distributed parity.
Windows RAID offers several advantages. You can create arrays from within Window Drive manager so there's no BIOS to configure. It's also more flexible with mirrors, allowing you to create them from existing volumes containing data, as well as delete either half of a mirror with the other remaining intact. You can mirror individual partitions, including partitions from different drives onto a single drive.
The disadvantages are that other operating systems, such as the Linux used on repair discs, can't see Windows software RAID partitions which use Microsoft's dynamic disk technology. Also, maintenance performed by Windows when it feels it's needed, which can occur any time there's a configuration change, hurts performance while in progress. Restoring mirrors isn't as dead simple as it is with a hardware solution either.
Though you'll see a lot of talk about hardware RAID being faster, this discussion predates modern CPUs which can easily handle the overhead. Windows RAID is actually quite fast.
RAID controller: If you don't use software RAID, there's hardware. You probably already have a RAID controller in your PC; many older midrange and high-end motherboards come with secondary RAID controller, and newer motherboard chipsets offer integrated RAID obviating the need for an additional controller. Check your PC or motherboard documentation to find out if your motherboard supports RAID (and if so, which levels), and for specific installation instructions.
If your PC doesn't have integrated RAID, you may use an adapter card. Basic PCI and PCIe adapters supporting RAID levels 0, 1, 10, and sometimes 5 can be found online for $100 or less. AdaptecPromise and other vendors offer a wide selection of pricier, but more capable RAID adapters with onboard cache and advanced features. If possible, buy a card that supports greater-than-2.2TB disks and 6Gbps SATA III.
Two or more hard drives: If you decide on Windows software RAID, you may use any drives you choose. They need not be the same size if you're mirroring individual volumes, though it's generally a good idea.
Back in the days of parallel ATA, it was a no-no to mix drives from different vendors on a RAID controller. Sometimes it would work--more often it wouldn't. With the advent of SATA, mixing vendors is no longer as problematic.
Also, though there are controllers that allow mixing and matching capacities without losing storage space (using advanced parity techniques), these are still relatively rare. Using drives of different sizes usually results in total storage capacity that's only a multiple of the smallest drive. For example, combining 500GB and 320GB drives in RAID 1 would be 320GB * 2, or 640GB instead of 820GB.
In practice, you'll save yourself a lot of time and sidestep possible issues by building your array with identical hard drives--meaning drives of the same make, model, and size. You need at least two drives for RAID 0 and 1, three drives for RAID 5, and four for RAID 0+1, 1+0, and 10.
Floppy drive (Windows XP-only): If you plan to install Windows XP on your new array, you will need a floppy disk with your RAID adapter's Windows drivers, and a floppy drive to read it--Windows' installation won't install the drivers from an optical drive. Thankfully, this incredibly annoying limitation of Windows XP doesn't apply in Windows Vista and Windows 7 which can read drivers from hard drives, flash drives, or optical media.
Tools: You'll need a small, non-magnetic Phillips screwdriver to remove and replace the fastener screw that secures the adapter card to the PC chassis, as well as to install any new hard drives. You might also want a simple grounding strap that attaches to your wrist; look for one at your local computer store for less than $15. Alternatively, never touch exposed contacts or electronics.

Saturday, 1 June 2013

How to join a Ubuntu machine to a Windows domain

 No matter how you try, sometimes you can't escape the clutches of Microsoft and Windows. You might have a fortress of Linux solitude at home, but unless you are one of the lucky ones working in a Linux-only environment, you are going to have to interact with Windows.

One of the trickiest aspects of getting Linux to play well with Windows is the Windows Domain. For the longest time this was a challenge most were simply not ready (or able) to handle. This task required a very deep understanding of Samba and how to get Samba to communicate with that Windows domain. Even armed with that knowledge, this wouldn't always work. Even after hours of  editing your /etc/samba/smb.conf file, you found yourself stumped until you simply gave up.



That is, until now. Fortunately, things have continued to get easier on the Linux operating system to where even what was once the most challenging tasks are mundane. One such tool that has made the challenge of joining a Windows domain is Likewise Open. Using Likewise Open's handy GUI tool (that also comes with an equally hand command line version) you can quickly and easily connect a Linux machine to a Windows domain.

What you will need

    An already running Ubuntu installation (I prefer 10.04, but 9.10 should work fine).
    Domain name: This will be your company domain.
    DNS: If your machine uses something like OpenDNS, you might need to have the IP address(es) of your company DNS server(s).
    Access: You are going to need authentication credentials for an account that is able to join a domain.
    GROUP: You will need to know the group your user belongs to on the domain.

Installation

This is simple. Follow these steps to get both the GUI and command line tools installed:

    Open up the Add/Remove Software tool.
    Search for "likewise open".
    Marke likewise-open5, likewise-open5-gui,  and winbind for installation (the Add/Remove tool will pick up any necessary dependencies for you).
    Click Apply to install (and Apply to accept any dependencies).

That's it. You are now ready to join your Windows domain. Let's tackle this via command line first.

Joining using the command line
You will be surprised how easy this is to do. Open up a terminal window and issue the following command:

sudo domainjoin-cli join DOMAIN_NAME USER

Where DOMAIN_NAME is the name of the Windows domain you want to join and USER is the user you authenticate with. You will be prompted for your user password and, upon successful authentication, you will have officially joined that domain! You should be able to do things like browse all machines on your network domain as well as connect to your Exchange server using Evolution!

Now if you want to leave the domain you can do so equally as easy with the command:

sudo domainjoin-cli leave

This will drop you from the domain you are currently joined. Now let's take a look at the same task from the GUI tool.

GUI goodness

Likewise Open Gui

Figure 1
To start up the GUI click F2 and enter domainjoin-gui to open up the graphical tool (see Figure 1). This should be fairly straight-forward. You can name your computer what you want but you do have to use the exact domain name you would use to connect a Windows machine to your domain. In other words, if you domain is DOMAIN.LOCAL then use DOMAIN.LOCAL. If your domain is just DOMAIN then just use DOMAIN. As well, if you have to use an OU (Ogranizational Unit) to connect, make sure you have that correct.

Once you have the information entered click Connect and an authentication window will appear. In this window you must enter your username and your password as you would enter them when connecting on a Windows machine. After you enter your credentials click OK and Likewise Open will attempt to connect.

Upon successful authentication you will be a part of your company domain. Congratulations!

Logging in

Now log out of your desktop and log back in with your domain credentials. This most likely will mean you will log in with the username in the DOMAIN\user configuration. You can also log in to your local machine by logging in with the standard username and password on your local system.

Sudo issues

You will find, when logged into your domain, that your user doesn't have sudo privileges. This means you will not be able to install software and administer various tasks/tools. You can fix this by making an addition to the /etc/sudoers file. Do this with the following warning: You can really mess up your system with an improperly configured /etc/sudoers file...so use caution!

Open up the /etc/sudoers file and look for the line:

#Members of the Admin group may gain root privileges and do the following:

Under this line add the following:

%DOMAIN\GROUP ALL=(ALL) ALL

Where DOMAIN is the actual domain and GROUP is the group your user belongs to on the domain.

Now log out and log back in and your domain user should have sudoer privileges.

Final thoughts

I remember the days when joining a Windows domain was something very few could manage. Now anyone who can install an application can join a Windows domain. The method I describe has worked for me flawlessly on a number of domains. If you have trouble connecting to your domain, post the information below (just don't break company policy by posting information that should not be made public) and see how quickly any given member of the Linux.com community comes to the rescue. Bazinga!