Results 1 to 2 of 2
If you want a full run down as to WHY I want to do this, read here: webhostingtalk.com/showthread.php?t=899909
Basically, my ISP could not get my server running stable on a ...
- 10-27-2009 #1Just Joined!
- Join Date
- May 2007
- Posts
- 2
Moving install from single disk to RAID 1
If you want a full run down as to WHY I want to do this, read here: webhostingtalk.com/showthread.php?t=899909
Basically, my ISP could not get my server running stable on a simple raid 1 (or raid 5) so what it came down to was having them install my system on a single disk. I don't exactly like this, main reason being, if the system (or HDD) crashes, I'll end up with another several hours of down time... So here is my proposal:
Please Note: This will have to be accomplished on a live System (full backups!) over ssh as I don't trust my ISP to do things right as described in my post above.
Current Setup:
CentOS 5.3 x86_64
Dual Xeon 5410
16GB RAM
4x 750GB HDDs
/boot - /dev/sda1 - 512MB (real 471MB) ext3
/ - /dev/sda2 - 50GB (real 46GB) ext3
/home - /dev/sda3 - remaining space (real 642GB) ext3
swap - /dev/sdb1 - 32GB
/backup - /dev/sdb2 - remaining space (real 659GB) ext3
/dev/md0 - /dev/sdc + /dev/sdd - raid 1 (NOTE: uses entire disk, no partitions!)
Proposed Solution:
Now, I'd like to 'init 1' at this stage but I can't, so I won't (possible solutions?? Possible to umount the / partition??)Code:vgcreate -s 64M vg0 /dev/md0 lvcreate -L 512M -n lvboot vg0 lvcreate -L 50G -n lvroot vg0 lvcreate -L 5G -n lvtmp vg0 lvcreate --extent 100%FREE -n lvhome vg0 mkfs -t ext3 -m 1 /dev/vg0/lvboot mkfs -t ext3 -m 1 /dev/vg0/lvroot mkfs -t ext3 -m 1 /dev/vg0/lvtmp mkfs -t ext3 -m 1 /dev/vg0/lvhome
Assuming I'd have to do this on a fully live system, I'd disable all services that I can
Then we copy all of our data from the single partitions to the raid disksCode:/etc/init.d/sendmail stop /etc/init.d/postfix stop /etc/init.d/saslauthd stop /etc/init.d/httpd stop /etc/init.d/mysql stop /etc/init.d/courier-authlib stop /etc/init.d/courier-imap stop /etc/init.d/amavisd stop /etc/init.d/clamd stop /etc/init.d/pure-ftpd stop /etc/init.d/fail2ban stop /etc/init.d/syslogd stop
(I think I covered everything)Code:mkdir /mnt/newroot mkdir /mnt/newroot/boot mkdir /mnt/newroot/tmp mkdir /mnt/newroot/home mount /dev/vg0/lvboot /mnt/newroot/boot mount /dev/vg0/lvroot /mnt/newroot/root mount /dev/vg0/lvtmp /mnt/newroot/tmp mount /dev/vg0/lvhome /mnt/newroot/home
Once we have everything copied, update /etc/fstab and /etc/mtab to reflect the changes we made:Code:umount -l /dev/sda1 (/boot) umount -l /dev/sda3 (/home) cp -dpRx /* /mnt/newroot/ mount /dev/sda1 /boot cp -dpRx /boot/* /mnt/newroot/boot/ mount /dev/sda3 /home cp -dpRx /home/* /mnt/newroot/home/
vi /etc/fstab
ToCode:LABEL=/home /home ext3 defaults 0 3 LABEL=/ / ext3 defaults,usrquota,grpquota 1 1 LABEL=/boot /boot ext3 defaults 1 2 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 LABEL=SWAP-sdb1 swap swap defaults 0 0
findCode:/dev/vg0/lvhome /home ext3 defaults 0 3 /dev/vg0/lvroot / ext3 defaults,usrquota,grpquota 1 1 /dev/vg0/lvboot /boot ext3 defaults 1 2 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 LABEL=SWAP-sdb1 swap swap defaults 0 0 Moving on, we make a fail safe in the event this doesn't work out: vi /boot/grub/menu.lst
add afterCode:default=0
Then we find (in the same file):Code:fallback=1
Add before:Code:title CentOS (2.6.18-164.el5) root (hd1,0) kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/vg0/vgroot initrd /initrd-2.6.18-164.el5.img
Where (hd3,0) is /dev/sdc. If the system fails to boot to the raid then it'll auto boot to the single disk (/dev/sda)Code:title CentOS (2.6.18-164.el5) root (hd3,0) kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/sda2 initrd /initrd-2.6.18-164.el5.img
then update my ramdisk:
Code:mv /boot/initrd-`uname -r`.img /boot/initrd-`uname -r`.img_bak mkinitrd /boot/initrd-`uname -r`.img `uname -r`
And now to set up grub...
we should see something like this:Code:grub > root (hd0,0) > setup (hd0)
ThenCode:Checking if "/boot/grub/stage1" exists... no Checking if "/grub/stage1" exists... yes Checking if "/grub/stage2" exists... yes Checking if "/grub/e2fs_stage1_5" exists... yes Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded. succeeded Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded Done.
Again, we should see something like this:Code:> root (hd3,0) > setup (hd3)
Code:Checking if "/boot/grub/stage1" exists... no Checking if "/grub/stage1" exists... yes Checking if "/grub/stage2" exists... yes Checking if "/grub/e2fs_stage1_5" exists... yes Running "embed /grub/e2fs_stage1_5 (hd1)"... 15 sectors are embedded. succeeded Running "install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2 /grub/grub.conf"... succeeded Done.
From here I think we're ready to reboot, can't see where I missed anything. If all goes well then I should see my volume groups listed in 'df- h'Code:> quit
Now, the big question is... have I missed anything?
Any and all input is greatly appreciated.
- 10-28-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Personally, I don't like to use RAID for the system disc(s). I make regular bit image backups to an external drive which I can use to swap out the system disc in a couple of minutes (seconds because I have a removable system drive enclosure). Total down time for my RHEL/CentOS 5.4 system including boot time is 5-10 minutes at most. That said, in 2 years I've had 0 system drive failures. I use NAS RAID devices for my long-term archival storage, but not for daily runtime purposes.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote