본문 바로가기
IT/그 외 IT

[OpenStack] 4. VM image 설치

by 초록술 2022. 6. 1.
반응형

Virtual Machine image 를 Glance 에 추가

 

root@nw1 ~(keystone)# mkdir -p /var/kvm/images

# cloud ubuntu 20.04 다운로드
root@nw1 ~(keystone)# wget http://cloud-images.ubuntu.com/releases/20.04/release/ubuntu-20.04-server-cloudimg-amd64.img -P /var/kvm/images
--2022-05-26 07:02:46--  http://cloud-images.ubuntu.com/releases/20.04/release/ubuntu-20.04-server-cloudimg-amd64.img
Resolving cloud-images.ubuntu.com (cloud-images.ubuntu.com)... 185.125.190.40, 185.125.190.37, 2620:2d:4000:1::1a, ...
Connecting to cloud-images.ubuntu.com (cloud-images.ubuntu.com)|185.125.190.40|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.img [following]
--2022-05-26 07:02:46--  http://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.img
Reusing existing connection to cloud-images.ubuntu.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 595001344 (567M) [application/octet-stream]
Saving to: ‘/var/kvm/images/ubuntu-20.04-server-cloudimg-amd64.img’

ubuntu-20.04-server-cloudimg-amd64.img     100%[======================================================================================>] 567.44M  6.21MB/s    in 2m 5s   

2022-05-26 07:04:51 (4.55 MB/s) - ‘/var/kvm/images/ubuntu-20.04-server-cloudimg-amd64.img’ saved [595001344/595001344]
# 마운트
root@nw1 ~(keystone)# modprobe nbd
root@nw1 ~(keystone)# qemu-nbd --connect=/dev/nbd0 /var/kvm/images/ubuntu-20.04-server-cloudimg-amd64.img
root@nw1 ~(keystone)# mount /dev/nbd0p1 /mnt
# 설정 변경
root@nw1 ~(keystone)# vi /mnt/etc/cloud/cloud.cfg


# 라인 13에 추가
# only the case you'd like to allow SSH password authentication
ssh_pwauth: true


# 라인 96 수정
# only the case if you'd like to allow [ubuntu] user to use SSH password auth
system_info:
   # This will affect which distro class gets used
   distro: ubuntu
   # Default user name + that default users groups (if added/used)
   default_user:
     name: ubuntu
     lock_passwd: False
     gecos: Ubuntu


root@nw1 ~(keystone)# 
root@nw1 ~(keystone)# 
root@nw1 ~(keystone)# umount /mnt
root@nw1 ~(keystone)# qemu-nbd --disconnect /dev/nbd0p1
/dev/nbd0p1 disconnected

# Glance에 Ubuntu image 추가
root@nw1 ~(keystone)# openstack image create "Ubuntu2004" --file /var/kvm/images/ubuntu-20.04-server-cloudimg-amd64.img --disk-format qcow2 --container-format bare --public
+------------------+--------------------------------------------------------------------+
| Field                | Value                                                                        |
+------------------+--------------------------------------------------------------------+
| container_format | bare                 |
| created_at       | 2022-05-26T07:28:34Z                 |
| disk_format      | qcow2               |
| file             | /v2/images/716b7c1d-7890-4208-9984-7dbf3d0aa274/file                       |
| id               | 716b7c1d-7890-4208-9984-7dbf3d0aa274                   |
| min_disk         | 0       |
| min_ram          | 0       |
| name             | Ubuntu2004              |
| owner            | 2258f47e3eed4fb3bf4463b9ca5cdb34           |
| properties       | os_hidden='False', owner_specified.openstack.md5='', owner_specified.openstack.object='images/Ubuntu2004', owner_specified.openstack.sha256='' |
| protected        | False               |
| schema           | /v2/schemas/image          |
| status           | queued             |
| tags             |               |
| updated_at       | 2022-05-26T07:28:34Z          |
| visibility       | public       |
+------------------+-----------------------------------------------------------------+

# open stack image 목록 확인
root@nw1 ~(keystone)# openstack image list
+--------------------------------------+------------+--------+
| ID                                           | Name       | Status |
+--------------------------------------+------------+--------+
| 716b7c1d-7890-4208-9984-7dbf3d0aa274 | Ubuntu2004 | active |
+--------------------------------------+------------+--------+
root@nw1 ~(keystone)# 

 

 

 

참고 사이트

https://www.server-world.info/en/note?os=Ubuntu_20.04&p=openstack_xena&f=6 

 

Ubuntu 20.04 LTS : OpenStack Xena : Add VM Images : Server World

# if you'd like to change settings in the image, configure like follows # mount disk image root@dlp ~(keystone)# modprobe nbd root@dlp ~(keystone)# qemu-nbd --connect=/dev/nbd0 /var/kvm/images/ubuntu-20.04-server-cloudimg-amd64.img root@dlp ~(keystone)# #

www.server-world.info

 

반응형

'IT > 그 외 IT' 카테고리의 다른 글

[OpenStack] 5. Nova 구성(2)  (0) 2022.06.03
[OpenStack] 5. Nova 구성(1)  (0) 2022.06.02
[OpenStack] 3. Glance 설정  (0) 2022.05.31
[OpenStack] 2. Keystone 설정  (0) 2022.05.30
[OpenStack] 1. Openstack Xena 설치  (0) 2022.05.28

댓글