= Installare Slackware 12.0 con Raid Software su HD Sata2 = <> Eccoci qui per un'altra guida dedicata alla nostra amata Slackware. Con questo howto affronteremo il "problema" dell'installazione del nostro OS preferito su un'architettura raid gestita via software. Vedremo inoltre come cambiare il bootloader di default (lilo) in grub. == Software e hardware utilizzati == I cd o il dvd della Slackware 12. mdadm ( già presente sul cd della Slackware ) 2 hd sata2 .... == Cosa faremo == Gli hd sata vengono riconosciuti come sd[abcd...]. Nel nostro caso dato che utilizzeremo solo 2 hd avremo che il primo hd verrà ricosciuto come /dev/sda e il secondo come /dev/sdb. Per gestire il raid software utilizzeremo l'utility mdadm nativamente presente in Slackware. Il nostro scopo è quello di creare una partizione raid 1 (mirroring puro) per root (mount point /), una partizione raid 1 per la home (mount point /home) e due partizioni di swap, una per disco. Questo schema è naturalmente modificabile a vostro piacimento. Una volta creati e configurati gli array raid, il OS farà riferimento agli hd tramite /dev/md[0-9] secondo lo schema seguente : raid1: (sda1,sdb1) ---> md0 raid1: (sda3,sdb3) ---> md1 Inoltre avremo altre due partizioni, una per disco fisico, dedicate allo spazio di swap: sda2 ---> swap sdb2 ---> swap == Prerequisiti == Per permettere ad mdadm di gestire il raid software è NECESSARIO disabilitare la gestione del raid hardware dal bios della scheda madre. == Preparazione == Cominciamo. Avviamo il pc con il cd o dvd della Slackware. Alla richiesta {{{ boot:_ }}} digitiamo una delle tre opzioni possibili. Personalmente io ho scelto hugesmp.s poichè ho un sistema multiprocessore. Scegliamo la mappatura della tastiera ed entriamo finalmente nella nostra shell. Se tutto è andato bene I vostri hd sata2 dovrebbero corrispondere a /dev/sda e /dev/sdb. Cominciamo il partizionamento di sda con il vostro tool di partizionamento preferito (io ho utilizzato fdisk). Di seguito è mostrata la tabella delle partizioni presente sul mio /dev/sda: {{{ bash-3.1# fdisk /dev/sda The number of cylinders for this disk is set to 48641. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/sda: 400.0 GB, 400088457216 bytes 255 heads, 63 sectors/track, 48641 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 9484 76180198+ fd Linux raid autodetect /dev/sda2 9485 9728 1959930 82 Linux swap /dev/sda3 9729 36476 214853310 fd Linux raid autodetect /dev/sda4 36477 48641 97715362+ 7 HPFS/NTFS }}} Come si può vedere, ho creato due partizioni Linux raid ( /dev/sda1 e /dev/sda3 ), una di swap ( /dev/sda2 ) ed una dedicata a Windows (ma su questa sorvoliamo ). Quando lancerete fdisk per la prima volta su un hd mai partizionato ( come quelli appena comprati), dovrete procedere alla creazione delle partizioni. Per creare una partizione Linux raid da fdisk si procede in tal modo: {{{ Command (m for help): n ----> diciamo ad fdisk che vogliamo creare una nuova partizione (farà parte di md0) Command action e extended p primary partition (1-4) p ----> partizione primaria Partition number (1-4): 1 ----> 1 perchè è la prima che creiamo First cylinder (1-48641, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-48641, default 48641): +78000M ----> dimensione della partizione in MB Command (m for help): n ----> diciamo ad fdisk che vogliamo creare una nuova partizione (servirà per lo spazio swap) Command action e extended p primary partition (1-4) p ----> partizione primaria o estesa a vostra scelta(sono possibili massimo 4 partizioni primarie) Partition number (1-4): 2 First cylinder (9485-48641, default 9485): Using default value 9485 Last cylinder or +size or +sizeM or +sizeK (9485-48641, default 48641): +2000M Command (m for help): n ----> diciamo ad fdisk che vogliamo creare una nuova partizione (farà parte di md0) Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (9729-48641, default 9729): Using default value 9729 Last cylinder or +size or +sizeM or +sizeK (9729-48641, default 48641): +200000M Command (m for help): t ----> serve a definire il tipo delle partizioni Partition number (1-4): 1 ----> selezioniamo la prima partizione Hex code (type L to list codes): l ----> visualizza l'elenco dei tipi possibili x e partizioni 0 Empty 1e Hidden W95 FAT1 80 Old Minix be Solaris boot 1 FAT12 24 NEC DOS 81 Minix / old Lin bf Solaris 2 XENIX root 39 Plan 9 82 Linux swap c1 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 5 Extended 41 PPC PReP Boot 85 Linux extended c7 Syrinx 6 FAT16 42 SFS 86 NTFS volume set da Non-FS data 7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / . 8 AIX 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility 9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ee EFI GPT 10 OPUS 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/ 11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b 12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f1 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f4 SpeedStor 16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fd Linux raid auto 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fe LANstep 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT 1c Hidden W95 FAT3 75 PC/IX Hex code (type L to list codes): fd ----> impostiamo il tipo a Linux raid auto (fd) Changed system type of partition 1 to fd (Linux raid autodetect) Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): 82 Changed system type of partition 2 to 82 (Linux swap) ----> impostiamo il tipo a Linux swap (82) Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): fd ----> impostiamo il tipo a Linux raid auto (fd) Changed system type of partition 3 to fd (Linux raid autodetect) Command (m for help): a ----> definiamo quale partizione dovrà essere bootable Partition number (1-4): 1 ----> in questo cas sarà la prima (sda1) Command (m for help): w ----> scrive sulla tabella delle partizioni le modifiche impostate finora }}} Ora dobbiamo procedere con il partizionamento del secondo hd /dev/sdb. E' importante che le dimensioni delle partizioni raid1 tra sda e sdb corrispondano. Per far ciò ci sono 2 metodi: * procedere con fdisk /dev/sdb in modo identico a quello fatto per /dev/sda * lanciare {{{ sfdisk -d /dev/sda | sfdisk /dev/sdb }}} che imposta la tabella delle partizioni di sdb in modo identico a quella di sda (se avete un altro OS, tipo Windows, non credo che questo metodo vi serva). Ora che abbiamo impostato le tabelle delle partizioni, procediamo con la creazione e attivazione dell'array raid. Come già detto creeremo un array raid1 con le partizioni sda1 e sdb1 e un secondo array raid con le partizioni sda3 e sdb3. {{{ bash-3.1# mdadm --create /dev/md0 --level=1 \ --raid-devices=2 /dev/sd[ab]1 Continue creating array? yes mdadm: array /dev/md0 started. bash-3.1# mdadm --create /dev/md1 --level=1 \ --raid-devices=2 /dev/sd[ab]3 Continue creating array? yes mdadm: array /dev/md0 started. }}} Ha così inizio la creazione dei due array. Ci vorrà un pò di tempo prima che finisca (dipende dalla dimensione dei dischi). Potete verificare lo stato di avanzamento con {{{ bash-3.1# cat /proc/mdstat }}} oppure : {{{ bash-3.1# watch cat /proc/mdstat }}} ..zzz.. Una volta ultimato, l'output di cat /proc/mdstat dovrebbe essere qualcosa del genere: {{{ bash-3.1# cat /proc/mdstat Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] md1 : active raid1 sdb3[1] sda3[0] 214853184 blocks [2/2] [UU] md0 : active raid1 sdb1[1] sda1[0] 76180096 blocks [2/2] [UU] unused devices: }}} Formattiamo gli array con i filesystem che preferiamo ( io uso ext3 ): {{{ bash-3.1# mkfs.ext3 /dev/md0 bash-3.1# mkfs.ext3 /dev/md1 bash-3.1# mkswap /dev/sda2 bash-3.1# mkswap /dev/sdb2 bash-3.1# swapon /dev/sda2 bash-3.1# swapon /dev/sdb2 }}} A questo punto gli array raid sono attivi e si può procedere con l'installazione della Slackware. == Installazione Slack 12 su sata2 Raid == Lanciamo setup: {{{ bash-3.1# setup }}} e installiamo la nostra Slackware normalmente, facendo però attenzione ad inserire come come mount point per la root / /dev/md0 e come mount point per la /home /dev/md1. Procedete nell'installazione ed ignorate l'errore che vi viene proposto al momento dell'installazione di LILO. Lo correggeremo in un secondo memento. Finita l'installazione NON riavviate il pc, perchè non ripartirebbe senza cd o dvd. Procedete così: * montate la partizione /dev/sda1 su /mnt {{{ bash-3.1# mount /dev/sda1 /mnt bash-3.1# chroot /mnt bash-3.1# vi /etc/lilo.conf }}} * ed editate lilo.conf in tal modo: {{{ # LILO configuration file # generated by 'liloconfig' # # Start LILO global section lba32 # Allow booting past 1024th cylinder with a recent BIOS boot = /dev/sda message = /boot/boot_message.txt prompt timeout = 1200 vga = 791 # End LILO global section # Linux bootable partition config begins image = /boot/vmlinuz root = /dev/md0 label = Linux read-only # Linux bootable partition config ends }}} * e non dimenticate di lanciare lilo: {{{ bash-3.1# lilo -t }}} * e se è tutto ok: {{{ bash-3.1# lilo -v }}} * usciamo dal chroot e smontiamo la partizione /dev/sda1: {{{ bash-3.1# exit bash-3.1# umount /mnt }}} Quello che andremo a fare secondo me è assolutamente inutile, ma non ho avuto modo di provarlo. In pratica replichiamo le modifiche fatte a lilo.conf di /dev/sda1 su /dev/sdb1. Procediamo quindi in modo identico a quanto fatto per /dev/sda1 {{{ bash-3.1# mount /dev/sdb1 /mnt bash-3.1# chroot /mnt bash-3.1# vi /etc/lilo.conf # LILO configuration file # generated by 'liloconfig' # # Start LILO global section lba32 # Allow booting past 1024th cylinder with a recent BIOS boot = /dev/sda message = /boot/boot_message.txt prompt timeout = 1200 vga = 791 # End LILO global section # Linux bootable partition config begins image = /boot/vmlinuz root = /dev/md0 label = Linux read-only # Linux bootable partition config ends bash-3.1# lilo -t bash-3.1# lilo -v bash-3.1# exit bash-3.1# umount /mnt }}} Finalmente ... abbiamo finito! Togliete il cd o dvd e riavviate...e magari, anche se siete atei, fate una preghierina... ( con la divulgazione di Linux si è riscontrato un aumento dei credenti...chissà xchè). == Da lilo a grub == Questo paragrafo è dedicato a tutti quelli che, come me, hanno la necessità di usare come boot loader grub al posto di lilo (per esempio se usate xen!). Bene. Grub ha il brutto vizio di identificare gli hd con hd[abcde...]. Ma cosa fare se abbiamo degli hd sata che vengono identificati con sd[abcd....]? Vediamo cosa si può fare. Apriamo la nostra buona shell e iniziamo. Prima di tutto è necessario procurasi e installare grub. Scaricatelo con il vostro tool preferito (slapt-get o swaret o slackpkg) e installatelo. {{{ bash-3.1# slapt-get --search grub bash-3.1# slapt-get --install grub-0.97-i486-3 }}} Copiamo gli stage di grub nella directory di boot: {{{ bash-3.1# cp /usr/lib/grub/i386-pc /boot/grub }}} Ora procediamo con l'installazione di grub sul MBR del primo hd dell'array (/dev/sda) {{{ bash-3.1# mount /dev/sda1 /mnt/tmp bash-3.1# chroot /mnt/tmp bash-3.1# grub Probing devices to guess BIOS drives. This may take a long time. GNU GRUB version 0.97 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> device (hd0) /dev/sda grub> root (hd0,0) grub> setup (hd0) grub> device (hd1) /dev/sdb grub> root (hd1,0) grub> setup (hd1) grub> quit }}} Usciamo dal chroot: {{{ bash-3.1# exit }}} Ripetiamo le stesse operazioni per /dev/sdb : {{{ bash-3.1# mount /dev/sdb1 /mnt/tmp bash-3.1# chroot /mnt/tmp bash-3.1# grub Probing devices to guess BIOS drives. This may take a long time. GNU GRUB version 0.97 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> device (hd0) /dev/sda grub> root (hd0,0) grub> setup (hd0) grub> device (hd1) /dev/sdb grub> root (hd1,0) grub> setup (hd1) grub> quit }}} Usciamo dal chroot: {{{ bash-3.1# exit }}} Ora creiamo ed editiamo il file menu.lst {{{ bash-3.1# vi /boot/grub/menu.lst # GRUB configuration file '/boot/grub/menu.lst'. # generated by 'grubconfig'. Fri Oct 19 16:33:43 2007 # # The backup copy of the MBR for drive '/dev/hda' is # here '/boot/grub/mbr.hda.28315'. You can restore it like this. # dd if=mbr.hda.28315 of=/dev/hda bs=512 count=1 # # Start GRUB global section default 0 timeout 10 color light-gray/blue black/light-gray device (hd0) /dev/sda device (hd1) /dev/sdb # End GRUB global section # Linux bootable partition config begins # title LinuxBK on (/dev/hdb2) # root (hd1,1) # kernel (hdb1,1)/boot/vmlinuzBK root=/dev/hdb2 ro vga=791 # boot # savedefault title Linux on (/dev/sda) root (hd0,0) kernel (hd0,0)/boot/vmlinuz root=/dev/md0 ro vga=791 max_loop=32 boot savedefault fallback title Linux on (/dev/sdb) root (hd1,0) kernel (hd1,0)/boot/vmlinuz root=/dev/md0 ro vga=791 max_loop=32 boot savedefault fallback # Linux bootable partition config ends title --- For help press 'c', type: 'help' title --- For help press 'c', type: 'help' root (hd0) title --- For usage examples, type: 'cat /boot/grub/grub.txt' root (hd0) }}} Riavviate e abbiate fede... Pedro