티스토리 뷰

반응형


간단한 ip설정 및 kvm (kernel virtual machine)에 필요한 파일 설치 및 파티션 나누기


#시작하자마자 인터넷이 안 되었다. 고스트로 이미지 뜬 것이기에 다른 ip가 입력되어 있었다. 동적 ip로 설정해주기 위해 Networking 명령어 필요

# nmtui

# 한 뒤 알아서 하면됨 (수동이면 Manual, 동적이면 Automatic ... 설정)


# 메모장 사용법은 gedit을 활용, 저장시 windows로 저장해야 enter가 뉴 라인 캐릭터로 인식됨


# 커널 정보를 알 수 있음 (3.10.0-514.26.1.el7.x86_64)

[root@station16 ~]# uname -a
Linux station16.example.com 3.10.0-514.26.1.el7.x86_64 #1 SMP Thu Jun 29 16:05:25 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

# OS 정보를 알 수 있음

[root@station16 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

# 기업들이 좋아하는 linux
# "redhat" 인기가 많은 이유 : warranty가 잘됨
# fedora를 번역하면 중절모
# 같은 계열 { redhat, fedora, centos }
# SuSE

# 그 외 linux
# 가상화에 유리한 Debian, Ubuntu

======= 쉬는 시간


[root@station16 ~]# ping 59.29.224.96
PING 59.29.224.96 (59.29.224.96) 56(84) bytes of data.
64 bytes from 59.29.224.96: icmp_seq=1 ttl=64 time=0.225 ms
64 bytes from 59.29.224.96: icmp_seq=2 ttl=64 time=0.234 ms
64 bytes from 59.29.224.96: icmp_seq=3 ttl=64 time=0.144 ms
64 bytes from 59.29.224.96: icmp_seq=4 ttl=64 time=0.172 ms
^C
--- 59.29.224.96 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.144/0.193/0.234/0.040 ms


[root@station16 ~]# vi /etc/hosts
...
59.29.224.96     server1.example.com     server1


[root@station16 ~]# ping server1
PING server1.example.com (59.29.224.96) 56(84) bytes of data.
64 bytes from server1.example.com (59.29.224.96): icmp_seq=1 ttl=64 time=0.164 ms
64 bytes from server1.example.com (59.29.224.96): icmp_seq=2 ttl=64 time=0.154 ms
64 bytes from server1.example.com (59.29.224.96): icmp_seq=3 ttl=64 time=0.153 ms
^C
--- server1.example.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.153/0.157/0.164/0.005 ms
[root@station16 ~]# vi /etc/hosts



# Repository : 필요한 파일들이 모여있는 저장소, xxx.rpm, yyy.rpm, ...

# PC -------> Server { xxx.rpm, yyy.rpm ... }
        <-------

# xxx를 설치하고 싶은데, yyy도 필요해. 그래서 yyy를 설치하려는데 zzz가 필요해. 그것을 피하는 명령어 "yum"


# 아래는 실습환경에서 필요한 파일들

[root@station16 ~]# yum -y install qemu-kvm libvirt virt-manager virt-viewer


# 터미널 명령어 창에서 vi 커맨드 모드 쓰는 법, 커맨드 모드에서 자동완성기능은 ESC + \ 하면됨.

# set -o vi

# etc/.profile, $HOME/.profile, $HOME/ .bashrc (bashrc는 자식 프로세스를 열 때도 호출한다.) vi로 호출 후 set -o vi 입력


# 또 실습환경에서 필요한 파일들 설치 (파일이 존재하지 않음)

[root@station16 ~]# lsscsi
bash: lsscsi: command not found...
[root@station16 ~]# yum -y install lsscsi

# 시스템에 장치된 장치 확인

[root@station16 ~]# lsscsi
[0:0:0:0]    disk    Generic- SD/MMC           1.00  /dev/sdb    # 메모리 sd 카드읽는기기
[0:0:0:1]    disk    Generic- Compact Flash    1.01  /dev/sdc   # 같음
[0:0:0:2]    disk    Generic- SM/xD-Picture    1.02  /dev/sdd   #  같음
[0:0:0:3]    disk    Generic- MS/MS-Pro        1.03  /dev/sde   #  같음
[1:0:0:0]    disk    ATA      ST3500418AS      HP35  /dev/sda  # 하드디스크
[3:0:0:0]    cd/dvd  hp       CDDVDW TS-H653T  H6D1  /dev/sr0  # cd/ dvd

하드디스크 공간

-------
/boot
-------
OS
-------

그 외 사용할 수 있는 공간

-------


# "그 외 사용할 수 있는 공간"에 파티션을 나누려고 함.

[root@station16 ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008f15e

   Device Boot      Start         End      Blocks   Id  System     #start 주소 번지수, End 주소번지수
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    72706047    35840000   8e  Linux LVM


# 위에서 파티션 두개 있는거 확인했으니 생성하기로 함.
# 파티션 생성시 Start 주소를 줄 수 있으나, default로는 가장 뒤 파티션 뒤에 따라감.
# End 주소는 번지수 말고도 size로도 줄 수 있음

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (72706048-976773167, default 72706048):
Using default value 72706048
Last sector, +sectors or +size{K,M,G} (72706048-976773167, default 976773167): +100G
Partition 3 of type Linux and of size 100 GiB is set

Command (m for help): p

Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008f15e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    72706047    35840000   8e  Linux LVM
/dev/sda3        72706048   282421247   104857600   83  Linux

# 이제까지 메모리에 로드 했으니 w 명령어를 통해 디스크에 쓴다.

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.


# 파티션 나눠졌는가 확인, 안되어 있어서 partprobe를 수행후 다시 확인.

[root@station16 ~]# ls -l /dev/sda?
brw-rw----. 1 root disk 8, 1 Jul 16 20:19 /dev/sda1
brw-rw----. 1 root disk 8, 2 Jul 16 20:19 /dev/sda2
[root@station16 ~]# partprobe /dev/sda
[root@station16 ~]# ls -l /dev/sda?
brw-rw----. 1 root disk 8, 1 Jul 16 20:21 /dev/sda1
brw-rw----. 1 root disk 8, 2 Jul 16 20:21 /dev/sda2
brw-rw----. 1 root disk 8, 3 Jul 16 20:21 /dev/sda3


# 포맷 수행

[root@station16 ~]# mkfs.xfs /dev/sda3
meta-data=/dev/sda3              isize=512    agcount=4, agsize=6553600 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=26214400, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=12800, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


# 마운트하기

[root@station16 ~]# vi /etc/fstab

...
/dev/sda3       /var/lib/libvirt/images         xfs     defaults        0 2

# /etc/fstab 에 기록된 것들 마운트해주세요

[root@station16 ~]# mount -a


# 잘 됐는지 확인, Unix의 bdf 와 유사한 df, 옵션은 human readable(-h)로 사이즈를 읽기 쉽게해준다.

[root@station16 ~]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root         8.0G  3.8G  4.3G  47% /
devtmpfs                     7.8G     0  7.8G   0% /dev
tmpfs                        7.9G   25M  7.9G   1% /dev/shm
tmpfs                        7.9G   17M  7.9G   1% /run
tmpfs                        7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/sda1                    497M  153M  345M  31% /boot
/dev/mapper/vg0-tmp         1014M   33M  982M   4% /tmp
/dev/mapper/vg0-var          2.0G  180M  1.9G   9% /var
tmpfs                        1.6G   28K  1.6G   1% /run/user/0
server1:/export/netinstall   232G   11G  222G   5% /net/server1/export/netinstall
server1:/export/courserepos  232G   11G  222G   5% /net/server1/export/courserepos
/dev/sda3                    100G   33M  100G   1% /var/lib/libvirt/images


======== 쉬는 시간


# reboot후 다음 수행, gui 환경의 virtual machine manager

[root@station16 ~]# virt-manager
... 스샷 찍기 어려움. Local 환경에 이미지가 있을경우, 또는 NFS 으로 이미지를 받을 경우 등. 선택해서 설치..

# 설치 다 수행하고 vm에서 linux 초기 화면 보여줄 때, 소프트웨어 선택에서 시스템 환경 설정가능 { 최소설치, 웹서버, 계산노드, 인프라 서버 ... }

# KDUMP, 장애 발생시 디버깅 정보 알려줌

# 본 리눅스 터미널에서 ssh "가상 아이피 주소" 로 가상환경에 접속가능

반응형

'IoT 과정' 카테고리의 다른 글

커널 옵션 적응하기, 드라이버 편집하기 등 task  (0) 2017.07.17
LINUX KERNEL & DEVICES  (0) 2017.07.17
Managing Input and Output  (0) 2017.07.07
Functions and Function Libraries  (0) 2017.07.07
Array Variable  (0) 2017.07.07