Ceci est une ancienne révision du document !
Installing an OS on RAID disks is something not publicised with every distribution. Ubuntu used to have the alternative setup with which it was possible to create a RAID system, but I think it was around 12.04 or 12.10 when they stopped releasing it. OpenSuse still has it in their extremely versatile installation program. In this article, which is a rewrite of a story Tartifola wrote on the Mint forums on Wed Jun 26, 2013 (http://forums.linuxmint.com/viewtopic.php?f=46&t=138044#p735417), all necessary steps are explained to install Mint on a RAID configuration to get a really fast system. First a little explanation of what RAID is and why it is used. RAID comes in several flavors, of which 0, 1 and 5 are the most commonly used. In this article, I will explain how to use RAID 0; the other RAID's are not so different, especially setting up RAID 1 looks a lot like what will be explained here. RAID stands for Redundant Array of Independent (or Inexpensive) Disks.
L'installation d'un OS sur des disques RAID est un sujet qui n'est médiatisé dans aucune distribution. Ubuntu devrait avoir une configuration alternative avec laquelle il serait possible de créer un système RAID, mais je pense que sa publication a été arrêtée à la 12.04 ou la 12.10. OpenSuse l'a encore dans son programme d'installation extrêmement fourni.
Dans cet article, qui est une ré-écriture de l'article que Tartifola a écrit sur les forums Mint le Mercredi 26 juin 2013 (http://forums.linuxmint.com/viewtopic.php?f=46&t=138044#p735417), toutes les étapes nécessaires sont décrites pour installer Mint sur une configuration RAID, en vue d'obtenir un système vraiment rapide.
D'abord, une petite explication sur ce que veut dire RAID et pourquoi il est utilisé.
RAID existe en plusieurs variantes, parmi lesquelles 0, 1 et 5 sont les plus utilisées. Dans cet article, j'expliquerai comment utiliser RAID 0 ; les autres RAID ne sont pas très différents, particulièrement la configuration d'un RAID 1 qui ressemble beaucoup à ce qui sera expliqué ici.
RAID veut dire Redundant Array of Independent (or Inexpensive) Disks (Ensemble redondant de disques indépendants (ou bon marché)).
The Hardware: • Disks: because you need more than 1 physical disk to build a RAID. One disk with several partitions (which will then be called disks) won't do the job. • Independent: because, as I just wrote, the disks have to be real physical disks which can operate independently from each other. With more partitions on 1 disk, reading or writing on one partition can't be done when another action is active. The read/write head can't be in 2 places at the same time. • Array: the independent disks have to be placed together as a team to perform as one disk system, in what is called an array.
Le matériel :
• Disques : parce que vous avez besoin de plus d'un disque physique pour construire un RAID. Un disque avec plusieurs partitions (qui seraient alors appelés disques) ne feront pas l'affaire. • Indépendants : parce que, comme je viens de l'écrire, les disques doivent être de vrais disques qui peuvent fonctionner indépendamment l'un de l'autre. Avec plusieurs partitions sur un même disque, la lecture et l'écriture sur une partition ne peut pas être réalisée quand une autre action est en cours. La tête de lecture/écriture ne peut pas être à deux endroits à la fois. • Ensemble : les deux disques indépendants doivent être placés ensemble comme une équipe pour fonctionner comme un seul système de disques ; c'est pourquoi c'est appelé un ensemble.
The Software: • Redundant is the software or data part. On a RAID system, to prevent data loss when something goes terribly wrong, you need to write extra or redundant data to the disks. This is to make sure that, should a disk go haywire, all your original data can be brought back, one way or another. RAID was invented in a time when disks were not so dependable, at least not the smaller ones. The bigger disks, which at that time cost a fortune, were better, but nobody could afford them. By placing together smaller disks, and adding extra data, a system was created to get disk systems with more capacity, which were faster than just 1 disk, and were still affordable for the majority of computer users. RAID 0 is, technically speaking, not a RAID since there is no redundant data. Still, it is part of the RAID family. With RAID 0, data is chopped into chunks (16kB, 32kB, 64kB, 128kB, 256kB, 512kB, etc) whatever has been chosen when setting up the RAID), and those chunks of data are sent to the disks, one chunk to disk 1, the next chunk to disk 2, then disk 1 again, and so on. The hard disk controller (in this case renamed RAID controller) does all this for you. This means that both disks are only reading/writing half of the total amount of data which reduces the read/write time. With RAID 0, since no redundant data is written onto both disk partitions, you get a new “disk” with a free writable area with a size equal to the sum of the disk partitions used to create the RAID.
Because RAID 0 has no redundant data a warning is in order: Should a disk go haywire, you have lost everything, both your OS AND your data. With Just a Bunch Of Disks (JBOD), you will either still have your OS on one disk or your data on the other when one fails. With RAID 0, because all data is chopped into small pieces and those pieces are written intermittently to the 2 disks, you will only have parts of the files. You can see that you have only parts 1, 3, 5, 7 and 9 of a file when disk sdb fails. In other words, you end up with nothing. Using RAID 0 means making daily backups in order not to loose anything. Rsync, or even nicer, Grsync (with GUI) is a great program to do that. Before starting, it is a good idea to write down the partitioning scheme you plan to use. Think well about this, it is either the key to success or defeat. A Linux operating system needs a minimum of 2 partitions, one for “/” (the system disk), the other for “swap” (extended memory placed on disk should you run out of your normal memory). It is, however, a good idea to introduce a third partition, one which will be used for “/home”. It makes re-installing the OS, or even installing another one, so much easier. With a separate /home partition, you can keep all your data when re-installing, although it is always a good idea to make a good backup before you start. Now since the OS can't boot from a “/boot” folder within the RAID, we will make one more partition, a normal non-RAID one, for “/boot”.
1. Preparing the disks All the operations to set up the disks, the RAID 0, and installing the OS, can be done from within the OS, so we will boot the computer with a live Mint disc (or USB stick). I use the KDE version for this since this is my favorite desktop environment. The first thing we need to do is to prepare the disks we want to use for Mint. This needs to be done now since the disks are not used at the moment; we use only the DVD or USB stick. In your live system you either have a partitioning program, or you can install gparted from the repositories. In my KDE system, I have KDE Partition Manager, so I am using that. I have used the following setup to install Mint in a virtual machine in which I created 2 disks each of 25GB. I made the following partitions on both disks: In the picture (below left) you see the partitioning scheme for the sda disk, the one for sdb is exactly the same. Before adding the partitions to both disks, it is good to choose menu “Device” first and from that menu, you choose New Partition Table. In the new smaller pop-up window, click on Create New Partition Table and finally click in the Toolbar on the Apply button. Do this for both disks. Now both disks are empty and you can start making your partitions on them.
With the exception of sda1, which is going to be used for “/boot”, all partitions can be created without a file system. They will be used by the RAID setup, and a file system will be assigned to them later: • As said, sda1 will be used by “/boot”. Its counterpart, sdb1, will not be used at all. It is created just to keep both disks exactly the same. • sda2 and sdb2 will become md2 (multiple disk = RAID) and will be used for “/” with a total size of 16GB (sda2 + sdb2 = 8 + 8 = 16GB ). The number 2 is used because also the partitions have number 2. The MD number is however free to choose. • sda3 and sdb3 will become md3 and will be used as swap with a total size of 4GB • sda4 and sdb4 will be md4 and used for “/home”, making one partition of around 30GB. Right-click the line with the unallocated portion of the disk, choose New. A new window will pop up in which you choose the size of the new partition; you select Primary partition and (with the exception of sda1 which will have ext4), choose unformatted as file system. Do this for all the partitions you want to have. When done, click Apply to make the choice final. Do this for both disks.
2. Install mdadm In order to build a RAID, you need a program called mdadm (Multiple Disk Administrator). Use apt-get to install the most recent version. Open a terminal and type: sudo apt-get install mdadm When you are not used to the terminal and typing instructions, you can also use your favorite software installer to do the work. Mind you, in the next part you will have to use the terminal.
3. Creating the array (RAID 0) I created 3 arrays, one for /root, one for swap, and the last one for /home using: sudo mdadm –create /dev/md2 –verbose –level=0 –raid-devices=2 /dev/sda2 /dev/sdb2 sudo mdadm –create /dev/md3 –verbose –level=0 –raid-devices=2 /dev/sda3 /dev/sdb3 sudo mdadm –create /dev/md4 –verbose –level=0 –raid-devices=2 /dev/sda4 /dev/sdb4 (Mind the spaces in between the used options). Because we will not choose the chunk size ourselves the default value of 512kB will be used. To finish the partitions, I applied an ext4 file system to them. sudo mkfs.ext4 /dev/md2 sudo mkfs.ext4 /dev/md4
For Swap (md3) we have to use: sudo mkswap /dev/md3 You can check the status of your arrays with the instruction “cat /proc/mdstat”: md4 : active RAID 0 sdb4[1] sda4[0] 31192064 blocks super 1.2 512k chunks md3 : active RAID 0 sdb3[1] sda3[0] 4193280 blocks super 1.2 512k chunks md2 : active RAID 0 sdb2[1] sda2[0] 16776192 blocks super 1.2 512k chunks unused devices: <none>
4. Launch the Installation At this stage you can launch the Mint installation and follow the steps until it asks for the installation type (ie, where you have to choose if you would like to erase your entire disk and install Mint or …). You will see this: Choose “Manual” or “Something else” (depending on your version of Mint, the last option in the list) and pay attention. The picture will now change into: Clicking on Continue gives you this: In the above picture, you see the 3 md's (2, 3 and 4) which have either the ext4 filesystem or swap. You also see the partitions which are used to build the RAID. If the previous steps are OK, you should be able to choose to mount md2, md3 and md4 to /root, swap and /home. Click on the line that says: /dev/md2 ext4 Click on 'Change…'
Choose the items as shown in the picture bottom left. Click OK Do the same for md4 which will have a mount point of /home. Md3 will be used as swap. Here you need to choose swap area where it says: Use as: Other items for swap can be left as is since they are grayed out. Finally, mount /dev/sda1 to boot/ with file system ext4, and at the bottom of the Prepare Partitions picture, choose /dev/sda as the installation media for Grub. Continue with the installation till the end but DO NOT REBOOT the machine. Choose: Continue Testing, and remain in the liveDVD. Remark: Here you see the KDE version of the Installation Complete window. In other versions, the 2 buttons might have switched places. So don't just assume you have to click the right one – read the text on the buttons.
5. Install mdadm in the new environment Now comes the tricky part. Just now you say? Yes, so far it was easy going, but now things are getting serious. After the installation of the OS has completed, you still need to do one thing: install mdadm in the new setup. For this you need a terminal again… sorry… so open one. First you need to mount the array on which your system (/) has been installed (/dev/md2 in my case). The directory target is made during installation of the OS, we will now use it to mount (connect) several parts of our installed system to it. This way we can jump into the installed version very easily. Type: sudo mount /dev/md2 /target/ sudo mount –bind /dev/ /target/dev/ sudo mount –bind /sys/ /target/sys/ sudo mount –bind /proc/ /target/proc/ sudo mount /dev/sda1 /target/boot/ (again mind the spaces in the above lines).
Before chrooting, remember to adjust the /etc/resolv.conf file in the new environment: sudo cp /etc/resolv.conf /target/etc/resolv.conf Then you can chroot. Chroot means change root. It's a way to jump from one OS into another, in this case to the freshly installed one, which is mounted (connected) to the folder target in the live version we are still using: sudo chroot /target Install the proper software in the usual way and adjust grub to your likings: sudo apt-get update sudo apt-get install mdadm sudo grub-install /dev/sda 6. Reboot the system During reboot, you will be asked to remove the installation medium. Do this and press Enter. You will now boot into the installed OS on the RAID 0 system.
BIO : Jan is a 57 year young Linux enthusiast who started using Ubuntu in 2008 (Hardy Heron), and is still learning about Linux every single day.