แสดงบทความที่มีป้ายกำกับ harddisk แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ harddisk แสดงบทความทั้งหมด

วันพุธที่ 4 สิงหาคม พ.ศ. 2553

Gentoo migration to raid

At some point, high availability become more essential to your server. Raid1(mirror) can help server to be able to continue even the disk go wrong. This blog is intend to be a complete just-type-guide for system admin. I hope that you guy succeeded in this migration

Background my system is gentoo on sda. The new disk will be sdb. After finishing copying data to sdb. The another new disk will be replace as sda. sda and sdb will be raid1 mirroring each other.

#0 move running service to another system
- make sure that the system can be down for maintainance


#1 shutdown system
shutdown -h now

#2 install new hdd as sdb
some vendor disable port B (for sdb) please make sure that it is enable so it can be visible from linux.

#3 boot system with live cd
modprobe raid1

#4 format disk and create raid on sdb
available 500GB
-> sdb1 boot 1GB ext2
-> sdb5 root entire ext3
-> sdb6 swap 4GB swap
cfdisk /dev/sdb
cd /dev && MAKEDEV md
mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb1
mdadm --create /dev/md5 --level=1 --raid-devices=2 missing /dev/sdb5
mke2fs /dev/md1
mke2fs -j /dev/md5
mkswap /dev/sdb6
swapon /dev/sdb6


#5 copy data from sda to raid
mkdir /mnt/gentoo1
mount /dev/sda5 /mnt/gentoo1
mount /dev/md5 /mnt/gentoo
mount /dev/sda1 /mnt/gentoo1/boot
mkdir /mnt/gentoo/boot
mount /dev/md1 /mnt/gentoo/boot
cp -dpRx /mnt/gentoo1/* /mnt/gentoo/


#6 install boot loader to raid
mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile
export PS1=”(chroot) $PS1”
#Edit grub.conf change root=/dev/sdaxx to mdxx
nano /boot/grub/grub.conf
#install boot loader to the disk
grub –no-floppy
- device (hd0) /dev/sdb
- root (hd0,0)
- setup (hd0)

#7 edit fstab to mount disk on raid instead // or just copy from preedit @ /home/username/fstab
nano /etc/fstab

#8 shutdown & replace sda with new disk
exit
cd /
umount /mnt/gentoo/boot /mnt/gentoo/proc /mnt/gentoo/dev /mnt/gentoo
umount /mnt/gentoo1/boot /mnt/gentoo1
shutdown -h now
-replace new disk


#9 sync disk and install boot loader
-change bios priority to start boot from sdb
sfdisk -d /dev/sdb | sfdisk /dev/sda
mdadm --add /dev/md1 /dev/sda1
mdadm --add /dev/md5 /dev/sda5
#edit fstab add sda as swap
nano /etc/fstab
mkswap /dev/sda6
swapon /dev/sda6
grub –no-floppy
- device (hd0) /dev/sda
- root (hd0,0)
- setup (hd0)


#wait until sync finish
- reboot test
- restore bios boot priority
- restore sevice back to the server.

วันอังคารที่ 12 มกราคม พ.ศ. 2553

How to monitor harddisk with smartmontools

Now let's install the smartmontools package:

# emerge -av smartmontools

Finally, you have to check if your hard disk(s) support SMART:

# smartctl -i /dev/hda

For SATA drives:

# smartctl -i -d ata /dev/sda

Using smartctl

SMART Health Status

Let's check the SMART Health Status:

# smartctl -H /dev/hda

If you read PASSED it's ok, but if you read FAILED you have to backup your data now: the disk has already failed or it's predicted to fail within 24 hours!


To recover from bad block :

http://smartmontools.sourceforge.net/badblockhowto.html

smartmontool document:

http://sourceforge.net/apps/trac/smartmontools/wiki/TocDoc

วันจันทร์ที่ 4 มกราคม พ.ศ. 2553