Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Thursday, June 9, 2011

Ubuntu on a FakeRAID 1

setting-up-nvidia-nforce-fakeraid-on-ubuntu-10-10
ubuntuforums.org  READ IT!
Source
Edit: These information work for Ubuntu Breezy. Things may have changed with Dapper Drake
Most cheap hardware RAID controllers such as the VIA VT6421 are not purely hardware RAID systems, but should be seen as semi-soft, or FakeRAID controllers.
In order to install an Operating System on a FakeRAID array, it is thus necessary to setup a few things, since the underlying array is not completly transparent to the Operating System.
This short article, based on the Ubuntu Wiki FakeRaid HOWTO explains how to install Ubuntu Linux on such a FakeRAID array.
First of all, be aware that is it not currently possible (well, it is, actually, but one would have to revert to applying hacking changes in the Initial Ramdisk Image, so it is currently better to forget about it) to setup an LVM Volume on top of a FakeRAID array.
Since the Ubuntu Wiki FakeRaid HOWTO already explains how to install Ubuntu on a FakeRAID/0 array, I am just going to highlight the differences for a FakeRAID/1 array here.
The only difference is the creation of the Initial Ramdisk, which should load the dm-mirror module to allow the OS to read / write from the FakeRAID array.

There is a bug for those who wants to CTRL+C – CTRL+V this script.
Some quotes are not ASCII.
PREREQ=””
PREREQ=”"
 The /etc/mkinitramfs/scripts/local-top/dmraid should be replaced by
#!/bin/sh
PREREQ=”"
prereqs()
{
echo “$PREREQ”
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
modprobe -q dm-mod
modprobe -q dm-mirror

/sbin/dmraid -ay
In addition to the dm-mod module, the previous script launches the dm-mirror module. This means that the dm-mirror module should be copied. This is done by adding the line
dm-mirror
to the /etc/mkinitramfs/modules file.
in hardy heron /etc/mkinitramfs doesn’t exist.
where create the dmraid script???
maybe in /etc/initramfs-tools/scripts/local-top/dmraid???

The rest of the Ubuntu FakeRaid Howto gives a good explanation of the tasks that should be done in order to configure the FakeRaid array.
===========================
FakeRAID Howto
Introduction
What is fakeRAID?

In the last few years, a number of hardware products have come onto the market claiming to be IDE or SATA RAID controllers. These have shown up in a number of desktop/workstation motherboards and lower-end servers such as the HP DL360 G5, if ordered without the optional RAID card. 
Virtually none of these are true hardware RAID controllers. 
Instead, they are simply multi-channel disk controllers combined with special BIOS configuration options and software drivers to assist the OS in performing RAID operations. This gives the appearance of a hardware RAID, because the RAID configuration is done using a BIOS setup screen, and the operating system can be booted from the RAID. With the advent of Terabyte disk drives, FakeRAID is becoming a popular option for entry-level small business servers to simply mirror 2 1.5 TB drives, and dispense with an expensive hardware RAID 5 array.
Older Windows versions required a driver loaded during the Windows install process for these cards, but that is changing as it has already changed in FreeBSD (which has FakeRAID support built into the ATAPI disk driver). 
Under Linux, which has built-in softRAID functionality that pre-dates these devices, the hardware is normally seen for what it is:
--multiple hard drives and a multi-channel IDE/SATA controller. Hence,  fakeRAID.
Why not use a linux software raid? If you have arrived here after researching this topic on the Internet, you know that a common response to this question is, "I don't know if you can actually do that, but why bother -- Linux has built-in softRAID capability." Also, it's not clear that there is any performance gain using hardware fakeRAID under Linux instead of the built-in softRAID capability; the CPU still ends up doing the work.
The most common reason for using fakeRAID is in a dual-boot environment, where both Linux and Windows must be able to read and write to the same RAID partitions.
Multiboot configurations are common among users who need multiple operating systems available on the same machine. These people shouldn't have to add a separate hard drive just so they can boot Linux. FakeRAID allows these users to access partitions interchangeably from either Linux or Windows.
Another reason for using FakeRAID is if you define a disk mirror and a hard drive crashes, you can down the system and replace the failed drive and rebuild the mirror from the BIOS without having to boot into the operating system.
/!\ That said, linux software RAID is more robust and better supported and thus, recommended over fakeRAID if you do not need to dual boot with Windows.
This wiki describes how to get Linux to see the RAID as one disk and boot from it in the same way that windows will install on this type of device. This document is constantly updated by users like you and is a "living" document to which your contributions are welcome.
Notes General Notes
/!\ Ubiquity will fail when installing grub, and will not automatically add dmraid to the new installation. This needs to be done manually. The Installation guide for 8.10 and 9.04 contain the steps required to manually install these items.
/!\ 'Alternate CD' is different to the standard Ubuntu iso download. Trying to install a fakeRAID Ubuntu with the standard ISO using the Alternate CD install method will fail.
/!\ The Live CD is not present in any server install ISOs. Use the desktop ISO.
/!\ It's critical to have dmraid loaded if you're in a dual-boot environment, with the /dev/mapper/XX entries. If you install to the drives without this running you WILL have access to the section of the hard drive that the disk metadata is located on that the controller uses, and you can wipe it out or damage it, ruining your array. If your FakeRAID array is striped, not mirrored, you will scramble all your data if this happens.
RAID-1
/!\ You should be aware that dmraid (especially the dm-raid1 target of the device mapper) (at least up to kernel version 2.6.17) supports the mirroring with RAID-1, but it has no error handling. When a block on one disk fails a failure reaches up to the application level, currently it doesn't try to read from the second disk. It only mirrors all data to the second disk.
So it secures the system from data loss, but the system can nonetheless crash. There exists patches for the 2.6.17 kernel series which enables a higher read speed and error handling in failure case, but until now they are not incorporated.
External links regarding RAID-1: Running Ubuntu On a Fakeraid/1 array described how to adapt the original HOWTO to a RAID-1 (mirroring) array.
RAID-5
Since version 8.10 (Intrepid Ibex) Ubuntu has RAID5 support built into the kernel loading the right module. also dmraid is now in the 'main' respository, and can be installed without reconfiguring apt. Once dmraid is running, the live installer can handle installing to the raid.

Installation

Ubuntu 10.04 (Lucid Lynx) and 10.10 (Maverick Meerkat)
The installer will recognize the dmraid devices and allow you to use them normally. Their names will be /dev/mapper/something instead of /dev/sdX. You need to install grub to the dmraid device instead of /dev/sda. In 10.04 the final stage of the installation you check the advanced button and can select where to install grub to. In 10.10, you choose the destination from the drop down list on the manual partitioning screen.
Ubuntu 9.10 (Karmic Koala)
The automatic installer may or may not work out of the box. When I tried it, it didn't work the first time and I had to manually install dmraid. But it did work the second time on the same machine, (with disks that had been wiped) The problem appears to be installing grub2
Use the LiveCD method
* Boot the system with the Live CD
* Run the partitioner program gparted (System->Administration->GParted)
9.10 loads dmraid automatically so you should see for a disk device
/dev/mapper/pdc_feddabdf or some suchlike
if dmraid detected and can use a fakeraid partition
* Setup an extended partition using whatever space your going to allocate for Ubuntu or the entire drive. Setup a minimum of 2 logical partitions in the extended partition, the first will be formatted ext4 and the last swap. Set the type on the swap partition to swap. Format the first partition. Exit gparted
* Run the installer. When it gets to it's partitioner, change the mount point on the first partition to / DO NOT format it! Do NOT make any partition changes! The installer partitioner does not understand dmraid partitions properly
* In the installer summary screen right before the copy process starts, click the Advanced button. Change the boot partition (this is the MSDOS-style "parent" partition not the Linux partitions) to /dev/mapper/pdc_feddabdf (or whatever dmraid lists as your fakeraid partition) Make sure the checkbox is clicked to boot from this disk. note that the installer will modify grub2 to point to the correct logical partition /dev/mapper/pdc_feddabdf1 or whatever / is on.
* When the installer finishes DO NOT REBOOT, the new system will be mounted on /target. If you rebooted then run the terminal screen and mount the /dev/mapper/pdc_feddabddf4 (root) partition (this is the target the installer put the root on) on some convenient directory (/tmp/tmp or some such) chroot that directory (/target or whatever it's mounted on)
* Run the command "apt-get install dmraid" If your lucky you will get a message back saying that the system didn't need to do anything as the installer will have correctly built initrd for grub to include dmraid. Otherwise this will update dmraid and rebuild the grub init to load dmraid. Exit the terminal and click reboot, or type "shutdown -r now" at the terminal window
* When the system comes back up login and verify that /dev/mapper/pdc_feddabdf (or whatever dmraid names your fakeraid) exists, and use df to verify that the system is mounted on it. (it will say it at the top)
Contributions
Gigabyte MA78GPM-DS2H  15 Jan 2009
I've just managed to make work a Gigabyte MA78GPM-DS2H motherboard RAID controller in RAID-1 mode. This is a pdc controller.
I configured RAID using BIOS, launched 'try Ubuntu' mode and added dmraid as described at the top of the page. Unfortunately, I've got the following error:
dmraid -ay 
ERROR: creating degraded mirror mapping for pdc_xxxxx

dmraid -r noticed only the second disk of the pair. More strangely, after reboot, BIOS launched an alarm that one of the disks is nonfunctional. The alarm gone after hard reset.
Now the solution: go to BIOS, delete your configuration and create it again. But this time change two options:
  • - "Gigabyte bonduary" to "NO" - "Fast Init" to "NO"
This time the RAID matrix and both devices are detected fine.
I am now waiting until Ubuntu is installed, hopefully grub part will be easy... Regards.  
----------------------------------
Windows XP fails  26 Jan 2009
I followed these instructions - Method 2 in long - and they worked perfectly EXCEPT for booting Windows.
Windows was an XP installation on a single ATA drive that wasn't part of the (new) RAID. The system BIOS was set to boot SCSI (which meant it was booting the RAID). GRUB couldn't make windows boot - it stalled on the final step.
The section is "Chainloading Windows on a non-first hard disk". The problem lies with Windows - it expects to be on the first drive. In the Windows section of Menu.lst, I now have:
title          Windows XP
rootnoverify   (hd1,0)
makeactive
map   (hd0)  (hd1)
map   (hd1)  (hd0)
chainloader    +1
hd0 is my (booting) RAID as seen by GRUB. hd1 is my (non-booting) ATA drive with windows in the first partition (hd1,0). The two map commands fool Windows into thinking it is on the first drive. This works.
--------------------------------------
Asus A8V 25 Apr 2009
I have an Asus A8V motherboard and had Gutsy running on it for some time. The moment I activated SATA raid (with two new drives), I could not boot my computer. Adding "pci=nomsi" to the kernel line in Grub or the F6 boot options on the Live CD, fixed it.
Possibly because of the above issue (or not?) I could not set the raid set for boot in the BIOS. I am currently using an ide drive for the boot partition. I also have Ubuntu installed on the ide drive """for emergencies""". Another good trick is to create a Live CD partition on a hard drive! See: https://help.ubuntu.com/community/Installation/FromHardDriveWithFloppies this allows very fast installation!
I am using the six partition method with boot (ide drive) and the rest on raid. For some reason, the initramfs image did not get sent to my boot partition and the raid OS would not boot. If you suspect this, mount your root partition without mounting the boot partition and look in the boot directory (/target/boot). It may be hiding there.
I have found that gparted does not work correctly (for me). I used fdisk and mkfs.
Another strange situation is, during Live CD installation, the partition section shows multiple lines for each of the raid partitions. Some of these had "no number". I installed to the partitions "with" numbers and deselected the "no number" partition for swap use. This allowed the installation to work.
Also, if you are using a Live CD install, ""do not"" deselect grub install. It could wreck any previous grub instalaltion.
----------------------------------------
Ubuntu 9.10 How-To
I have provided a post on the forums instructing how-to install 9.10 using fakeraid here
Basically you install using the live cd (alternate CD no longer required in 9.10) then boot into the live cd to remove GRUB2 and install+configure GRUB legacy.
GRUB2 currently does not have the means to boot a fakeraid setup and is rumored to be fixed in time for 10.4's release.  
----------------------------------------
Ubuntu 10.04 Installation on isw fakeraid
Had to work around the installer. Q&A'ed it in question 108677 in launchpad. 
Trick was using chmod on the disc's root partition! Just mount the root partition into the /media folder. Then sudo chmod 755 /media/fake  
----------------------------------------
Ubuntu 10.04 Addition for the Live CD installation (Ubiquity Graphical installer)
(Own experience with an intel RAID 0 array and 10.04 Kubuntu 64 bits following this wiki)
4.a. dm_raid45 (not "dm-raid4-5") module was already loaded. You can check it by doing
$ sudo lsmod

4.b. dmraid package was already installed but it is still safe to run this command to make sure.
5.a. alternatively you could test you raid array by running this
$ sudo dmraid -tay

6. Partitioning and formatting with ubiquity installer didn't work for me. I had to do it before launching the ubiquity installer.
6.b. After creating new partition on the raid array with cfdisk, you have to launch this command again
$ sudo dmraid -ay

  • Output should show the activation of the new partition(s).
6.c. Format the new partition(s) with the file system you want
$ mkfs.ext4 /dev/mapper/isw_beeaakeeaa_fiveZ

  • Z is the number of the new partition.
    • Example: $ mkfs.ext4 /dev/mapper/isw_beeaakeeaa_five5
8.a. Do not format nor partition using the ubiquity installer. in manual mode, choose the "/" mounting point on the partition you want and make sure "format" checkbox is unchecked. As you already format the partition in the step 6.c. it should allow you to attach "/" without formatting.
9.l.ii The command find /boot/grub/stage1 resulted in an error for me I had to do the following command to make Grub recognize my raid array
grub> geometry (hd0) C H S

  • Replace C H S (Cylinders, Heads and Sectors) above with the proper numbers. You can find them using cfdisk at the top of the main screen (be aware: they are not displayed in the same order).
    • Example: 18079 255 63 for a RAID stripe of two 74GB Raptor discs.
9.l.iii
grub> root (hdY,X)

  • Replace Y with the drive number. Usually 0 as specified in the step 9.l.i.
  • Replace X with the partition number from the previous step.
    • Example: root (hd0,4)
9.p. Make sure the device.map file is correct. This file is used to map the dmraid device to a grub hdY.
  • Edit the file:
# nano /boot/grub/device.map

  • and add the following line:
(hd0) /dev/mapper/isw_beeaakeeaa_five

  • Make sure there is no other line beginning by (hd0).
If you have multiple dmraid devices with multiple sets of arrays set up (say: nvidia_fdaacfde and nvidia_fffadgic), then create the /boot/grub/device.map file to help GRUB retain its sanity when working with the arrays. Using these dmraid devices, your device.map file will look like this:
(hd0) /dev/mapper/nvidia_fdaacfde
(hd1) /dev/mapper/nvidia_fffadgic

10.a.
# echo dm_raid45 >> /etc/initramfs-tools/modules

10.c.
# nano /etc/modules

  • and add dm_raid45 if not exists
11. Dual-Boot configuration.
  • /!\ In case of a dual boot with Win7, grub may have some problem to launch windows. An easy solution is to install grub on the linux partition (not the MBR). Cf. step 9.l.iv, grub> setup (hd0,4) Then, use the Win7 boot manager to choose between windows and linux. To add a new entry into the win7 boot manager, you can use the official "bcdedit" command or the unofficial graphical utility named "EasyBCD 2.0 beta".
------------------------------------------------
Ubuntu 10.10 Addition for the Live CD installation (Ubiquity Graphical installer)  
(Own experience with an nvidia RAID 0 array and 10.10 Ubuntu 64 bits following this wiki)
The built in installer nearly works. There is just some issue about a restricted hard-drive area used by some motherboards, which is ignored by default in Ubuntu. Ignoring this area interferes with fakeraid, so you need to enable the restriction by adding
libata.ignore_hpa=0
to the boot options. It wasn't me who figured that out.
Have a look at http://samueltaylor.me.uk/2011/01/31/setting-up-nvidia-nforce-fakeraid-on-ubuntu-10-10/ for the full story and a more detailed tutorial. Note that his conclusions are a bit off in that this doesn't have anything to do with nVidia, and ignore_hpa=0 actually DISABLES access to the protected area, not enables it.
You actually have the meaning of ignore_hpa upside down. By default Ubuntu has ignore_hpa=1, which means it ignores the protection mechanism and ALLOWS access to that part of the disk. This interferes with the fakeraid because the bios writes the metadata relative to the end of the disk when the protection is in place. When the kernel unlocks the HPA, the metadata is now in the wrong location relative to the real end of the disk.
Also this is not an nVidia nvraid thing. The vast majority of motherboards do not use the HPA. Whether they are nVraid or otherwise, a few oddball boards enable the HPA for no apparent reason.
How-to Install 9.10 karmic on fakeraid
This is how I installed 9.10 karmic onto a stripped fakeraid Raid 0 array. These instructions may or may not work for a mirrored raid 1 array, I have gotten limited feedback on this. All you really need is the LiveCD and an internet connection. The steps outlined here are used after Ubuntu has been installed but fails to boot. Just load the LiveCD environment and follow these steps. Mind you this may be a daunting task to a person new to Ubuntu but if you have any command line experience you should be fine. I made this how-to cause I felt many others were lacking in some areas. I had searched around the net and found bits and pieces to make this work and thought how nice to have it all in one spot so here it is. ##Note this works on ext4 w/o any patch, 9.10 no longer requires install via Alternate CD as the LiveCD has dmraid included, also note fdisk does not work well with dmraid use gparted instead.
1. Open a terminal: Applications, Accessories, Terminal.
2. Create a mounting point
sudo mkdir /mnt/root
3. ls /dev/mapper
In this example the output would have shown "nvidia_cffbdeda, nvidia_cffbdeda1, nvidia_cffbdeda2" where nvidia_cffbdeda is the hdd. All the others listing a # on the end are the partitions. If you don't know what partition is the root of your installation check out gparted. I will use nvidia_cffbdeda1 in the following steps as an example for mounting and chrooting into the installation.
4. Mount the installation
sudo mount /dev/mapper/nvidia_cffbdeda1 /mnt/root
*If this fails use nautilus (thunar in xbuntu) to mount your Ubuntu root partition then use mount to find the mount location. This location will be used in place of /mnt/root in the following steps.
sudo mount --bind /dev /mnt/root/dev
sudo mount -t proc proc /mnt/root/proc
sudo mount -t sysfs sys /mnt/root/sys
sudo mount -t devpts devpts /mnt/root/dev/pts
sudo cp /etc/resolv.conf /mnt/root/etc/resolv.conf

5. Login into the installation
sudo chroot /mnt/root /bin/bash
6.Fetch most recent package lists
apt-get update

7. Remove GRUB2
apt-get purge grub2 grub-pc
rm -r /boot/grub
##The system will be unbootable until another bootloader is installed.
8. Install GRUB 0.97
apt-get install grub
grub-install /dev/mapper/xxx ##note please substitute your hdd in this line (mine would have been nvidia_cffbdeda)
9. At this point it may be a good idea to check the device.map
chmod 777 /boot/grub/device.map##For write access
nano /boot/grub/device.map
Mine was incorrect and I changed it to:
(fd0) /dev/fd0
(hd0) /dev/mapper/nvidia_cffbdeda ##was listed as /dev/sda which is incorrect
(hd1) /dev/sdc
Afterwards use this to restore file permissions
chmod 744 /boot/grub/device.map
If changes were made then re-run grub-install
10. grub --no-curses ##you will now be at the grub prompt##
grub> device (hdx) /dev/mapper/xxx ##note please substitute your hdd in this line
grub> find /boot/grub/stage1 ##make a note of the output it is used in the next step
grub> root (hdx,y) ##(hdx,y) where x is the drive (most likely 0) and y is the partition (first partition would be 0 NOT 1)
setup (hdx)
quit
update-grub
##When prompted to generate a menu.lst file say yes
13. Run these commands to keep it from upgrading automatically:
echo "grub hold" | sudo dpkg --set-selections
echo "grub-common hold" | sudo dpkg --set-selections
14. Reboot
As much as I have tried to make this guide complete it seems to not work for some people and anyhelp I can get in making this guide complete is much appreciated. Namely Raid 1 issues.
Step 10 problems arise when you don't specify the correct device for (hd0)
BIOS boot order can also affect this step so make sure it's correct
In some extreme cases it's necessary to remove other hard drives from the sys as some cheap motherboards lack the understanding of fakeraid and tell grub IDE devices boot first. Thus effectively installing grub to the wrong disk in some cases.
Read a lot More at link

No comments: