Unix/Open Solaris

Root pool 미러링

ForceCore 2009. 2. 15. 15:13
Root pool을 mirroring하고 싶다면...
설치할 때 디스크 전체 사용을 하도록 하면 안 된다. 파티션 하나를 잡고, 0.1GB만 남긴 거대파티션을 생성하여 설치하도록 한다. 안 그러면, 미러링 이후 주화입마(부트 불능)에 빠지는 수가 있다.

이제 메인디쉬로!
http://dd-b.net/ddbcms/2009/01/opensolaris-zfs-root-pool-mirroring/
http://darkstar-solaris.blogspot.com/2008/09/zfs-root-mirror.html
이 두 글을 컨닝했다. 두번째 글이 더 좋다. 더 친절함.

$ pfexec /usr/sbin/format
을 해보면 디스크 목록이 나온다. Pool에 들어가 있는 디스크를 고르면 (format tool은 객관식으로 고르는 interface로 되어있다) pool에 들어가 있으니 zpool을 쓰라고 친절히 알려준다. 안 들어가있는 것의 device 명을 봐둔다.
pool에 들어가 있는 파티션은 이렇게 나올 것이다:
/dev/dsk/c3d0s0 is part of active ZFS pool rpool. Please see zpool(1M).

빈 디스크는 이렇게 나온다:
AVAILABLE DISK SELECTIONS:
       0. c3d0 <DEFAULT cyl 60764 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1f,1/ide@0/cmdk@0,0
       1. c4d1 <WDC WD50-  WD-WCASY334260-0001-465.76GB>
          /pci@0,0/pci-ide@1f,1/ide@1/cmdk@1,0
Specify disk (enter its number): 1
selecting c4d1
NO Alt slice
No defect list found
[disk formatted, no defect list found]

이렇게 명령을 내려 보았다:
fc@lol:~$ pfexec zpool attach -f rpool c3d0s0 c4d1
cannot label 'c4d1': EFI labeled devices are not supported on root pools.

포멧이 제대로 되어 있지 않아서 그렇다.
이렇게 포멧해주자:
$ pfexec format
> 적절한 디스크 선택
> fdisk
아무 파티션도 없는 상태로 만든 뒤,
create a partition
종류는 SOLARIS2
차지할 공간의 percentage를 입력하라고 하는데, 100으로 했다.
> 5. Exit (update disk config...)
format> quit (나온다.)

이제 디스크 구조를 복제해야 한다.

/dev/dsk/c3d0s0가 원본이 설치된 곳인데...
그러면 명령어는 이렇게 된다.

$ pfexec prtvtoc /dev/rdsk/c3d0s2 | fmthard -s - /dev/rdsk/c4d1s2

s2이다. s0가 아니고!
그런데, 위와 같이 pfexec로 하면 permission denied라고 뜨면서 안 통한다.

$ pfexec bash
로 # 프롬프트를 본 상태에서 명령어를 내려야 한다. 명령어에서 warning이 좀 뜬다. 디스크 용량이 full disk용량이 일치하지 않는다나 뭐라나. 불평을 하긴 하지만, format도구로, verify명령어를 통해 복제용 디스크를 보면, 원본 디스크의 구조가 복제되어 있음을 볼 수 있다.

$ pfexec zpool attach -f rpool c3d0s0 c4d1s0

이렇게 두개를 attach시킨다. attach하면 default는 mirror인 모양이다.

$ zpool status

로 제대로 되었는지 확인을 해보자.
  pool: rpool
 state: ONLINE
 scrub: resilver completed after 0h2m with 0 errors on Sat Feb 14 16:32:05 2009
config:
       NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          mirror    ONLINE       0     0     0
            c3d0s0  ONLINE       0     0     0  23.8M resilvered
            c4d1s0  ONLINE       0     0     0  2.98G resilvered
저기 있는 resilvered는 서로 얼마나 데이터를 복제했느냐이다. 현재까지의 솔라리스가 디스크를 점유한 공간은 2.98GB이므로, 2.98GB가 복제되면 mirroring이 끝났단 소리다.

Grub도 설치해야 함.
$ pfexec installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d1s0
완성!!!

미러링이 잘 되는지 테스트를 해볼 수도 있다.
6. Test the worst Case: Disk A fails, you can still boot into Disk B
- Remove Disk A
- Replace it with an emtpy Disk C
- Start the System: Choose to boot from Disk B in the Bios
- Repeat Steps 2. till 5. for Disk C (swap c3d0s0 and c3d1s0)
- Start the System like before (from Disk C)
그러나 안 해봤다. 물리적으로 디스크를 뺐다 꼈다 하라니 ㅠㅠ;;;
심심하면, VirtualBox같은 것에다 해보길 바란다.