Skip to research

Installer Ubuntu dans une machine virtuelle avec Vagrant

Temps de lecture
Environ 4 minutes

Avez-vous installé sur votre machine VirtualBox et Vagrant ?

initier un fichier vagrantfile

C:\Users\mm\Documents\tdb\workspace\work_vagrant
λ vagrant init bento/ubuntu-17.10
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.

dir pour des infos

C:\Users\mm\Documents\tdb\workspace\work_vagrant
λ dir
 Le volume dans le lecteur C s’appelle Windows
 Le numéro de série du volume est 0A4C-2D81

 Répertoire de C:\Users\mm\Documents\tdb\workspace\work_vagrant

24/06/2018  15:54    <DIR>          .
24/06/2018  15:54    <DIR>          ..
24/06/2018  15:54             3 095 Vagrantfile
               1 fichier(s)            3 095 octets
               2 Rép(s)  710 618 034 176 octets libres

vagrant up pour créer la machine

C:\Users\mm\Documents\tdb\workspace\work_vagrant
λ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'bento/ubuntu-17.10' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'bento/ubuntu-17.10'
    default: URL: https://vagrantcloud.com/bento/ubuntu-17.10
==> default: Adding box 'bento/ubuntu-17.10' (v201806.08.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/bento/boxes/ubuntu-17.10/versions/201806.08.0/providers/virtualbox.box
    default: Progress: 100% (Rate: 2048k/s, Estimated time remaining: --:--:--)
==> default: Successfully added box 'bento/ubuntu-17.10' (v201806.08.0) for 'virtualbox'!
==> default: Importing base box 'bento/ubuntu-17.10'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/ubuntu-17.10' is up to date...
==> default: Setting the name of the VM: work_vagrant_default_1529848790927_80709
==> 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: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection aborted. Retrying...
    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] GuestAdditions versions on your host (5.1.36) and guest (5.2.12) do not match.
Reading package lists...
Building dependency tree...
Reading state information...
dkms is already the newest version (2.3-3ubuntu3).
The following NEW packages will be installed:
  linux-headers-4.13.0-21 linux-headers-4.13.0-21-generic
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 11.6 MB of archives.
After this operation, 83.1 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu artful-updates/main amd64 linux-headers-4.13.0-21 all 4.13.0-21.24 [10.9 MB]
Get:2 http://archive.ubuntu.com/ubuntu artful-updates/main amd64 linux-headers-4.13.0-21-generic amd64 4.13.0-21.24 [706 kB]
dpkg-preconfigure: unable to re-open stdin: No such file or directory
Fetched 11.6 MB in 8s (1,431 kB/s)
Selecting previously unselected package linux-headers-4.13.0-21.
(Reading database ... 39242 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.13.0-21_4.13.0-21.24_all.deb ...
Unpacking linux-headers-4.13.0-21 (4.13.0-21.24) ...
Selecting previously unselected package linux-headers-4.13.0-21-generic.
Preparing to unpack .../linux-headers-4.13.0-21-generic_4.13.0-21.24_amd64.deb ...
Unpacking linux-headers-4.13.0-21-generic (4.13.0-21.24) ...
Setting up linux-headers-4.13.0-21 (4.13.0-21.24) ...
Setting up linux-headers-4.13.0-21-generic (4.13.0-21.24) ...
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 4.13.0-21-generic /boot/vmlinuz-4.13.0-21-generic
Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
Installing Virtualbox Guest Additions 5.1.36 - guest version is 5.2.12
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.36 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Removing installed version 5.2.12 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Starting the VirtualBox Guest Additions.

Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 5.1.36. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
Job for vboxadd-service.service failed because the control process exited with error code.
See "systemctl  status vboxadd-service.service" and "journalctl  -xe" for details.
Unmounting Virtualbox Guest Additions ISO from: /mnt
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.12
VBoxService inside the vm claims: 5.1.36
Going on, assuming VBoxService is correct...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.12
VBoxService inside the vm claims: 5.1.36
Going on, assuming VBoxService is correct...
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 5.2.12
    default: VirtualBox Version: 5.1
==> default: [vagrant-hostsupdater] Checking for host entries
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/mm/Documents/tdb/workspace/work_vagrant

 

C:\Users\mm\Documents\tdb\workspace
λ vagrant global-status
id       name        provider   state    directory
------------------------------------------------------------------------------------------
349e028  studio      virtualbox poweroff C:/Users/mm/Documents/tdb/workspace/studio
c9cf29c  packpublish virtualbox poweroff C:/Users/mm/Documents/tdb/workspace/packpublish
8a9e625  bdc         virtualbox poweroff C:/Users/mm/Documents/tdb/workspace/bdc
5fc7b7b  bureau      virtualbox poweroff C:/Users/mm/Documents/tdb/workspace/bureau
8379b61  office      virtualbox poweroff C:/Users/mm/Documents/tdb/workspace/office
ad13600  magique     virtualbox poweroff C:/Users/mm/Documents/tdb/workspace/magique
4c9f1f1  brainquizz  virtualbox poweroff C:/Users/mm/Documents/tdb/workspace/quizz
897a451  default     virtualbox running  C:/Users/mm/Documents/tdb/workspace/work_vagrant

The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date. To interact with any of the machines, you can go to
that directory and run Vagrant, or you can use the ID directly
with Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"
C:\Users\mm\Documents\tdb\workspace\work_vagrant
λ vagrant ssh
Welcome to Ubuntu 17.10 (GNU/Linux 4.13.0-21-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


0 packages can be updated.
0 updates are security updates.


vagrant@vagrant:~$ exit
logout
Connection to 127.0.0.1 closed.