Which RAID Settings Should I Use For My NAS?

RAID 1 (Mirror)

A NAS (Network Attached Storage) puts storage onto your network, where it can be accessed by many computers. They often have more than one hard drive which can allow you to have automated copies of your data, which is known as RAID. A common type of RAID found on NAS devices is RAID 1, which will make two hard drives into a mirror copy of one another. Some manufacturers call RAID 1 Safe mode. If you have a NAS with two 1TB hard drives and set them to RAID 1 mirroring, instead of 2TB of storage (1TB x2) you only get 1TB. Everything you store to the NAS gets saved to both drives automatically. The theory is that if one of the drives fail, you can access all of the data from the other one. In practice that is not always the case. More on that later.

RAID 1 Mirror Animation
RAID 1 Mirror Animation

RAID 0 (Stripe)

Another common NAS option is RAID 0. The “R” in RAID stands for redundant, however there is no redundancy in RAID 0, so it’s not a real RAID type. If you setup the same two 1TB disks as RAID 0, you will get a 2TB volume to store your data on. The problem is that every single file you write to the NAS will be split into tiny pieces and distributed across both drives. If one drive fails, you not only lose the data from that failed drive, but also from the non-failed drive as it only contains half the pieces of each file. RAID 0 should never be used for long term storage, but can be fast so is often used for video editing.

RAID 0 Stripe
RAID 0 Stripe

So that’s the hardware taken care of. What other things should you look out for when choosing a NAS?

Another problem with most NAS devices is the non-standard filesystems they use to store the data on the disks. If the NAS itself fails, you cannot usually read the disks by attaching them to a standard PC. So even in RAID 1 mirror mode, you could end up with no usable copies of your data. Most NAS drives run a simplified version of Linux, but only some of them use standard Linux filesystems like ext2/3/4.

Backup my backup?

Some NAS drives have a USB port to allow you to backup the data to an external hard drive. This is great, as long as you can access the backup data on a regular PC, and it doesn’t need to go through the NAS. You can imagine why that would be a problem.

To summarise, NAS drives can be a great way to upgrade your home or small office storage. They can allow collaboration and sharing of files between users, and should simplify your backup process. Just remember that a NAS is a small server that needs to be backed up as a matter of urgency. As long as you have that covered then a NAS can be a smart addition to your network.

Burning Linux ISO to USB Using a Mac

My main computer is an old MacBook Pro. I often download Linux ISOs to install on other computers. In recent Debian-esque releases this is actually really simple.

1. I find it quicker and easier to install from USB so first insert a USB pen / stick of some sort.

Note: This USB stick will be erased, so don’t use one with data that you need to keep!

2. Next we need to find out which number has been assigned to the USB stick. If you only have one disk in your Mac then the USB will usually be disk1, but always check first. (Note: Disks are numbered from zero, so your internal drive should be disk0) On your Mac open Disk Utility, which is located within Applications / Utilities. (See Image)

Disk Utility
Disk Utility

Select the USB stick from the lefthand window and then click the Info button which is on the toolbar. (See Image)

USB Info
USB Info

You will get a pop up window with loads of information about the device. We only need the Disk Identifier. Make a note of this for later.

Disk Identifier
Disk Identifier

3. To allow us to write data to the USB stick we need to unmount any volumes currently on there. (see image)

Unmount USB
Unmount USB

4. Now comes the actual writing. First locate the Terminal application, again within Applications / Utilities. (see image)

Mac Terminal
Mac Terminal

5. Remember to change the code to match your Disk Identifier from earlier. There are a few things to note about the following command.

  • sudo – allows you to run dangerous commands, so will require an administrator password
  • Instead of typing the location of the ISO file you can just drag the ISO onto the terminal when required.
  • “if” means input file (in this case the ISO file), “of” means output file (the USB stick)
  • When we found out the Disk Identifier, it was disk1. That will work in the command, but we use rdisk1 instead, which gives us raw access to the disk. This may not be necessary, but it works for me.

There is a lot of discussion about block sizes, but I find 4MB is reasonable for writing ISOs to USB. In Linux we often type bs=4M, however the Mac prefers it like bs=4096 instead. It’s the same thing, just expressed differently.

The command:

sudo dd if=[drag iso here] of=/dev/r[disk number] bs=4096; sync

Example:

sudo dd if=/Users/dan/Desktop/linux.iso of=/dev/rdisk1 bs=4096; sync

If you’ve got it right, you shouldn’t get any feedback until it finishes. Your USB stick may have a blinking LED whilst the data is being written. For reference the 200MB debian-netinst ISO took just over a minute to write.

Once complete you should get something like:

48896+0 records in
48896+0 records out
200278016 bytes transferred in 95.151719 secs (2104828 bytes/sec)

This means you’re finished. Now eject the USB and try to boot your PC with it. The Mac may complain that the disk is not readable but just ignore that and try it on a PC.

Debian Boot
Debian Boot

Dual boot Ubuntu & Windows

We needed a dual boot Ubuntu and Windows 7 setup today, which had a few stumbling blocks.

Problem 1. – GPT Partition

Installed Windows 7 on half a 500GB drive and left 250GB free for Ubuntu. When booting to install Linux, it didn’t see Windows 7 due to the GPT partition that Windows 7 uses by default.

Solution 1.

Used Gparted from the Linux live cd to format the drive with an MBR partition layout. (Note:- This destroyed the original Windows installation.) Then installed Windows back to the drive. This time, Ubuntu saw Windows 7 during installation and was happy to install alongside it.

Problem 2. – Default Windows Dual Boot

Although the machine was now happily dual booting, it would default to Ubuntu, regardless of which changes i made to the grub config. Startup manager would make changes to grub, but it would still default to Ubuntu.

Solution 2.

Nariub on the Ubuntu forums suggested changing the os-prober number, so it loads that first. This puts Windows at the top, making it the default. Perfect for what we needed.

The command for this, which worked for us on Ubuntu 11.10 & Windows 7:

mv /etc/grub.d/30_os-prober /etc/grub.d/09_os-prober
update-grub

So now we have the machine booting as we want, with each operating system happily taking up half of the 500GB drive.