btrfs를_응용한_no-hdd_pc방_구축

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

btrfs를_응용한_no-hdd_pc방_구축 [2015/06/18 15:48] – 만듦 adminbtrfs를_응용한_no-hdd_pc방_구축 [2015/06/18 15:49] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 +====== btrfs를 이용한 No-HDD PC방 구축 ======
  
 + :!: 원글 링크 : http://2cpu.co.kr/bbs/board.php?bo_table=vm&wr_id=2343
 +
 +===== 0. 우분투 설치 =====
 +btrfs file system 사용할 파티션 생성
 +/iscsi <---  사용자지정
 +
 +  * DHCP 서버
 +  * TFTP 서버
 +  * ISCSI 서버
 +  * BTRFS 화일 시스템
 +
 +===== 1. 네트웍 설정 =====
 +서버의 IP 어드레스를 설정 합니다
 +<code vim>
 +/etc/network/interface
 +
 +auto eth0
 +iface eth0 inet static
 +        address 211.168.0.3
 +        netmask 255.255.255.0
 +        gateway 211.168.0.1
 +        dns-nameservers 168.124.101.2
 +</code>
 +
 +===== 2. 서버 프로그램 인스톨 =====
 +
 +우분투는 인터넷에 연결되어 있으면 필요한 프로그램을 설치하기가 쉽습니다..
 +
 +  * # DHCP 서버 프로그램 설치
 +<code>
 +root:/#apt-get install isc-dhcp-server
 +</code>
 +
 +  * #TFTP 서버 프로그램 설치
 +<code>
 +root:/#apt-get install xinetd
 +root:/#apt-get install tftpd
 +root:/#apt-get install hpa-tfpd
 +</code>
 +
 +  * #BTRFS-TOOLS 설치
 +<code>
 +root:/#apt-get install btrfs-tools
 +</code>
 +
 +  * #iscsi 서버 설치
 +<code>
 +root:/#apt-get install iscsitarget iscsitarget-dkms
 +</code>
 +
 +===== 3. ISCSI 볼륨 만들기 =====
 +
 + - 위의 프로그램이 전부 인스톨 되어 있으면 프로그램 세팅에 들어갑니다.. ISCSI TARGET 설정으로 하드가 없는 클라이언트에 하드 디스크 볼륨을 만들어 줍니다..
 +
 + - 처음에 리눅스 인스톨할때 BTRFS 파일 시스템 100G 로 /iscsi 로 마운트 해서 만들 었습니다.
 +주의 : 100G 가 파일시스템을 만들었으면 새로 생성될 이미지 크기는 50% 정도만 사용해야 사용중 Full 상태가 안날수 있습니다.
 +
 +<code>
 +root:/# mkdir /iscsi/image
 +root:/# chmod 755 /iscsi/image
 +root:/# btrfs subvolume create /iscsi/image/win7
 +root:/# chmod 755 /iscsi/image/win7
 +</code>
 +
 + - 볼륨 이미지 생성
 +<code>
 +root:/# dd if=/dev/zero of=/iscsi/image/win7/win7.img bs=1048576 count=500000
 +</code>
 +50기가의 빈 파일을 생성합니다
 +
 +  * /etc/default/iscsitarget 파일을 수정 합니다.
 +ISCSITARGET_ENABLE=true      ----- > true 로 수정하시고 저장하시면 됩니다.
 +
 +  * /etc/iet/ietd.conf 파일의 마지막에 다음을 추가 합니다.
 +<code vim>
 +Target iqn.2014-08.vitamin.com:master    -----> iscsi target 이름
 +    Lun 0 Path=/iscsi/image/win7/win7.img,Type=fileio  ------> iscsi target image path
 +Alias client1        --> 별명 생략가능
 +MaxConnecions    1  ------> 설정 안하면 iscsi 동시 접속시 파일시스템 깨짐
 +</code>
 +
 +  * Iscsi target 재시작
 +<code>
 +root:/# service iscsitarget restart
 +</code>
 + 에러 없이 ok 나오면 정상적으로 이미지를 생성한것이고 틀리면 위를 다시한번 살펴 보세요
 +
 +===== 4. 클라이언트가 연결할 DHCP, TFTP, gPXE 설정 =====
 +http://rom-o-matic.net/gpxe/gpxe-1.0.1/contrib/rom-o-matic/
 +에서 undionly.kpxe 를 다운로드 합니다..
 +
 +  * dhcp 설정
 +<code vim>
 +/etc/dhcp/dhcpd.conf
 +
 +subnet 211.168.0.0 netmask 255.255.255.0 {
 +range dynamic-bootp 211.168.0.11 211.168.0.185;
 +option domain-name-servers 164.124.101.2, 168.126.63.1;
 +option broadcast-address 211.168.0.255;
 +option routers 211.168.0.1;
 +authoritative;
 +
 +}
 +host client1 {
 +  hardware ethernet 00:00:00:00:00:00;    ------> 클라이언트의 맥어드레스
 +  fixed-address 192.168.0.10;            -------> 위의 클라이언트에 아이피 등록
 +  option host name "client1";
 +  if exists user-class and option user-class = "gPXE" {
 +    filename "";
 +    option root-path "iscsi:211.168.0.3::::iqn.2014-08.vitamin.com:master"; -- > 서버주소와 iscsi target 이름 메인 이지미 입니다
 +} else {
 +    filename "gpxe.kpxe";
 +}
 +}
 +</code>
 +
 +위에서 중요한것은 클라이언트의 맥어드레스 입니다..
 +클라이언트의 CMOS SETUP 에 들어가 랜카드로 부팅이 가능하도록 Boot from LAN 을 Enable 로
 +바꾸고 부팅순서도 NETWORK 을 1 번으로 바꾸고 부팅을 하면
 +
 +
 +
 + - TFTP 설정
 +
 +/etc/xinetd.d/tftp 파일 편집
 +<code vim>
 +service tftp
 +{
 +  disable      = no                --- > 이것만 yes 를 no 로 하시면 될듯
 +  socket_type  = dgram
 +  protocol    = udp
 +  wait        = yes
 +  user        = nobody
 +  server      = /usr/sbin/in.tftpd
 +  server_args    = -s /tftpboot
 + }
 +</code>
 +#############################
 +
 +아까 다운받은파일 gpxe-1.0.1-undionly.kpxe 는
 +/tftpboot 폴더로 복사하여 이름을 gpxe.kpxe 로 바꾸어 놓습니다.
 +
 +/tftpboot 폴더는 존재하지 않는 폴더니 새로 만드셔야 합니다.
 +#mkdir /tftpboot 하시면 됩니다.
 +
 +  * DHCP 서버 재시작
 +<code>
 +root:/#service isc-dhcp-server restart
 +</code>
 +
 +이렇게 되면... 원본 마스터 서버가 만들어져습니다.
 +이제 10개에서 100개 무한대로 파일 시스템 스냅샷입니다.
 +<code>
 +btrfs subvolume snapshot /iscsi/image/win7 /iscsi/image/pc01
 +btrfs subvolume snapshot /iscsi/image/win7 /iscsi/image/pc02
 +btrfs subvolume snapshot /iscsi/image/win7 /iscsi/image/pc03
 +</code>
 +사용할 pc대수 만큼 만들어 줍니다.
 +/iscsi/image/pc01/ 폴더에 win7.img 가 보일겁니다
 +새로만든 스넵샷 pc에 연결 하기
 +위에 /etc/iet/ietd.conf 파일 편집 추가
 +
 +<code vim>
 +Target iqn.2014-08.vitamin.com:pc01
 +Lun 0 Path=/iscsi/image/pc01/win7.img,Type=fileio
 +MaxConnecions 1
 +Target iqn.2014-08.vitamin.com:pc02
 +Lun 0 Path=/iscsi/image/pc02/win7.img,Type=fileio
 +MaxConnecions 1
 +Target iqn.2014-08.vitamin.com:pc03
 +Lun 0 Path=/iscsi/image/pc03/win7.img,Type=fileio
 +MaxConnecions 1
 +</code>
 +
 +dhcp에 연결설정 합니다 /etc/dhcp/dhcpd.conf
 +아까 만들어 놓은 파일에 추가 합니다.
 +/etc/dhcp/dhcpd.conf
 +<code vim>
 +subnet 211.168.0.0 netmask 255.255.255.0 {
 +range dynamic-bootp 211.168.0.11 211.168.0.185;
 +option domain-name-servers 164.124.101.2, 168.126.63.1;
 +option broadcast-address 211.168.0.255;
 +option routers 211.168.0.1;
 +authoritative;
 +}
 +host master {
 +  hardware ethernet 00:00:00:00:00:00;
 +  fixed-address 211.168.0.10;
 +  option host name "client1";
 +  if exists user-class and option user-class = "gPXE" {
 +    filename "";
 +    option root-path "iscsi:211.168.0.3::::iqn.2014-08.vitamin.com:master";
 +} else {
 +    filename "gpxe.kpxe";
 +}
 +}
 +host pc01 {
 +  hardware ethernet 00:00:00:00:00:00;
 +  fixed-address 211.168.0.11;
 +  option host name "pc01";
 +  if exists user-class and option user-class = "gPXE" {
 +    filename "";
 +    option root-path "iscsi:211.168.0.3::::iqn.2014-08.vitamin.com:pc01";
 +} else {
 +    filename "gpxe.kpxe";
 +}
 +}
 +host pc02 {
 +  hardware ethernet 00:00:00:00:00:00;
 +  fixed-address 211.168.0.12;
 +  option host name "pc02";
 +  if exists user-class and option user-class = "gPXE" {
 +    filename "";
 +    option root-path "iscsi:211.168.0.3::::iqn.2014-08.vitamin.com:pc02";
 +} else {
 +    filename "gpxe.kpxe";
 +}
 +}
 +host pc03 {
 +  hardware ethernet 00:00:00:00:00:00;
 +  fixed-address 211.168.0.13;
 +  option host name "client1";
 +  if exists user-class and option user-class = "gPXE" {
 +    filename "";
 +    option root-path "iscsi:211.168.0.3::::iqn.2014-08.vitamin.com:pc03";
 +} else {
 +    filename "gpxe.kpxe";
 +}
 +}
 +</code>
 +위에
 +pc01 스냅샷 파일을 만들고 iscsi에서 연결할 스냅샷 이미지을 path을 설정하고
 +tftp 부팅시 iscs에서 pc01에 만들어 놓은 이미지을 연결합니다.
 +
 +만약 pc01번을 사용하다 초기화 해야될 상항이 생기면
 +<code>
 +#ietadm --op delete --tid=1 --lun=0  iscsi 연결 끊기
 +#btrfs subvolume delete /iscsi/image/pc01  스냅샷 이미지 지우기
 +#btrfs subvolume snapshot /iscsi/image/win7 /iscsi/image/pc01  새로 원본에서 스냅샷 이미지 생성
 +#ietadm --op new --tid=1 --lun=0 --params Path=/iscsi/image/pc01/win7.img  iscsi에서 이미지 연결
 +</code>
 +이렇게 명령어 치시면 0.1초도 안되 초기화가 됩니다.
 +프로그램 추가 하거지 삭제 하실꺼면 처음 만들어 놓은 master 이미지로 부팅해서
 +추가 하거나 삭제 하시고  pc대수 만큼 스넵샷 다시 만들어주면 일괄 적용 됩니다.
 +master 이미지에 윈도우 넣기는
 +일반 pc에 하드 달고 정상적이 윈도우 설치하고 다른 파티션에 고스트 이미지 만든다음
 +윈도우 제어판 관리도구에 iscsi 클릭
 +연결에 만들어놓은 서버 ip 넣구 연결
 +그러면 master, pc01, pc02 pc03, 나오면 master 연결
 +그러면 윈도우에 물리적하드가 생성됩니다.
 +관리도구 디스크에서 온라인 시키고 포맷 한다음
 +아까 만들어 놓은 고스트 이미지 새로연결된 iscsi 에 밀어 놓기 하면 끝납니다.
 +원본하드 윈도우 설치후 아래 픽스 설치 하셔야 부팅시 불루 스크인 안뜹니다
 +http://support.microsoft.com/kb/2550978
 +http://support.microsoft.com/kb/976042/