この記事は約42分12秒で読むことができます。

vagrantで.Vagrantフォルダ吹っ飛ばした時の話

まえがき

疲れていることもある。明日雨だから、ランしたけど、つかれたわ。勢いで消したわ。

参考文献

dhilst commented on 13 Apr 2018  

起動している仮想マシン確認

コード表示

[oracle@centos vx]$ vagrant up node1
Bringing machine 'node1' up with 'libvirt' provider...
Name `vx_node1` of domain about to create is already taken. Please try to run
`vagrant up` command again.
[oracle@centos vx]$ sudo virsh list --all
[sudo] oracle のパスワード:
 Id    名前                         状態
----------------------------------------------------
 57    vx_node3                       実行中
 58    vx_node1                       実行中
 59    vx_node5                       実行中
 60    vx_node6                       実行中
 61    vx_node4                       実行中
 62    vx_node2                       実行中

強制停止してundefineすればいい

コード表示

[oracle@centos vx]$ seq 6 | xargs -I@ bash -c 'sudo virsh destroy vx_node@ && sudo virsh undefine vx_node@'

状態確認

コード表示

[oracle@centos vx]$ sudo virsh list --all
 Id    名前                         状態
----------------------------------------------------

実はこれだけではまだいけぬ

boxイメージをvagrantアプリにマウントして使用しているけど、起動する仮想マシン分テンプレからコピーしている。こいつらも全部消してやるんだ。

コード表示

[oracle@centos vx]$ sudo virsh vol-list default
 名前               パス                                  
------------------------------------------------------------------------------
 centos-VAGRANTSLASH-7_vagrant_box_image_0.img /var/lib/libvirt/images/centos-VAGRANTSLASH-7_vagrant_box_image_0.img
 vx_node1.img         /var/lib/libvirt/images/vx_node1.img    
 vx_node2.img         /var/lib/libvirt/images/vx_node2.img    
 vx_node3.img         /var/lib/libvirt/images/vx_node3.img    
 vx_node4.img         /var/lib/libvirt/images/vx_node4.img    
 vx_node5.img         /var/lib/libvirt/images/vx_node5.img    
 vx_node6.img         /var/lib/libvirt/images/vx_node6.img    
[oracle@centos vx]$ sudo virsh vol-list default | awk '/vx/ {print $1}' | xargs -I@ bash -c 'sudo virsh vol-delete --pool default @'
ボリューム vx_node1.img は削除されました

ボリューム vx_node2.img は削除されました

ボリューム vx_node3.img は削除されました

ボリューム vx_node4.img は削除されました

ボリューム vx_node5.img は削除されました

ボリューム vx_node6.img は削除されました

[oracle@centos vx]$ sudo virsh vol-list default
 名前               パス                                  
------------------------------------------------------------------------------
 centos-VAGRANTSLASH-7_vagrant_box_image_0.img /var/lib/libvirt/images/centos-VAGRANTSLASH-7_vagrant_box_image_0.img

仮想マシン立ち上がるか確認

コード表示

[oracle@centos vx]$ vagrant up node1
Bringing machine 'node1' up with 'libvirt' provider...
==> node1: Creating image (snapshot of base box volume).
==> node1: Creating domain with the following settings...
==> node1:  -- Name:              vx_node1
==> node1:  -- Domain type:       kvm
==> node1:  -- Cpus:              1
==> node1:  -- Feature:           acpi
==> node1:  -- Feature:           apic
==> node1:  -- Feature:           pae
==> node1:  -- Memory:            2048M
==> node1:  -- Management MAC:    
==> node1:  -- Loader:            
==> node1:  -- Nvram:             
==> node1:  -- Base box:          centos/7
==> node1:  -- Storage pool:      default
==> node1:  -- Image:             /var/lib/libvirt/images/vx_node1.img (41G)
==> node1:  -- Volume Cache:      default
==> node1:  -- Kernel:            
==> node1:  -- Initrd:            
==> node1:  -- Graphics Type:     vnc
==> node1:  -- Graphics Port:     -1
==> node1:  -- Graphics IP:       127.0.0.1
==> node1:  -- Graphics Password: Not defined
==> node1:  -- Video Type:        cirrus
==> node1:  -- Video VRAM:        9216
==> node1:  -- Sound Type:	
==> node1:  -- Keymap:            en-us
==> node1:  -- TPM Path:          
==> node1:  -- INPUT:             type=mouse, bus=ps2
==> node1: Creating shared folders metadata...
==> node1: Starting domain.
==> node1: Waiting for domain to get an IP address...
==> node1: Waiting for SSH to become available...
    node1: 
    node1: Vagrant insecure key detected. Vagrant will automatically replace
    node1: this with a newly generated keypair for better security.
    node1: 
    node1: Inserting generated public key within guest...
    node1: Removing insecure key from the guest if it's present...
    node1: Key inserted! Disconnecting and reconnecting using new SSH key...
==> node1: Setting hostname...
==> node1: Configuring and enabling network interfaces...
    node1: SSH address: 192.168.121.83:22
    node1: SSH username: vagrant
    node1: SSH auth method: private key
==> node1: Rsyncing folder: /home/oracle/vx/ => /mnt
==> node1: Running provisioner: shell...
    node1: Running: /tmp/vagrant-shell20190607-1175-1kel8h.sh
    node1: Loaded plugins: fastestmirror
    node1: Determining fastest mirrors
    node1:  * base: ftp-srv2.kddilabs.jp
    node1:  * extras: ftp-srv2.kddilabs.jp
    node1:  * updates: ftp-srv2.kddilabs.jp
    node1: Resolving Dependencies
    node1: --> Running transaction check
    node1: ---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed
    node1: --> Finished Dependency Resolution
    node1: 
    node1: Dependencies Resolved
    node1: 
    node1: ================================================================================
    node1:  Package         Arch         Version                          Repository  Size
    node1: ================================================================================
    node1: Installing:
    node1:  net-tools       x86_64       2.0-0.24.20131004git.el7         base       306 k
    node1: 
    node1: Transaction Summary
    node1: ================================================================================
    node1: Install  1 Package
    node1: 
    node1: Total download size: 306 k
    node1: Installed size: 918 k
    node1: Downloading packages:
    node1: Public key for net-tools-2.0-0.24.20131004git.el7.x86_64.rpm is not installed
    node1: warning: /var/cache/yum/x86_64/7/base/packages/net-tools-2.0-0.24.20131004git.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    node1: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    node1: Importing GPG key 0xF4A80EB5:
    node1:  Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) "
    node1:  Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
    node1:  Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
    node1:  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    node1: Running transaction check
    node1: Running transaction test
    node1: Transaction test succeeded
    node1: Running transaction
    node1:   Installing : net-tools-2.0-0.24.20131004git.el7.x86_64                    1/1
    node1:  
    node1:   Verifying  : net-tools-2.0-0.24.20131004git.el7.x86_64                    1/1
    node1:  
    node1: 
    node1: Installed:
    node1:   net-tools.x86_64 0:2.0-0.24.20131004git.el7                                   
    node1: 
    node1: Complete!
    node1: Loaded plugins: fastestmirror
    node1: Loading mirror speeds from cached hostfile
    node1:  * base: ftp-srv2.kddilabs.jp
    node1:  * extras: ftp-srv2.kddilabs.jp
    node1:  * updates: ftp-srv2.kddilabs.jp
    node1: Resolving Dependencies
    node1: --> Running transaction check
    node1: ---> Package lsof.x86_64 0:4.87-6.el7 will be installed
    node1: --> Finished Dependency Resolution
    node1: 
    node1: Dependencies Resolved
    node1: 
    node1: ================================================================================
    node1:  Package         Arch              Version                Repository       Size
    node1: ================================================================================
    node1: Installing:
    node1:  lsof            x86_64            4.87-6.el7             base            331 k
    node1: 
    node1: Transaction Summary
    node1: ================================================================================
    node1: Install  1 Package
    node1: 
    node1: Total download size: 331 k
    node1: Installed size: 927 k
    node1: Downloading packages:
    node1: Running transaction check
    node1: Running transaction test
    node1: Transaction test succeeded
    node1: Running transaction
    node1:   Installing : lsof-4.87-6.el7.x86_64                                       1/1
    node1:  
    node1:   Verifying  : lsof-4.87-6.el7.x86_64                                       1/1
    node1:  
    node1: 
    node1: Installed:
    node1:   lsof.x86_64 0:4.87-6.el7                                                      
    node1: 
    node1: Complete!
    node1: Loaded plugins: fastestmirror
    node1: Loading mirror speeds from cached hostfile
    node1:  * base: ftp-srv2.kddilabs.jp
    node1:  * extras: ftp-srv2.kddilabs.jp
    node1:  * updates: ftp-srv2.kddilabs.jp
    node1: Resolving Dependencies
    node1: --> Running transaction check
    node1: ---> Package psmisc.x86_64 0:22.20-15.el7 will be installed
    node1: --> Finished Dependency Resolution
    node1: 
    node1: Dependencies Resolved
    node1: 
    node1: ================================================================================
    node1:  Package          Arch             Version                 Repository      Size
    node1: ================================================================================
    node1: Installing:
    node1:  psmisc           x86_64           22.20-15.el7            base           141 k
    node1: 
    node1: Transaction Summary
    node1: ================================================================================
    node1: Install  1 Package
    node1: 
    node1: Total download size: 141 k
    node1: Installed size: 475 k
    node1: Downloading packages:
    node1: Running transaction check
    node1: Running transaction test
    node1: Transaction test succeeded
    node1: Running transaction
    node1:   Installing : psmisc-22.20-15.el7.x86_64                                   1/1
    node1:  
    node1:   Verifying  : psmisc-22.20-15.el7.x86_64                                   1/1
    node1:  
    node1: 
    node1: Installed:
    node1:   psmisc.x86_64 0:22.20-15.el7                                                  
    node1: 
    node1: Complete!
    node1: Loaded plugins: fastestmirror
    node1: Loading mirror speeds from cached hostfile
    node1:  * base: ftp-srv2.kddilabs.jp
    node1:  * extras: ftp-srv2.kddilabs.jp
    node1:  * updates: ftp-srv2.kddilabs.jp
    node1: Resolving Dependencies
    node1: --> Running transaction check
    node1: ---> Package traceroute.x86_64 3:2.0.22-2.el7 will be installed
    node1: --> Finished Dependency Resolution
    node1: 
    node1: Dependencies Resolved
    node1: 
    node1: ================================================================================
    node1:  Package            Arch           Version                   Repository    Size
    node1: ================================================================================
    node1: Installing:
    node1:  traceroute         x86_64         3:2.0.22-2.el7            base          59 k
    node1: 
    node1: Transaction Summary
    node1: ================================================================================
    node1: Install  1 Package
    node1: 
    node1: Total download size: 59 k
    node1: Installed size: 92 k
    node1: Downloading packages:
    node1: Running transaction check
    node1: Running transaction test
    node1: Transaction test succeeded
    node1: Running transaction
    node1:   Installing : 3:traceroute-2.0.22-2.el7.x86_64                             1/1
    node1:  
    node1:   Verifying  : 3:traceroute-2.0.22-2.el7.x86_64                             1/1
    node1:  
    node1: 
    node1: Installed:
    node1:   traceroute.x86_64 3:2.0.22-2.el7                                              
    node1: 
    node1: Complete!
    node1: Loaded plugins: fastestmirror
    node1: Loading mirror speeds from cached hostfile
    node1:  * base: ftp-srv2.kddilabs.jp
    node1:  * extras: ftp-srv2.kddilabs.jp
    node1:  * updates: ftp-srv2.kddilabs.jp
    node1: Resolving Dependencies
    node1: --> Running transaction check
    node1: ---> Package bridge-utils.x86_64 0:1.5-9.el7 will be installed
    node1: --> Finished Dependency Resolution
    node1: 
    node1: Dependencies Resolved
    node1: 
    node1: ================================================================================
    node1:  Package               Arch            Version              Repository     Size
    node1: ================================================================================
    node1: Installing:
    node1:  bridge-utils          x86_64          1.5-9.el7            base           32 k
    node1: 
    node1: Transaction Summary
    node1: ================================================================================
    node1: Install  1 Package
    node1: 
    node1: Total download size: 32 k
    node1: Installed size: 56 k
    node1: Downloading packages:
    node1: Running transaction check
    node1: Running transaction test
    node1: Transaction test succeeded
    node1: Running transaction
    node1:   Installing : bridge-utils-1.5-9.el7.x86_64                                1/1
    node1:  
    node1:   Verifying  : bridge-utils-1.5-9.el7.x86_64                                1/1
    node1:  
    node1: 
    node1: Installed:
    node1:   bridge-utils.x86_64 0:1.5-9.el7                                               
    node1: 
    node1: Complete!
    node1: Loaded plugins: fastestmirror
    node1: Loading mirror speeds from cached hostfile
    node1:  * base: ftp-srv2.kddilabs.jp
    node1:  * extras: ftp-srv2.kddilabs.jp
    node1:  * updates: ftp-srv2.kddilabs.jp
    node1: Resolving Dependencies
    node1: --> Running transaction check
    node1: ---> Package expect.x86_64 0:5.45-14.el7_1 will be installed
    node1: --> Processing Dependency: libtcl8.5.so()(64bit) for package: expect-5.45-14.el7_1.x86_64
    node1: --> Running transaction check
    node1: ---> Package tcl.x86_64 1:8.5.13-8.el7 will be installed
    node1: --> Finished Dependency Resolution
    node1: 
    node1: Dependencies Resolved
    node1: 
    node1: ================================================================================
    node1:  Package         Arch            Version                    Repository     Size
    node1: ================================================================================
    node1: Installing:
    node1:  expect          x86_64          5.45-14.el7_1              base          262 k
    node1: Installing for dependencies:
    node1:  tcl             x86_64          1:8.5.13-8.el7             base          1.9 M
    node1: 
    node1: Transaction Summary
    node1: ================================================================================
    node1: Install  1 Package (+1 Dependent package)
    node1: 
    node1: Total download size: 2.1 M
    node1: Installed size: 4.9 M
    node1: Downloading packages:
    node1: --------------------------------------------------------------------------------
    node1: Total                                              1.1 MB/s | 2.1 MB  00:01     
    node1: Running transaction check
    node1: Running transaction test
    node1: Transaction test succeeded
    node1: Running transaction
    node1:   Installing : 1:tcl-8.5.13-8.el7.x86_64                                    1/2
    node1:  
    node1:   Installing : expect-5.45-14.el7_1.x86_64                                  2/2
    node1:  
    node1:   Verifying  : 1:tcl-8.5.13-8.el7.x86_64                                    1/2
    node1:  
    node1:   Verifying  : expect-5.45-14.el7_1.x86_64                                  2/2
    node1:  
    node1: 
    node1: Installed:
    node1:   expect.x86_64 0:5.45-14.el7_1                                                 
    node1: 
    node1: Dependency Installed:
    node1:   tcl.x86_64 1:8.5.13-8.el7                                                     
    node1: 
    node1: Complete!

あとがき

疲れた

Leave a Reply

Your email address will not be published. Required fields are marked *