Konverze disku na RAID
Z KHnetWiki
(Rozdíly mezi verzemi)
Verze z 20. 3. 2007, 16:29
ROZPRACOVÁNO
Power HowTo:
This covers installing a second drive after a system is already up and running single drive.
Make sure you backup all your data... you have been pre warned.
- Primary Disc, lets get its info and record it. I used cfdisk.
- NOTE: Do not change anything.. just TAB to QUIT.
- cfdisk /dev/<yourolddevice>
disc1 Boot, NC Primary Linux ext2 41.13 disc2 Primary Linux swap / Solaris 271.44 disc3 Primary Linux ext3 82030.72
- Secondary Disc, Setup using cfdisk.
- cfdisk /dev/<yournewdevice>
disc1 Boot Primary Linux raid autodetect 41.13 disc2 Primary Linux raid autodetect 271.44 disc3 Primary Linux raid autodetect 82030.72 Hint --> Linux raid autodetect is type: FD
- create md device nodes
mknod /dev/md0 b 9 0 mknod /dev/md1 b 9 1 mknod /dev/md2 b 9 2 mknod /dev/md3 b 9 3 ...
- create raid devices
[root@svn ~]# mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/<yournewdevice-partitionA> mdadm: array /dev/md0 started. [root@svn ~]# mdadm --create /dev/md1 --level 1 --raid-devices=2 missing /dev/<yournewdevice-partitionB> mdadm: array /dev/md1 started. [root@svn ~]# mdadm --create /dev/md2 --level 1 --raid-devices=2 missing /dev/<yournewdevice-partitionC> mdadm: array /dev/md2 started. ... You may be asked: 'Continue creating array? y' if the disk was already formated. [root@svn ~]#
- Check /proc/mdstat
- All devices are in tact however they are degraded..
[root@svn ~]# cat /proc/mdstat Personalities : [linear] [raid0] [raid1] [raid5] [multipath] [raid6] [raid10] md2 : active raid1 sdb3[1] 80108032 blocks [2/1] [_U] md1 : active raid1 sdb2[1] 264960 blocks [2/1] [_U] md0 : active raid1 sdb1[1] 40064 blocks [2/1] [_U] unused devices: <none> [root@svn ~]#
- create filesystems
- use the filesystem tools you need to create your filesystem
- NOTE: our /boot is ext2, / is ext3.
[root@svn ~]# mke2fs -j /dev/md0 mke2fs 1.38 (30-Jun-2005) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 10040 inodes, 40064 blocks 2003 blocks (5.00%) reserved for the super user First data block=1 5 block groups 8192 blocks per group, 8192 fragments per group 2008 inodes per group Superblock backups stored on blocks: 8193, 24577 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. * mkswap [root@svn ~]# mkswap /dev/md1 Setting up swapspace version 1, size = 271314 kB no label, UUID=9d746813-2d6b-4706-a56a-ecfd108f3fe9 * mkfs.ext3 for / [root@svn ~]# mkfs.ext3 -j /dev/md2 mke2fs 1.38 (30-Jun-2005) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 10027008 inodes, 20027008 blocks 1001350 blocks (5.00%) reserved for the super user First data block=0 612 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 25 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@svn ~]#
- Mount and Copy Data.
# mount new raid / [root@svn ~]# mount /dev/md<where you assigned-/-number> /mnt/ # mount new raid /boot [root@svn ~]# mkdir /mnt/boot [root@svn ~]# mount /dev/md<where you assigned-/boot-number> /mnt/boot/ # add dirs and mount all other partitions You need to do this for every partition you had on old disk, to create the new raid device exactly the same. ... # copy / to new /raid/ [root@svn ~]# cd /mnt [root@svn mnt]# tar -C / -clspf - . | tar -xlspvf - # copy /boot to new /raid/boot cd /mnt/boot [root@svn boot]# tar -C /boot -clspf - . | tar -xlspvf - # copy other partitions You need to do this for every partition you had on old disk, to create the new raid device exactly the same. ...
- NOTE: CRUCIAL STEP
- edit /mnt/boot/grub/menu.lst
- Note: Make it look like so:
- add "fallback 1" to menu.lst
----- snip ----- default 0 color light-blue/black light-cyan/blue ## fallback disc1 fallback 1 # (0) Arch Linux title Arch Linux [Disc0: /boot/vmlinuz26] root (hd0,0) #kernel /vmlinuz26 root=/dev/discs/disc0/part3 ro kernel /vmlinuz26 root=/dev/md<where you assigned-/-number> md=<all your md devices, please refer mkinitcpio howto for correct syntax, but don't add the old disk partitions at this point> ro # (1) Arch Linux title Arch Linux [Disc1: /boot/vmlinuz26] root (hd1,0) #kernel /vmlinuz26 root=/dev/discs/disc1/part3 ro kernel /vmlinuz26 root=/dev/md<where you assigned-/-number> md=<all your md devices, please refer mkinitcpio howto for correct syntax, but don't add the old disk partitions at this point> ro ----- snip -----
- setup: vi /mnt/etc/fstab for NEW md devices.
- I just commented my old ones out..
#/dev/discs/disc0/part3 / ext3 defaults 0 1 /dev/md2 / ext3 defaults 0 1 #/dev/discs/disc0/part1 /boot ext2 defaults 0 1 /dev/md0 /boot ext2 defaults 0 1 #/dev/discs/disc0/part2 swap swap defaults 0 0 /dev/md1 swap swap defaults 0 0
- mount /proc and /sys to new raid
mount --bind /sys /mnt/sys mound --bind /proc /mnt/proc
- chroot into new raid system and rebuild initrd
chroot /mnt # edit /etc/mkinitcpio.conf to include 'raid' in HOOKS and place it before 'autodetect' mkinitcpio -g /boot/kernel26.img pacman -Rd udev pacman -S udev exit
- Install grub on new raid disk, change the numbers according to your setup.
[root@svn /]#grub grub> root (hd1,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd1) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 16 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd1) (hd1)1+16 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded Done grub>quit [root@svn /]#
- reboot into new raid disk and not! into old disk, you may need to change bios settings.
/sbin/reboot
- cross fingers ;)
- If system booted fine, add the missing md devices to RAID.
[root@svn ~]# mdadm /dev/md0 -a /dev/<old-disk-partitionA> mdadm: hot added /dev/<old-disk-partitionA> [root@svn ~]# mdadm /dev/md1 -a /dev/<old-disk-partitionB> mdadm: hot added /dev/<old-disk-partitionB> [root@svn ~]# mdadm /dev/md2 -a /dev/<old-disk-partitionC> mdadm: hot added /dev/<old-disk-partitionC> ... [root@svn ~]
- Check mdstat
- Verify that your RAID is being built.
[root@svn ~]# cat /proc/mdstat Personalities : [linear] [raid0] [raid1] [raid5] [multipath] [raid6] [raid10] md1 : active raid1 sda2[0] sdb2[1] 264960 blocks [2/2] [UU] md2 : active raid1 sda3[2] sdb3[1] 80108032 blocks [2/1] [_U] [>....................] recovery = 1.2% (1002176/80108032) finish=42.0min speed=31318K/sec md0 : active raid1 sda1[0] sdb1[1] 40064 blocks [2/2] [UU] unused devices: <none> [root@svn ~]#
- finish grub config
----- snip ----- # (0) Arch Linux title Arch Linux [Disc0: /boot/vmlinuz26] root (hd0,0) #kernel /vmlinuz26 root=/dev/discs/disc0/part3 ro kernel /vmlinuz26 root=/dev/md<where you assigned-/-number> md=<all your md devices, please refer mkinitcpio howto for correct syntax, add the old disk partitions at this point> ro # (1) Arch Linux title Arch Linux [Disc1: /boot/vmlinuz26] root (hd1,0) #kernel /vmlinuz26 root=/dev/discs/disc1/part3 ro kernel /vmlinuz26 root=/dev/md<where you assigned-/-number> md=<all your md devices, please refer mkinitcpio howto for correct syntax, add the old disk partitions at this point> ro ----- snip -----
- finish initrd
edit /etc/mkinitcpio.conf you can now place 'raid' hook behind autodetect and rebuild initrd mkinitpcio -g /boot/kernel26.img
- Change your bios to normal boot order again.
- You are done, enjoy your new RAID setup :)