quemu로 Ubuntu Cloud 만들기

2345 단어
Ubuntu Cloud 구축
ubuntu 시작
두 가지로 나뉘는데:uefi와 정상 가동
https://gist.github.com/george-hawkins/16ee37063213f348a17717a7007d2c79 https://gist.github.com/tpaskhalis/1e601200da499508f9a8502493091f52
기본 방식은 로그인할 수 없습니다. ssh로 두 가지 방식으로 공개 키를 vm에 전달합니다. 하나는 mount img을 복제하고, 다른 하나는 클라우드에 있습니다.txt에 쓰기
방법 1
$ whoami
ghawkins
$ cat ~/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...
$ cat > cloud.txt << EOF
#cloud-config
users:
  - name: ghawkins
    ssh-authorized-keys:
      - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash
EOF
$ cloud-localds cloud.img cloud.txt

방법 2
 # Instructions for working with QEMU image come from 
# https://www.kumari.net/index.php/system-adminstration/49-mounting-a-qemu-image

1. Download image http://cloud-images.ubuntu.com/
2. Install qemu, nbd-client
3. Load the module
    sudo modprobe nbd max_part=8
4. Connect image  
    sudo qemu-nbd --connect=/dev/nbd0 Downloads/xenial-server-cloudimg-amd64-disk1.img
5. Mount image
    sudo mount /dev/nbd0p1 /mnt/cd
6. Add the content of ~/.ssh/id_rsa.pub to /mnt/cd/home/ubuntu/.ssh/authorized_keys
7. Unmount image
    sudo umount /mnt/cd
8. Disconnect the image
    sudo nbd-client -d /dev/nbd0

img 크기 증가
기본 파일 시스템이 매우 작기 때문에
https://help.ubuntu.com/community/UEC/Images

## Install a necessary packages
$ sudo apt-get install kvm cloud-utils genisoimage
 
## URL to most recent cloud image of 12.04
$ img_url="http://cloud-images.ubuntu.com/server/releases/12.04/release"
$ img_url="${img_url}/ubuntu-12.04-server-cloudimg-amd64-disk1.img"
## download the image
$ wget $img_url -O disk.img.dist

## Create a file with some user-data in it
$ cat > my-user-data <

좋은 웹페이지 즐겨찾기