VM의 Root Disk를 가지고 VM들을 만들면서,

기존의 Root Disk를 이용해서 새로운 VM을 만들경우,

eth0 이 아닌 eth1이 만들어진다. 그 다음은 eth2.

물론 기존의 nic가 없을경우는 상관이 없지만, 기존에 nic 이 있을 경우 이런식이다.

/etc/udev/rules.d/ 를 보면 

70-persistent-net.rules 파일이 있는데,

이 파일을 열어 보면 nic 정보가 들어있다. (Centos6 기준)

이걸 보면 느낌이 오겠지만 기존 정보를 지우고 재부팅을 하면 원하는 eth로 사용을 할 수 있다.


CentOS 템플릿을 수정해야할 일이 생겼다.

qemu-img convert -f qcow2 볼륨파일 -O qcow2 템플릿파일

위와 같이 시도해봤으나 볼륨이 카피되는 것처럼 찝찝했다.

그래서 마운트해서 직접 파일시스템을 고쳐보기로...

하지만 LVM 에서 막혀버렸다... ㅠ


그리도 qcow2 는 qemu-nbd 라는 유틸리티를 이용해서 로드할 수 있는데, CentOS6 버전에서는 없다.


그래서 qcow2 를 raw로 변경해야 한다.

qemu-img convert -f qcow2 originImage.qcow2 -O raw image.raw


raw 로 바뀌었으면 이제 본격적으로 마운트를 시켜보자.

losetup /dev/loop0 image.raw

kpartx -a /dev/loop0

mkdir /mnt/image

mount /dev/mapper/loop0p2 /mnt/image

하지만.

"mount: unknown filesystem type 'LVM2_member'"

에러가 발생한다.

LVM이기 때문에 이렇게 마운트 할수가 없는 것이다.



[root@dev156 mnt]# lvmdiskscan

  /dev/ram0                [      16.00 MiB]

  /dev/loop0               [       8.00 GiB]

  /dev/root                [      50.00 GiB]

  /dev/ram1                [      16.00 MiB]

  /dev/vg_dev154/lv_swap   [       9.80 GiB]

  /dev/ram2                [      16.00 MiB]

  /dev/sda2                [     500.00 MiB]

  /dev/vg_dev154/lv_home   [     871.22 GiB]

  /dev/ram3                [      16.00 MiB]

  /dev/sda3                [     931.02 GiB] LVM physical volume

  /dev/vg_dev156/lv_swap   [       9.78 GiB]

  /dev/ram4                [      16.00 MiB]

  /dev/vg_dev156/lv_home   [     871.22 GiB]

  /dev/ram5                [      16.00 MiB]

  /dev/vg_dev156/lv_root   [      50.00 GiB]

  /dev/ram6                [      16.00 MiB]

  /dev/ram7                [      16.00 MiB]

  /dev/mapper/loop0p2      [       7.90 GiB] LVM physical volume

  /dev/ram8                [      16.00 MiB]

  /dev/VolGroup00/LogVol00 [       6.88 GiB]

  /dev/ram9                [      16.00 MiB]

  /dev/VolGroup00/LogVol01 [       1.00 GiB]

  /dev/ram10               [      16.00 MiB]

  /dev/ram11               [      16.00 MiB]

  /dev/ram12               [      16.00 MiB]

  /dev/ram13               [      16.00 MiB]

  /dev/ram14               [      16.00 MiB]

  /dev/ram15               [      16.00 MiB]

  /dev/sdb1                [     500.00 MiB]

  /dev/sdb2                [     931.02 GiB] LVM physical volume

  6 disks

  21 partitions

  0 LVM physical volume whole disks

  3 LVM physical volumes


LVM 볼륨이 보인다.

/dev/mapper/loop0p2      [       7.90 GiB] LVM physical volume


lvdisplay와 vgdisplay를 확인해서 LV, VG 이름을 확인한다.

[root@dev156 mnt]# vgdisplay

  --- Volume group ---

  VG Name               vg_dev154

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  6

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                3

  Open LV               3

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               931.02 GiB

  PE Size               4.00 MiB

  Total PE              238341

  Alloc PE / Size       238341 / 931.02 GiB

  Free  PE / Size       0 / 0

  VG UUID               Dully9-Bnix-hrHe-czD0-HfDK-pE60-wNLdmb


  --- Volume group ---

  VG Name               VolGroup00

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  3

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                2

  Open LV               0

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               7.88 GiB

  PE Size               32.00 MiB

  Total PE              252

  Alloc PE / Size       252 / 7.88 GiB

  Free  PE / Size       0 / 0

  VG UUID               984Syc-oChm-BdAX-TKcD-l95D-JkTY-1FdH6M


  --- Volume group ---

  VG Name               vg_dev156

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  4

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                3

  Open LV               0

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               931.00 GiB

  PE Size               32.00 MiB

  Total PE              29792

  Alloc PE / Size       29792 / 931.00 GiB

  Free  PE / Size       0 / 0

  VG UUID               zzp60Z-uCg8-2A6T-M6aU-LfBP-QXqx-U1SDpB


[root@dev156 mnt]# lvdisplay

  --- Logical volume ---

  LV Name                /dev/vg_dev154/lv_root

  VG Name                vg_dev154

  LV UUID                Qx338T-4L2V-mVsj-Idhd-MN0Y-zRM8-WXZBKK

  LV Write Access        read/write

  LV Status              available

  # open                 1

  LV Size                50.00 GiB

  Current LE             12800

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0


  --- Logical volume ---

  LV Name                /dev/vg_dev154/lv_home

  VG Name                vg_dev154

  LV UUID                Ht9ZKI-0tUv-aYCr-hEjO-ArBT-VOaW-J2vcRM

  LV Write Access        read/write

  LV Status              available

  # open                 1

  LV Size                871.22 GiB

  Current LE             223033

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:2


  --- Logical volume ---

  LV Name                /dev/vg_dev154/lv_swap

  VG Name                vg_dev154

  LV UUID                3pLedP-5ctg-1BVo-gSwA-Tbyg-V1gy-X5CaFP

  LV Write Access        read/write

  LV Status              available

  # open                 1

  LV Size                9.80 GiB

  Current LE             2508

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:1


  --- Logical volume ---

  LV Name                /dev/VolGroup00/LogVol00

  VG Name                VolGroup00

  LV UUID                8Yp1YF-dfjF-tg8n-JHNh-iYwL-PJqy-TRlOEz

  LV Write Access        read/write

  LV Status              available

  # open                 0

  LV Size                6.88 GiB

  Current LE             220

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:8


  --- Logical volume ---

  LV Name                /dev/VolGroup00/LogVol01

  VG Name                VolGroup00

  LV UUID                Fd4zHI-S1sp-Xz20-KIuO-QaJJ-RQ1y-mbtIzW

  LV Write Access        read/write

  LV Status              available

  # open                 0

  LV Size                1.00 GiB

  Current LE             32

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:9


  --- Logical volume ---

  LV Name                /dev/vg_dev156/lv_swap

  VG Name                vg_dev156

  LV UUID                d6c20U-pQYM-xGfe-yER1-uSgF-wUYx-5OrboZ

  LV Write Access        read/write

  LV Status              available

  # open                 0

  LV Size                9.78 GiB

  Current LE             313

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:3


  --- Logical volume ---

  LV Name                /dev/vg_dev156/lv_home

  VG Name                vg_dev156

  LV UUID                V1jSbh-ZqZM-XOh7-PFCL-JqTN-jxuc-yoP6Sk

  LV Write Access        read/write

  LV Status              available

  # open                 0

  LV Size                871.22 GiB

  Current LE             27879

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:4


  --- Logical volume ---

  LV Name                /dev/vg_dev156/lv_root

  VG Name                vg_dev156

  LV UUID                RpA6xx-qI6s-WhG6-ZEu8-DCiY-Uprz-C039Cz

  LV Write Access        read/write

  LV Status              available

  # open                 0

  LV Size                50.00 GiB

  Current LE             1600

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:5

[root@dev156 mnt]# vgdisplay

  --- Volume group ---

  VG Name               vg_dev154

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  6

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                3

  Open LV               3

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               931.02 GiB

  PE Size               4.00 MiB

  Total PE              238341

  Alloc PE / Size       238341 / 931.02 GiB

  Free  PE / Size       0 / 0

  VG UUID               Dully9-Bnix-hrHe-czD0-HfDK-pE60-wNLdmb


  --- Volume group ---

  VG Name               VolGroup00

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  3

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                2

  Open LV               0

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               7.88 GiB

  PE Size               32.00 MiB

  Total PE              252

  Alloc PE / Size       252 / 7.88 GiB

  Free  PE / Size       0 / 0

  VG UUID               984Syc-oChm-BdAX-TKcD-l95D-JkTY-1FdH6M


  --- Volume group ---

  VG Name               vg_dev156

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  4

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                3

  Open LV               0

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               931.00 GiB

  PE Size               32.00 MiB

  Total PE              29792

  Alloc PE / Size       29792 / 931.00 GiB

  Free  PE / Size       0 / 0

  VG UUID               zzp60Z-uCg8-2A6T-M6aU-LfBP-QXqx-U1SDpB


mount /dev/VolGroup00/LogVol00 /mnt/image

"mount: special device /dev/VolGroup00/LogVol00 does not exist"

에러가 발생했다...


그래서.

[root@dev156 mnt]# lvscan

  ACTIVE            '/dev/vg_dev154/lv_root' [50.00 GiB] inherit

  ACTIVE            '/dev/vg_dev154/lv_home' [871.22 GiB] inherit

  ACTIVE            '/dev/vg_dev154/lv_swap' [9.80 GiB] inherit

  inactive            '/dev/VolGroup00/LogVol00' [6.88 GiB] inherit

  inactive            '/dev/VolGroup00/LogVol01' [1.00 GiB] inherit

  ACTIVE            '/dev/vg_dev156/lv_swap' [9.78 GiB] inherit

  ACTIVE            '/dev/vg_dev156/lv_home' [871.22 GiB] inherit

  ACTIVE            '/dev/vg_dev156/lv_root' [50.00 GiB] inherit

상태가 inactive가 되어있다.


active로 바꿔줘야한다.

[root@dev156 mnt]# modprobe dm-mod

[root@dev156 mnt]# vgchange -ay

[root@dev156 mnt]# lvscan

  ACTIVE            '/dev/vg_dev154/lv_root' [50.00 GiB] inherit

  ACTIVE            '/dev/vg_dev154/lv_home' [871.22 GiB] inherit

  ACTIVE            '/dev/vg_dev154/lv_swap' [9.80 GiB] inherit

  ACTIVE            '/dev/VolGroup00/LogVol00' [6.88 GiB] inherit

  ACTIVE            '/dev/VolGroup00/LogVol01' [1.00 GiB] inherit

  ACTIVE            '/dev/vg_dev156/lv_swap' [9.78 GiB] inherit

  ACTIVE            '/dev/vg_dev156/lv_home' [871.22 GiB] inherit

  ACTIVE            '/dev/vg_dev156/lv_root' [50.00 GiB] inherit


다시

mount /dev/VolGroup00/LogVol00 /mount/image

이제 마운트가 된다.


수정 후

raw 를 qcow2 다시 변환해주어야한다.

qemu-img convert -f qcow2 image.raw -O raw modifiedImage.qcow2


해제

#lvremove /dev/VolGroup00/LogVol00

#lvremove /dev/VolGroup00/LogVol01

#kpartx -d /dev/loop0

#losetup -d /dev/loop0

참고

http://stackoverflow.com/questions/4966213/changing-password-of-a-virtual-machine

http://pissedoffadmins.com/?p=481


본딩에 관한 글!


http://sangchul.kr/4695354

계정알아보기

# fuser -cu /mnt/temp


해당 계정 종료

# fuser -ck /mnt/temp


Unmount

# umount /mnt/temp

-scanbus로 디바이스 정보 확인

[root@dev156 _home]# cdrecord -scanbus

scsibus4:

4,0,0 400) 'ATAPI   ' 'DVD A DH16ABS   ' 'PS21' Removable CD-ROM

4,1,0 401) *

4,2,0 402) *

4,3,0 403) *

4,4,0 404) *

4,5,0 405) *

4,6,0 406) *

4,7,0 407) *


ISO 파일로 CD굽기

[root@dev156 _home]# cdrecord -v -eject speed=4 dev=4,0,0 CentOS-6.2-x86_64-bin-DVD1.iso

wodim: No write mode specified.

wodim: Asuming -tao mode.

wodim: Future versions of wodim may have different drive dependent defaults.

TOC Type: 1 = CD-ROM

scsidev: '4,0,0'

scsibus: 4 target: 0 lun: 0

WARNING: the deprecated pseudo SCSI syntax found as device specification.

Support for that may cease in the future versions of wodim. For now,

the device will be mapped to a block device file where possible.

Run "wodim --devices" for details.

Linux sg driver version: 3.5.27

Wodim version: 1.1.9

SCSI buffer size: 64512

Device type    : Removable CD-ROM

Version        : 5

Response Format: 2

Capabilities   : 

Vendor_info    : 'ATAPI   '

Identification : 'DVD A DH16ABS   '

Revision       : 'PS21'

Device seems to be: Generic mmc2 DVD-R/DVD-RW.

Current: 0x0011 (DVD-R sequential recording)

Profile: 0x002B (DVD+R/DL) 

Profile: 0x001B (DVD+R) 

Profile: 0x001A (DVD+RW) 

Profile: 0x0016 (DVD-R/DL layer jump recording) 

Profile: 0x0015 (DVD-R/DL sequential recording) 

Profile: 0x0014 (DVD-RW sequential recording) 

Profile: 0x0013 (DVD-RW restricted overwrite) 

Profile: 0x0012 (DVD-RAM) 

Profile: 0x0011 (DVD-R sequential recording) (current)

Profile: 0x0010 (DVD-ROM) 

Profile: 0x000A (CD-RW) 

Profile: 0x0009 (CD-R) 

Profile: 0x0008 (CD-ROM) 

Profile: 0x0002 (Removable disk) 

Using generic SCSI-3/mmc DVD-R(W) driver (mmc_mdvd).

Driver flags   : SWABAUDIO BURNFREE 

Supported modes: PACKET SAO

Drive buf size : 1177600 = 1150 KB

Beginning DMA speed test. Set CDR_NODMATEST environment variable if device

communication breaks or freezes immediately after that.

FIFO size      : 4194304 = 4096 KB

Track 01: data  4218 MB        

Total size:     4844 MB (479:56.41) = 2159731 sectors

Lout start:     4844 MB (479:58/31) = 2159731 sectors

Current Secsize: 2048

HINT: use dvd+rw-mediainfo from dvd+rw-tools for information extraction.

Blocks total: 2298496 Blocks current: 2298496 Blocks remaining: 138765

Speed set to 8310 KB/s

Starting to write CD/DVD at speed   6.0 in real unknown mode for single session.

Last chance to quit, starting real write in    0 seconds. Operation starts.

Waiting for reader process to fill input buffer ... input buffer ready.

Performing OPC...

Starting new track at sector: 0

Track 01: 4218 of 4218 MB written (fifo 100%) [buf  99%]   6.4x.

Track 01: Total bytes read/written: 4423129088/4423129088 (2159731 sectors).

Writing  time:  560.568s

Average write speed   6.0x.

Min drive buffer fill was 57%

Fixating...

Fixating time:   14.648s

wodim: fifo had 69669 puts and 69669 gets.

wodim: fifo was 0 times empty and 25652 times full, min fill was 82%.


CD 데이타 지우기

[root@dev156 _home]# cdrecord -eject --dev=4,0,0 --blank=all



더욱 자세한 것은 여기로 ^^

http://realmind.tistory.com/entry/Linux-Shell%EC%97%90%EC%84%9C-CD-%EA%B5%BD%EA%B8%B0

출처 :  http://www.spaceprogram.com/knowledge/2004/01/starting-tomcat-as-service-on-linux.html 

# vim /etc/init.d/tomcatd


# This is the init script for starting up the

# Jakarta Tomcat server

#

# chkconfig: 345 91 10

# description: Starts and stops the Tomcat daemon.

#

# Source function library.

 . /etc/rc.d/init.d/functions

# Get config.

 . /etc/sysconfig/network

# Check that networking is up.

 [ "${NETWORKING}" = "no" ] && exit 0

 tomcat=/usr/local/tomcat6

 startup=$tomcat/bin/startup.sh

 shutdown=$tomcat/bin/shutdown.sh

 CATALINA_HOME=/usr/local/tomcat6; export CATALINA_HOME

 JAVA_HOME=/usr/java/jdk1.6.0_29; export JAVA_HOME

 start(){

  echo -n $"Starting Tomcat service: "

  #daemon -c

  $startup

  RETVAL=$?

  echo

 }

 stop(){

  action $"Stopping Tomcat service: " $shutdown

  RETVAL=$?

  echo

 }

 status(){

  numproc=`ps -ef | grep catalina | grep -v "grep catalina" | wc -l`

  if [ $numproc -gt 0 ]; then

  echo "Tomcat is running..."

  else

  echo "Tomcat is stopped..."

  fi

 }

 restart(){

   stop

   start

 }

 # See how we were called.

 case "$1" in

 start)

  start

  ;;

 stop)

  stop

  ;;

 status)

  status
 ;;

 restart)

  restart

  ;;

 *)

  echo $"Usage: $0 {start|stop|status|restart}"

  exit 1

 esac

 exit 0


리눅스 서버 세팅 

1. VNC 서버 설치 (환경은 CentOS 6)
#yum install vnc-server

2. VNC 설정. 아래는 root 계정 사용과 해상도는 1680x1050 사용
#vim /etc/sysconfig/vncservers

VNCSERVERS="1:root"

VNCSERVERARGS[1]="-geometry 1680x1050"


32. VNC에 사용할 패스워드 설정
#vncpasswd
패스워드 입력 

4. VNC에 사용될 tcp 포트 추가해서 열어준다.
#vim /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT

# /etc/init.d/iptables restart

5. VNC 서버 시작 
#/etc/init.d/vncserver start


CentOS 5 일 경우 VNC 로 접속했을 때
 

#vim ~/.vnc/xstartup


#twm &     <- 주석처리 하고 GNOME 데스크탑이 실행될 수 있도록 아래 줄을 추가해준다.

gnome-session &   



윈도우 클라이언트 세팅   

1. VNC Viewer 다운로드


2. Server란에 IP주소:포트 입력



3. OK 눌러서 비밀번호 입력 후 접속 !
CentOS6을 설치하면 ssh 클라이언트가 설치되어있지않다.
#yum -y install openssh-clients

계정 추가
# useradd [계정이름]

비밀번호 설정
# passwd [계정이름]

계정 삭제
# userdel [계정이름]

계정 관련 데이터 삭제
# userdel -r [계정이름]

기본적으로 vsftpd
service에 vsftpd가 실행되고 있는지 확인.
아니면 실행해줄것. service vsftpd start

ftp 포트 (21)를 열어줘야 함.

Configure Iptables To Protect The FTP Server

Open file /etc/sysconfig/iptables, enter:
# vi /etc/sysconfig/iptables
Add the following lines, ensuring that they appear before the final LOG and DROP lines for the RH-Firewall-1-INPUT:

-A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 21 -j ACCEPT

Save and close the file. Restart firewall:
# service iptables restart


(출처 : Red Hat / CentOS VSFTPD FTP Server Configuration)
Anonymous 접속을 허락하지 않는다면,

/etc/vsftpd/vsftpd.conf

anonymous_enable=NO

+ Recent posts