Migration vers un raid1 logiciel
Recemment je me suis un peu penché sur le raid logiciel sous debian: mdadm.
J'ai été fortement seduit par cette solution (je detaillerai pourquoi dans un prochain billet) et j'ai donc voulu passer ma gate@home en raid1 logiciel.
Je vais donc detailler ici comment migrer son systeme vers un raid1 logiciel avec mdadm.
Un petit etait des lieux avant tout, voici ma configuration actuelle:
debian:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 2.8G 494M 2.2G 19% /
tmpfs 126M 0 126M 0% /lib/init/rw
udev 10M 52K 10M 1% /dev
tmpfs 126M 0 126M 0% /dev/shm
debian:~#
On vient bien ici que je n'ai qu'une partition principale / de 2.8Go. /dev/sda est donc mon disque dur actuel, avec une partition /dev/sda1.
Par chance je retrouve un disque dur de taille identique ce qui sera plus cool pour faire mes partitions et mon raid logiciel.
Considerons donc /dev/sda mon disque dur actuel et /dev/sdb mon nouveau disque dur.
/dev/sdb vient juste d'etre ajouté dans la machine:
debian:~# fdisk -l /dev/sdb
Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDisk /dev/sdb doesn't contain a valid partition table
debian:~#
Commencons par installer mdadm:
- # apt-get install mdadm
Il faut a present modifier le type des partitions sur /dev/sda en effet nous avons actuellement:
debian:~# fdisk -l /dev/sda
Disk /dev/sda: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sda1 * 1 367 2947896 83 Linux
/dev/sda2 368 391 192780 5 Extended
/dev/sda5 368 391 192748+ 82 Linux swap / Solaris
debian:~#
Utilisez fdisk ou cfdisk pour obtenir:
debian:~# fdisk -l /dev/sda
Disk /dev/sda: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sda1 * 1 367 2947896 fd Linux raid autodetect
/dev/sda2 368 391 192780 5 Extended
/dev/sda5 368 391 192748+ 82 Linux swap / Solaris
debian:~#
Une fois cela fait, nous allons dupliquer les partitions de /dev/sda sur /dev/sdb:
- # sfdisk -d /dev/sda | sfdisk /dev/sdb
Vous devriez obtenir un affichage du style de celui ci:
......
Successfully wrote the new partition table
Re-reading the partition table ...
.......
A present il va falloir utiliser mdadm pour creer le raid en indiquant /dev/sda comme manquant:
debian:~# mdadm --create /dev/md0 --level 1 --raid-devices=2 missing /dev/sdb1
mdadm: array /dev/md0 started.
debian:~#
Repetez cette operation pour chacune de vos partitions (dans mon cas je n'avais que /dev/sda1 au tout debut)
Creez le filesystem pour le raid:
- # mkfs.ext3 /dev/md0
A present montons le volume /Dev/md0 et copions son contenu:
- # mount /dev/md0 /mnt
- # cp -dpRx / /mnt
Faites ainsi pour chacun de vos partitions par exemple pour /var:
- # mount /dev/md1 /mnt/var
- # cp -dpRx / /mnt/var
Dans le cas de ce tutorial nous ne le ferons car nous avons tout dans une seule partitions.
Formatons la partition swap sur le nouveau disque dur sdb:
- # mkswap -v1 /dev/sdb5
Puis modifiez le fichier /mnt/etc.fstab pour qu'il ressemble a:
debian:~# cat /mnt/etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/md0 / ext3 defaults,errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/sdb5 none swap sw 0 0
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
debian:~#
On notera le remplacement de /dev/sda1 par /dev/md0 et l'activation des deux partitions swap sda5 et sdb5
Editez egalement le fichier /mnt/boot/grub/menu.lst , voici a quoi ressemble dorenavant le mien:
.....
title Debian GNU/Linux, kernel 2.6.18-5-686
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-5-686 root=/dev/md0 md=0,/dev/sda1,/dev/sdb1 ro
initrd /boot/initrd.img-2.6.18-5-686
savedefaulttitle Debian GNU/Linux, kernel 2.6.18-5-686 (single-user mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-5-686 root=/dev/md0 md=0,/dev/sda1,/dev/sdb1 ro sin gle
initrd /boot/initrd.img-2.6.18-5-686
savedefault.....
Passons a grub:
grub-install /dev/sda
grub
grub: device (hd0) /dev/sdb
grub: root (hd0,0)
grub: setup (hd0)
grub: quit
Copions tout cela sur /dev/sda
debian:~# cp -dp /mnt/etc/fstab /etc/fstab
debian:~# cp -dp /mnt/boot/grub/menu.lst /boot/grub
Et on reboot!
Lors du reboot voici ce que l'on voit passer:
md: raid6 personality registered for level 6
md: raid5 personality registered for level 5
md: raid4 personality registered for level 4
md: raid10 personality registered for level 10
md: bind<sdb1>
raid1: raid set md0 active with 1 out of 2 mirrors
Attempting manual resume
Il nous faut donc ajouter /dev/sda1 a /dev/md0 :
debian:~# mdadm --add /dev/md0 /dev/sda1
mdadm: added /dev/sda1
debian:~#
Vous devriez voir cela dans votre dmesg au bout d'un ptit moment:
md: bind<sda1>
RAID1 conf printout:
--- wd:1 rd:2
disk 0, wo:1, o:1, dev:sda1
disk 1, wo:0, o:1, dev:sdb1
md: syncing RAID array md0
md: minimum _guaranteed_ reconstruction speed: 1000 KB/sec/disc.
md: using maximum available idle IO bandwidth (but not more than 200000 KB/sec) for reconstruction.
md: using 128k window, over a total of 2947776 blocks.
md: md0: sync done.
RAID1 conf printout:
--- wd:2 rd:2
disk 0, wo:0, o:1, dev:sda1
disk 1, wo:0, o:1, dev:sdb1
On pretera attention : "md: md0: sync done."
Et hop on reboot encore :p
Ceete fois ci on a:
raid1: raid set md0 active with 2 out of 2 mirrors
Mais on voit un petit message rouge pas tres gracieux:
Assembling MD Arrays ... failed (no arrays found in config file or automatically)
Pour regler cela j'ai rajoute dans /etc/mdadm/mdadm.conf:
DEVICE /dev/sda*
DEVICE /dev/sdb*
ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1
Et voila tout tourne bien :)
December 29th, 2010 - 11:17
It is unusual for me to find something on the net that’s as entertaining and fascinating as what you have got here. Your page is sweet, your graphics are great, and what’s more, you use source that are relevant to what you are saying. You’re definitely one in a million, well done!
December 31st, 2010 - 00:27
The Zune concentrates on being a Portable Media Player. Not a web browser. Not a game machine. Maybe in the future it’ll do even better in those areas, but for now it’s a fantastic way to organize and listen to your music and videos, and is without peer in that regard. The iPod’s strengths are its web browsing and apps. If those sound more compelling, perhaps it is your best choice.
January 3rd, 2011 - 05:16
The Zune concentrates on being a Portable Media Player. Not a web browser. Not a game machine. Maybe in the future it’ll do even better in those areas, but for now it’s a fantastic way to organize and listen to your music and videos, and is without peer in that regard. The iPod’s strengths are its web browsing and apps. If those sound more compelling, perhaps it is your best choice.
January 3rd, 2011 - 20:07
Zune and iPod: Most people compare the Zune to the Touch, but after seeing how slim and surprisingly small and light it is, I consider it to be a rather unique hybrid that combines qualities of both the Touch and the Nano. It’s very colorful and lovely OLED screen is slightly smaller than the touch screen, but the player itself feels quite a bit smaller and lighter. It weighs about 2/3 as much, and is noticeably smaller in width and height, while being just a hair thicker.
January 6th, 2011 - 03:31
If you’re still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you’ll know which is right for you.
January 6th, 2011 - 10:52
Apple now has Rhapsody as an app, which is a great start, but it is currently hampered by the inability to store locally on your iPod, and has a dismal 64kbps bit rate. If this changes, then it will somewhat negate this advantage for the Zune, but the 10 songs per month will still be a big plus in Zune Pass’ favor.
January 6th, 2011 - 14:15
Between me and my husband we’ve owned more MP3 players over the years than I can count, including Sansas, iRivers, iPods (classic & touch), the Ibiza Rhapsody, etc. But, the last few years I’ve settled down to one line of players. Why? Because I was happy to discover how well-designed and fun to use the underappreciated (and widely mocked) Zunes are.
January 8th, 2011 - 14:52
Sorry for the huge review, but I’m really loving the new Zune, and hope this, as well as the excellent reviews some other people have written, will help you decide if it’s the right choice for you.
January 9th, 2011 - 04:29
I can observe a huge improvement within your Posts, I’ll love to make contact. Keep up the excellent work! Your Posts are pretty inspirational for someone who may be new to such a stuff.
January 9th, 2011 - 04:57
I’ll gear this review to 2 types of people: current Zune owners who are considering an upgrade, and people trying to decide between a Zune and an iPod. (There are other players worth considering out there, like the Sony Walkman X, but I hope this gives you enough info to make an informed decision of the Zune vs players other than the iPod line as well.)
January 9th, 2011 - 16:01
This is getting a bit more subjective, but I much prefer the Zune Marketplace. The interface is colorful, has more flair, and some cool features like ‘Mixview’ that let you quickly see related albums, songs, or other users related to what you’re listening to. Clicking on one of those will center on that item, and another set of “neighbors” will come into view, allowing you to navigate around exploring by similar artists, songs, or users. Speaking of users, the Zune “Social” is also great fun, letting you find others with shared tastes and becoming friends with them. You then can listen to a playlist created based on an amalgamation of what all your friends are listening to, which is also enjoyable. Those concerned with privacy will be relieved to know you can prevent the public from seeing your personal listening habits if you so choose.
January 10th, 2011 - 09:33
The new Zune browser is surprisingly good, but not as good as the iPod’s. It works well, but isn’t as fast as Safari, and has a clunkier interface. If you occasionally plan on using the web browser that’s not an issue, but if you’re planning to browse the web alot from your PMP then the iPod’s larger screen and better browser may be important.
January 10th, 2011 - 12:41
The catchy blog with the fascinating contents. You give the nice info .that many people dont know before. most of your contents are make me have far more knowledge. it is very different. I was impressed with your blog. Never be bored to visit your blog again. Have the nice day.Keep enjoyed your blogging.
January 10th, 2011 - 20:38
Hands down, Apple’s app store wins by a mile. It’s a huge selection of all sorts of apps vs a rather sad selection of a handful for Zune. Microsoft has plans, especially in the realm of games, but I’m not sure I’d want to bet on the future if this aspect is important to you. The iPod is a much better choice in that case.