Vagrant啟動自己編譯的內核

上一篇為Guest Ubuntu編譯內核我們?yōu)閂agrant的Guest Ubuntu編譯了內核,現(xiàn)在我們要在Vagrant的Guest OS中安裝,并啟動自己的內核。

root@ubuntu:~/vagrant# vagrant up
root@ubuntu:~/vagrant# vagrant ssh

# Guest Ubuntu shell
vagrant@ubuntu-xenial:~$ cd /vagrant/obj/
vagrant@ubuntu-xenial:~/vagrant/obj/$  ls -lah  --time-style='+'  *.deb
-rw-r--r-- 1 vagrant vagrant  11M  linux-headers-4.16.0+_4.16.0+-1_amd64.deb
-rw-r--r-- 1 vagrant vagrant  50M  linux-image-4.16.0+_4.16.0+-1_amd64.deb
-rw-r--r-- 1 vagrant vagrant 490M  linux-image-4.16.0+-dbg_4.16.0+-1_amd64.deb
-rw-r--r-- 1 vagrant vagrant 967K  linux-libc-dev_4.16.0+-1_amd64.deb

我們現(xiàn)在只需要安裝linux-image和linux-headers,

vagrant@ubuntu-xenial:~/vagrant/obj/$  sudo dpkg -i  ./linux-image*.deb 
vagrant@ubuntu-xenial:~/vagrant/obj/$  sudo dpkg -i  ./linux-headers*.deb 

裝好以后,就可以重新啟動新的內核了,到Host Ubuntu的Shell中:

root@ubuntu:~/vagrant# vagrant reload

重啟之后,再進入Guest Ubuntu驗證內核版本:

root@ubuntu:~/vagrant# vagrant ssh
vagrant@ubuntu-xenial:~$  uname -r
4.16.0+
vagrant@ubuntu-xenial:~$  ls /vagrant

可以看到已經(jīng)是新的內核了,但是共享目錄/vagrant是空的,這是因為新的內核中還沒有安裝VirtualBox Guest Additions,首先我們要在Host中驗證VirtualBox的版本號:

root@ubuntu:~/vagrant#  vboxmanage --version
5.1.34_Ubuntur121010

然后到這里下載相同版本的Guest Additions,我的版本是5.1.34,在Guest Ubuntu中,下載并安裝:

vagrant@ubuntu-xenial:~$ wget http://download.virtualbox.org/virtualbox/5.1.34/VBoxGuestAdditions_5.1.34.iso
vagrant@ubuntu-xenial:~$ sudo mount -o loop ./VBoxGuestAdditions_5.1.34.iso /mnt/
vagrant@ubuntu-xenial:~$ sudo /mnt/VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.34 Guest Additions for Linux...........
VirtualBox Guest Additions installer
This system appears to have a version of the VirtualBox Guest Additions
already installed.  If it is part of the operating system and kept up-to-date,
there is most likely no need to replace it.  If it is not up-to-date, you
should get a notification when you start the system.  If you wish to replace
it with this version, please do not continue with this installation now, but
instead remove the current version first, following the instructions for the
operating system.

If your system simply has the remains of a version of the Additions you could
not remove you should probably continue now, and these will be removed during
installation.

Do you wish to continue? [yes or no]
yes
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.

安裝完成以后,重啟Guest Ubuntu,然后看到Mounting shared folders...不報錯,就說明共享目錄可以訪問了。

root@ubuntu:~/vagrant# vagrant reload
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /root/vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
root@ubuntu:~/vagrant# vagrant ssh

下一篇介紹如何用kgdb調試這個內核。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容