Instalasi ini dilakukan untuk menambah harddisk pada server yang sudah running, yang sebelumnya hanya memiliki harddisk satu. Kapasitas harddisk kedua sama dengan harddisk pertama. Untuk ini saya memakai RAID (Redundant Array of Independent Disks) , Raid1 saya gunakan karena menggunakan 2 harddisk dan dapat saling menggantikan jika salah satu harddisk rusak.
Berikut instalasi dan konfigurasi Raid 1 pada sistem operasi Linux Debian Lenny.
svr32-backup-id:/home/gtoms# uname -a
Linux svr32-backup-id 2.6.26-2-686 #1 SMP Thu Jan 27 00:28:05 UTC 2011 i686 GNU/Linux
svr32-backup-id:/home/gtoms# cat /etc/debian_version
5.0.8
svr32-backup-id:/home/gtoms# fdisk -l
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0007b638
Device Boot Start End Blocks Id System
/dev/sda1 * 1 121271 974109276 83 Linux
/dev/sda2 121272 121601 2650725 5 Extended
/dev/sda5 121272 121601 2650693+ 82 Linux swap / Solaris
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn’t contain a valid partition table
svr32-backup-id:/home/gtoms#
/dev/sdb adalah harddisk kedua yang sudah saya pasang di server. Kapasitas harddisk pertama dan kedua sama yaitu 1 Terabyte.
Software raid menggunakan mdadm :
svr32-backup-id:/home/gtoms# apt-get install mdadm
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
mdadm
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 275kB of archives.
After this operation, 799kB of additional disk space will be used.
Get:1 http://ftp.us.debian.org lenny/main mdadm 2.6.7.2-3 [275kB]
Fetched 275kB in 3s (76.3kB/s)
Preconfiguring packages …
Selecting previously deselected package mdadm.
(Reading database … 19456 files and directories currently installed.)
Unpacking mdadm (from …/mdadm_2.6.7.2-3_i386.deb) …
Processing triggers for man-db …
Setting up mdadm (2.6.7.2-3) …
Generating array device nodes… done.
Generating mdadm.conf… done.
update-initramfs: deferring update (trigger activated)
Starting MD monitoring service: mdadm –monitor.
Assembling MD arrays…done (no arrays found in config file or automatically).
Processing triggers for initramfs-tools …
update-initramfs: Generating /boot/initrd.img-2.6.26-2-686
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
W: mdadm: no arrays defined in configuration file.
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# apt-get install rsync
svr32-backup-id:/home/gtoms# echo raid1 >> /etc/modules
svr32-backup-id:/home/gtoms# modprobe raid1
svr32-backup-id:/home/gtoms# lsmod | grep raid1
raid1 18016 0
md_mod 67100 1 raid1
svr32-backup-id:/home/gtoms# cat /proc/mdstat
Personalities : [raid1]
unused devices: <none>
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now …
OK
Disk /dev/sdb: 121601 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 * 63 1948218614 1948218552 83 Linux
/dev/sdb2 1948218615 1953520064 5301450 5 Extended
/dev/sdb3 0 – 0 0 Empty
/dev/sdb4 0 – 0 0 Empty
/dev/sdb5 1948218678 1953520064 5301387 82 Linux swap / Solaris
Successfully wrote the new partition table
Re-reading the partition table …
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# for partition in 1; do sfdisk –change-id /dev/sdb $partition fd; done
Done
svr32-backup-id:/home/gtoms# for partition in 1; do mdadm –create /dev/md$partition –level=1 \
> –raid-disks=2 missing /dev/sdb$partition; done
mdadm: array /dev/md1 started.
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# for partition in 1; do mkfs.ext3 /dev/md$partition; done
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
60882944 inodes, 243527296 blocks
12176364 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
7432 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
svr32-backup-id:/home/gtoms# mdadm –detail –scan >> /etc/mdadm/mdadm.conf
svr32-backup-id:/home/gtoms# nano /etc/fstab
OLD
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext3 errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/hda /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
NEW
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/md1 / ext3 errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/hda /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
svr32-backup-id:/home/gtoms# sed ‘s/sda1/md1/’ < /boot/grub/menu.lst_orig > /boot/grub/menu.lst
svr32-backup-id:/home/gtoms# grep md1 /boot/grub/menu.lst
# kopt=root=/dev/md1 ro
kernel /boot/vmlinuz-2.6.26-2-686 root=/dev/md1 ro quiet
kernel /boot/vmlinuz-2.6.26-2-686 root=/dev/md1 ro single
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# update-grub
Searching for GRUB installation directory … found: /boot/grub
Searching for default file … found: /boot/grub/default
Testing for an existing GRUB menu.lst file … found: /boot/grub/menu.lst
Searching for splash image … none found, skipping …
Found kernel: /boot/vmlinuz-2.6.26-2-686
Updating /boot/grub/menu.lst … done
svr32-backup-id:/home/gtoms# init 1
svr32-backup-id:/home/gtoms# mount /dev/md1 /media; rsync -aqxP / /media; umount /media
svr32-backup-id:/home/gtoms# grub
device (hd0) /dev/sdb
root (hd0,0)
setup (hd0)
quit
svr32-backup-id:/home/gtoms# reboot
svr32-backup-id:/home/gtoms# mount
/dev/md1 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
svr32-backup-id:/home/gtoms# for partition in 1; do sfdisk –change-id /dev/sda $partition fd; done
Done
svr32-backup-id:/home/gtoms# for partition in 1; do mdadm –add /dev/md$partition /dev/sda$partition; done
mdadm: metadata format 00.90 unknown, ignored.
mdadm: added /dev/sda1
svr32-backup-id:/home/gtoms# watch cat /proc/mdstat
Every 2.0s: cat /proc/mdstat Tue Jun 7 09:17:37 2011
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda1[2] sdb1[1]
974109184 blocks [2/1] [_U]
[>………………..] recovery = 0.2% (2188672/974109184) finish=207.2min speed=78166K/sec
unused devices: <none>
svr32-backup-id:/home/gtoms# cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig1
svr32-backup-id:/home/gtoms# cp /etc/mdadm/mdadm.conf_orig /etc/mdadm/mdadm.conf
svr32-backup-id:/home/gtoms# mdadm –detail –scan >> /etc/mdadm/mdadm.conf
svr32-backup-id:/home/gtoms# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda1[2] sdb1[1]
974109184 blocks [2/1] [_U]
[>………………..] recovery = 1.1% (11431104/974109184) finish=194.2min speed=82579K/sec
unused devices: <none>
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda1[2] sdb1[1]
974109184 blocks [2/1] [_U]
[==>………………] recovery = 11.5% (112625344/974109184) finish=171.9min speed=83490K/sec
unused devices: <none>
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda1[2] sdb1[1]
974109184 blocks [2/1] [_U]
[====>…………….] recovery = 22.5% (219963584/974109184) finish=135.4min speed=92823K/sec
unused devices: <none>
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda1[2] sdb1[1]
974109184 blocks [2/1] [_U]
[================>….] recovery = 81.2% (791885824/974109184) finish=43.4min speed=69878K/sec
unused devices: <none>
svr32-backup-id:/home/gtoms#
Sampai disini sudah selesai, dan biarin saja sampai 100%
TOP
Tasks: 59 total, 2 running, 57 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 2.0%sy, 0.0%ni, 95.5%id, 0.0%wa, 0.5%hi, 2.0%si, 0.0%st
Mem: 1034944k total, 47700k used, 987244k free, 4732k buffers
Swap: 2650684k total, 0k used, 2650684k free, 17096k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
918 root 15 -5 0 0 0 R 43 0.0 20:34.83 md1_raid1
2538 root 20 0 2392 1100 876 R 6 0.1 0:00.18 top
2439 root 15 -5 0 0 0 D 2 0.0 1:09.51 md1_resync
10 root 15 -5 0 0 0 S 1 0.0 0:01.08 events/1
1 root 20 0 2104 720 624 S 0 0.1 0:01.08 init
2 root 15 -5 0 0 0 S 0 0.0 0:00.00 kthreadd
3 root RT -5 0 0 0 S 0 0.0 0:00.00 migration/0
4 root 15 -5 0 0 0 S 0 0.0 0:00.00 ksoftirqd/0
5 root RT -5 0 0 0 S 0 0.0 0:00.00 watchdog/0
svr32-backup-id:/home/gtoms# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda1[0] sdb1[1]
974109184 blocks [2/2] [UU]
unused devices: <none>
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md1 915G 742M 868G 1% /
tmpfs 506M 0 506M 0% /lib/init/rw
udev 10M 636K 9.4M 7% /dev
tmpfs 506M 0 506M 0% /dev/shm
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/md1 / ext3 errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/hda /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
svr32-backup-id:/home/gtoms#
svr32-backup-id:/home/gtoms# lsmod |grep md
md_mod 67100 7 raid10,raid456,raid1,raid0,multipath,linear
svr32-backup-id:/home/gtoms#
Silahkan test dengan melepas harddisk pertama atau kedua dan testing boot satu persatu. Jika berhasil tutorial ini bermanfaat bagi anda, jika gagal silahkan di ulangin kembali sampai berhasil.
Selesai.
henry@gultom.or.id