vmdk 형식에서 box 형식으로 변환하여 시작까지의 단계
15716 단어 VirtualBoxvmwareVagrant
주위에 이런 것에 관심이 있는 사람이 없어서 힘들다. . .
유쿠유쿠는 jenkins와 협력하고 싶다.
환경
호스트 OS: Windows Server 2012 R2 64bit
절차
변환하고 싶은 개발 환경을 VirtualBox로 기동시켜 둔다.
명령 프롬프트에서 다음 변환 명령 실행
명령vagrant package --base [VirtualBoxName] --output [BoxFile].box
VirtualBoxName:VirtualBox 제목 표시줄에 표시되는 이름
BoxFile : vagrant로 읽을 파일 이름
여러 가지 오류가 있었지만 박스 파일이 생성되었습니다.
실행 결과C:\Users\[UserName]>vagrant package --base [VirtualBoxName]--output [BoxFile].box
==> [VirtualBoxName]: Attempting graceful shutdown of VM...
[VirtualBoxName]: Guest communication could not be established! This is usually because
[VirtualBoxName]: SSH is not running, the authentication information was changed,
[VirtualBoxName]: or some other networking issue. Vagrant will force halt, if
[VirtualBoxName]: capable.
==> [VirtualBoxName]: Forcing shutdown of VM...
==> [VirtualBoxName]: Exporting VM...
==> [VirtualBoxName]: Compressing package to:C:/Users/[UserName]/[BoxFile].box
UserName: Windows 계정 이름
vagrant에 다음 명령으로 box 추가
명령vagrant box add "[BoxFile]" ./[BoxFile].box
실행 결과C:\Develop\VirtualMachine>vagrant box add "[BoxFile]" ./[BoxFile].box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box '[BoxFile]' (v0) for provider:
box: Unpacking necessary files from: file://C:/[BoxFile].box
box: Progress: 100% (Rate: 18.0M/s, Estimated time remaining: --:--:--)
==> box: Successfully added box '[BoxFile]' (v0) for 'virtualbox'!
vagrant 초기화
초기화 명령vagrant init [BoxFile]
실행 결과A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
Vagrantfile의 사용자 변경
작성된 vm에는 당연히 vagrant 유저를 정의하고 있지 않으므로,
파일에 로그인 사용자를 지정합니다.
config.ssh.username = "[VM_USERNAME]"
vagrant 시작 [실패]
시작 명령vagrant up
실행 결과Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: melco
default: SSH auth method: private key
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Authentication failure. Retrying...
넣지 않는다 ⇒ ssh의 공개 키 설정이 박스 쪽으로 되어 있지 않은 탓
Ctrl+C로 중단하여 별도 작업
ssh 공개 키 설정을 vm으로 설정
호스트 OS에서 ssh 공개 키를 생성합니다.
기본 로컬 네트워크에서만 사용되므로 보안은 경시
cd C:\Users\[USERNAME]\.vagrant.d
ssh-keygen insecure_private_key > public_key
UserName: Windows 계정 이름
Vagrantfile의 개인 키 설정
Vagrantfile의 개인 키 설정config.ssh.private_key_path = "C:/Users/Administrator/.vagrant.d/insecure_private_key"
공개 키의 교환을 호스트 OS와 게스트 OS간에 실시하기 때문에 vagrant의 설정을 취득해 둔다
vagrantOS⇔hostOS 통신vagrant ssh-config > ssh.config
ssh 공개 키 설정
ssh.config에서 기본적으로 PasswordAuthentication의 인수가 no이므로 yes로 다시 씁니다.
공개 키 파일 보내기scp -F ssh.config C:\Users\[USERNAME]\.vagrant.d\public_key [VM_USERNAME]@default:~/ssh
vagrant에 ssh 비밀번호로 로그인vagrant ssh
권한 설정chmod 700 ~/.ssh
파일 이름을 바꾸고 권한 설정mv public_key authorized_keys
chmod 600 authorized_keys
종료 명령vagrant halt
이번이야말로 vagrant 시작 [실패]
시작 명령vagrant up
실행 결과Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: melco
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Mounting shared folders...
default: /vagrant => C:/Develop/VirtualMachine
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mkdir -p /vagrant
권한이 없기 때문에 지금까지의 [VM_USERNAME]을 모두 root로 하고 다시 실행.
세 번째 정직 [실패]
시작 명령vagrant reload
실행 결과==> default: Attempting graceful shutdown of VM...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: root
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Mounting shared folders...
default: /vagrant => C:/Develop/VirtualMachine
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=0,gid=0 vagrant /vagrant
분명히 공유 폴더를 마운트하는 데 필요한 게스트 추가 기능이 없기 때문입니다.
vagrant-vbguest 플러그인 설치
우리 환경이라면 proxy의 설정이 필요하다고 해서 우선 proxy를 set했다.
프록시 설정 명령set http_proxy=[proxy_address]:[proxy_port]
플러그인 설치 명령vagrant plugin install vagrant-vbguest
실행 결과Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Fetching: micromachine-2.0.0.gem (100%)
Fetching: vagrant-vbguest-0.15.1.gem (100%)
Installed the plugin 'vagrant-vbguest (0.15.1)'!
네 번째 정직 [성공! ]
시작 명령vagrant reload
실행 결과・
・
・
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => C:/Develop/VirtualMachine
==> default: Machine already provisioned. Run `vagrant provision` or use the `--
provision`
==> default: flag to force provisioning. Provisioners marked to run always will
still run.
로그 할애. 아무래도 에러도 없고 정상적으로 우울하고 있는 모습.
여기까지 길었다. . .
참조 페이지
vagrant package --base [VirtualBoxName] --output [BoxFile].box
C:\Users\[UserName]>vagrant package --base [VirtualBoxName]--output [BoxFile].box
==> [VirtualBoxName]: Attempting graceful shutdown of VM...
[VirtualBoxName]: Guest communication could not be established! This is usually because
[VirtualBoxName]: SSH is not running, the authentication information was changed,
[VirtualBoxName]: or some other networking issue. Vagrant will force halt, if
[VirtualBoxName]: capable.
==> [VirtualBoxName]: Forcing shutdown of VM...
==> [VirtualBoxName]: Exporting VM...
==> [VirtualBoxName]: Compressing package to:C:/Users/[UserName]/[BoxFile].box
vagrant box add "[BoxFile]" ./[BoxFile].box
C:\Develop\VirtualMachine>vagrant box add "[BoxFile]" ./[BoxFile].box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box '[BoxFile]' (v0) for provider:
box: Unpacking necessary files from: file://C:/[BoxFile].box
box: Progress: 100% (Rate: 18.0M/s, Estimated time remaining: --:--:--)
==> box: Successfully added box '[BoxFile]' (v0) for 'virtualbox'!
vagrant init [BoxFile]
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
config.ssh.username = "[VM_USERNAME]"
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: melco
default: SSH auth method: private key
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Authentication failure. Retrying...
cd C:\Users\[USERNAME]\.vagrant.d
ssh-keygen insecure_private_key > public_key
config.ssh.private_key_path = "C:/Users/Administrator/.vagrant.d/insecure_private_key"
vagrant ssh-config > ssh.config
scp -F ssh.config C:\Users\[USERNAME]\.vagrant.d\public_key [VM_USERNAME]@default:~/ssh
vagrant ssh
chmod 700 ~/.ssh
mv public_key authorized_keys
chmod 600 authorized_keys
vagrant halt
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: melco
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Mounting shared folders...
default: /vagrant => C:/Develop/VirtualMachine
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mkdir -p /vagrant
vagrant reload
==> default: Attempting graceful shutdown of VM...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: root
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Mounting shared folders...
default: /vagrant => C:/Develop/VirtualMachine
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=0,gid=0 vagrant /vagrant
set http_proxy=[proxy_address]:[proxy_port]
vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Fetching: micromachine-2.0.0.gem (100%)
Fetching: vagrant-vbguest-0.15.1.gem (100%)
Installed the plugin 'vagrant-vbguest (0.15.1)'!
vagrant reload
・
・
・
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => C:/Develop/VirtualMachine
==> default: Machine already provisioned. Run `vagrant provision` or use the `--
provision`
==> default: flag to force provisioning. Provisioners marked to run always will
still run.
Reference
이 문제에 관하여(vmdk 형식에서 box 형식으로 변환하여 시작까지의 단계), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/emuemu/items/659b7871a98face25422텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)