0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

vagrant virtualbox で rockylinux8 を実行する

Posted at

virtualbox + rhel9 はまだ出来ないっぽい(Hyper-Vだと出来るらしいが windows home では対象外)ので rocky linux 8 を実行する

Vagrantfile

rockylinux/8 のボックスを使う
https://app.vagrantup.com/rockylinux/boxes/8

Vagrant.configure("2") do |config|
  config.vm.box = "rockylinux/8"
  # config.vm.network "forwarded_port", guest: 80, host: 8080
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
  # config.vm.network "private_network", ip: "192.168.56.12"
  config.vm.synced_folder ".", "/vagrant", type:"virtualbox"
  config.vm.disk :disk, size: "10GB", primary: true
  # config.vm.network "public_network"
  config.vm.provider "virtualbox" do |vb|
    #   vb.gui = true
    vb.memory = "2048"
  end
  #if Vagrant.has_plugin?("vagrant-vbguest")
  #  config.vbguest.auto_update = false  
  #end  
  config.omnibus.chef_version = :latest
  config.vm.provision "chef_zero" do |chef|
    chef.install = false
    chef.cookbooks_path = ["chef-repo/cookbooks", "chef-repo/site-cookbooks"]
    chef.nodes_path = ["chef-repo/nodes"]
    chef.node_name = "server"
    chef.arguments = "--chef-license accept"
  end

end

provisionまで書いてはいるけどそれは別途。

起動

PS> vagrant up

これで本来ならサクッと起動して即利用可能のはずなのだが、VBoxGuestAddition の要求が変なのかなんなのか、共有フォルダの設定とかうまくいかない。

それと rockylinux/8 はVMのディスクサイズが5G なのであれやこれやと追加パッケージをインストールするとあっという間に Disk Full でどうにもならなくなるので以下で対応する

ディスクサイズを拡張する

VMのディスクサイズを拡張する

Vagrantfile でディスクサイズを指定する

  config.vm.disk :disk, size: "10GB", primary: true

vagrant のお試し機能を利用してディスクサイズを拡張する

PS> $env:VAGRANT_EXPERIMENTAL="disks"
PS> vagrant up

ボックスによっては上記だけでゲストの内側からのサイズが拡張されていて直ぐに利用可能なのだけど、今回の組み合わせでは駄目らしいのでゲストにログインしてパーティションサイズを変更したりする

パーティションサイズを拡張する

ゲストにログインして

PS> vagrant ssh

parted を使用してパーティションサイズを変更する

[vagrant@localhost ~]$ sudo parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  5369MB  5368MB  primary  xfs          boot

(parted) unit s
(parted) resize
resize      resizepart
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 20971520s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End        Size       Type     File system  Flags
 1      2048s  10485759s  10483712s  primary  xfs          boot

(parted) resizepart 1 20971519
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? yes
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 20971520s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End        Size       Type     File system  Flags
 1      2048s  20971519s  20969472s  primary  xfs          boot

(parted)

(parted) がプロンプトとなるので、help とか入力して使い方を調べられる。

XFS領域を拡張する

[vagrant@localhost ~]$ sudo xfs_growfs /dev/sda1
meta-data=/dev/sda1              isize=512    agcount=4, agsize=327616 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=1310464, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1310464 to 2621184
[vagrant@localhost ~]$ df -l
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs          994600       0    994600   0% /dev
tmpfs            1012196       0   1012196   0% /dev/shm
tmpfs            1012196   16732    995464   2% /run
tmpfs            1012196       0   1012196   0% /sys/fs/cgroup
/dev/sda1       10474496 3628528   6845968  35% /
tmpfs             202436       0    202436   0% /run/user/1000

df で / が拡張されたのを確認しておく。

VBoxGuestAddition が要求するライブラリをインストールする

色々と足らないモノがあるのでインストールする

sudo dnf install -y wget
sudo dnf install -y epel-release
sudo dnf -y update
sudo dnf -y update kernel && sudo dnf -y install kernel-devel kernel-headers make bzip2 gcc
sudo dnf install -y elfutils-libelf-devel
sudo dnf install -y libX11
sudo dnf install -y libXt
sudo dnf install -y libXext
sudo dnf install -y libXmu

再起動

PS> vagrant reload

とか。
時々reload も失敗することがある。あきらめずに vagrant halt vagrant uup とかするときれいに実行される

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?