当前位置:网站首页>Configure the firetracker process, i.e. stepping on the pit record
Configure the firetracker process, i.e. stepping on the pit record
2022-07-23 14:05:00 【LYSnowy】
Prerequisite
To configure firecracker The premise of is that the machine supports virtualization .
You can judge by the following commands , If the return is not 0 It supports
grep -E '(svm|vmx)' /proc/cpuinfo”
After you decide to support virtualization, you need to make kvm Have read and write permission .
sudo setfacl -m u:${
USER}:rw /dev/kvm
The configuration process
The whole process is based on github The above instruction manual is completed , Encountered a little problem in the process , But generally speaking, the problem is not big .
What I choose is not to build from the source code from scratch firecracker, Instead, I downloaded it directly github Provided firecracker Binary file , Direct operation .
First download the corresponding binary file and extract
release_url="https://github.com/firecracker-microvm/firecracker/releases"
latest=$(basename $(curl -fsSLI -o /dev/null -w %{
url_effective} ${
release_url}/latest))
arch=`uname -m`
curl -L ${
release_url}/download/${
latest}/firecracker-${
latest}-${
arch}.tgz \
| tar -xz
This command can be pasted and run directly in the command line or placed in shell Run... In file .
Then rename the downloaded file
mv release-${
latest}-$(uname -m)/firecracker-${
latest}-$(uname -m) firecracker
here firecracker The executable is ready , You can use the following commands to test whether it can run successfully .
./firecracker --version
The result of correct output is that firecracker Version of .
The next step is to firecracker Download under the folder where the executable program is located vm Of kernel and rootfs, I am a x86_64 System , Here is a direct link , You can also download through the command .
arch=`uname -m`
dest_kernel="hello-vmlinux.bin"
dest_rootfs="hello-rootfs.ext4"
image_bucket_url="https://s3.amazonaws.com/spec.ccfc.min/img/quickstart_guide/$arch"
if [ ${
arch} = "x86_64" ]; then
kernel="${image_bucket_url}/kernels/vmlinux.bin"
rootfs="${image_bucket_url}/rootfs/bionic.rootfs.ext4"
elif [ ${
arch} = "aarch64" ]; then
kernel="${image_bucket_url}/kernels/vmlinux.bin"
rootfs="${image_bucket_url}/rootfs/bionic.rootfs.ext4"
else
echo "Cannot run firecracker on $arch architecture!"
exit 1
fi
echo "Downloading $kernel..."
curl -fsSL -o $dest_kernel $kernel
echo "Downloading $rootfs..."
curl -fsSL -o $dest_rootfs $rootfs
echo "Saved kernel file to $dest_kernel and root block device to $dest_rootfs."
After downloading successfully, you can run , Need to be in firecracker Open two terminals under the folder , The first terminal executes the following commands :
First determine firecracker The port is not occupied
rm -f /tmp/firecracker.socket
And then run firecracker, At this time, the terminal will be stuck here waiting vm start-up
./firecracker --api-sock /tmp/firecracker.socket
Then at another terminal pair vm To configure , The first set kernel:
arch=`uname -m`
kernel_path=$(pwd)"/hello-vmlinux.bin"
if [ ${
arch} = "x86_64" ]; then
curl --unix-socket /tmp/firecracker.socket -i \
-X PUT 'http://localhost/boot-source' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d "{ \"kernel_image_path\": \"${
kernel_path}\", \"boot_args\": \"console=ttyS0 reboot=k panic=1 pci=off\" }"
elif [ ${
arch} = "aarch64" ]; then
curl --unix-socket /tmp/firecracker.socket -i \
-X PUT 'http://localhost/boot-source' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d "{ \"kernel_image_path\": \"${
kernel_path}\", \"boot_args\": \"keep_bootcon console=ttyS0 reboot=k panic=1 pci=off\" }"
else
echo "Cannot run firecracker on $arch architecture!"
exit 1
fi
here , If you download vmhello.bin and shell It's written in the document bin The following errors will appear when the names are different :the kernel file cannot be opened:No such file or directory 
The results of normal execution are as follows :
Then set the rootfs:
rootfs_path=$(pwd)"/hello-rootfs.ext4"
curl --unix-socket /tmp/firecracker.socket -i \
-X PUT 'http://localhost/drives/rootfs' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d "{ \"drive_id\": \"rootfs\", \"path_on_host\": \"${
rootfs_path}\", \"is_root_device\": true, \"is_read_only\": false }"
The same as above
Final run vm
curl --unix-socket /tmp/firecracker.socket -i \
-X PUT 'http://localhost/actions' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{ "action_type": "InstanceStart" }'
At this time, the following errors may appear :

This is because If another hypervisor like VMware or VirtualBox is running on the host and locks /dev/kvm, Firecracker process will fail to start with “Resource busy” error.
This issue can be resolved by terminating the other hypervisor running on the host, and allowing Firecracker to start.
Coincidentally, not long ago because of configuration minikube Just installed virtualbox, Ceaseless aapt remove After passage top Found a running virtualbox process , After stopping the process, it can run successfully .

The manual says that you need to enter a user name and password , If it's in github The download user name and password of the address indicated above are root, But I didn't ask me to enter my user name and password after running .
Then shut down in the virtual machine, just input reboot that will do .
You need to rm once socket, That is, the first command to run :
rm -f /tmp/firecracker.socket
Otherwise, the port will be occupied .
边栏推荐
- [ardunio] two methods to control the steering gear
- Unity makes simple intercepting close range artillery - how to predict the strike target
- LeetCode_ 2342_ Maximum sum of digits and equal pairs
- KingbaseES DENSE_ Rank function usage
- What's the difference between core i9 12950hx and i9 12900hx
- 基于OpenCV实现对图片及视频中感兴趣区域颜色识别
- 赛扬n5095处理器怎么样 英特尔n5095核显相当于什么水平
- LeetCode_ 491_ Longest increasing subsequence
- 赛扬N4000和赛扬N5095的区别
- GRE,MGRE的詳細了解;OSPF基礎配置知識
猜你喜欢

ERP production operation control

HCIA的复习

LeetCode_ 491_ Longest increasing subsequence

OSPF details (1)

OSPF详解(1)

The fourth operation

Thousands of databases, physical machines all over the country, JD logistics full volume cloud live record | interview with excellent technical team

酷睿i5 12490f和i5 12600k差距大吗

锐龙R7 PRO 6850H核显性能怎么样?相当于什么水平

天玑920相当于骁龙什么 天玑920相当于骁龙多少 天玑920怎么样
随机推荐
The fourth operation
图像处理6:顶层文件
CSDN recommended template
MGRE综合实验
Several methods of transferring parameters from child components to parent components
使用Stream流来进行分类展示。
Classes and objects (top)
mysql开启定时调度任务执行
KingbaseESV8R6不同隔离级下xmin的区别
LeetCode_ 51_ Queen n
数千个数据库、遍布全国的物理机,京东物流全量上云实录 | 卓越技术团队访谈录
Remove title block
京东云分布式链路追踪在金融场景的最佳实践
OSPF details (1)
Starfish OS:以现实为纽带,打造元宇宙新范式
小米12S Pro和小米12Pro天玑版区别 两者配置对比
excel随笔记录
Establish stm32f103c8t6 project template and STM32 st-link utility burn hex file
【微信小程序】案例 - 本地生活
rip的详细介绍