欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

binfmt_misc/qemu-user-static misc

程序员文章站 2022-03-03 21:01:13
...

Install Refer to 

Qemu2.x user mode/Ubuntu18 for Chroot/ARM qemu-user-static/CONFIG_BINFMT_MISC/Ubuntu/ARM/Rootfs

https://blog.csdn.net/hushui/article/details/103791704 

Qemu4 user mode source build/static for Chroot/ARM rootfs on Ubuntu18

https://blog.csdn.net/hushui/article/details/103806109

On Centos7/RHEL7   qemu-user-static(v4.2) are built from source. (Refer to https://blog.csdn.net/hushui/article/details/103806109

Note for Centos7/RHEL7 , static lib files are needed!

 yum install gtk2-devel   glib2-static   
  yum install glibc-static libtool 
 yum install zlib-static 
 yum install    libstdc++-static  
 yum install pcre-static 

--disable-guest-agent if Centos misses some pixman static lib 

[[email protected]_centos7 qemu-4.2.0]$  ./configure  --target-list=aarch64-linux-user,arm-linux-user  --enable-debug  --prefix=$HOME/usr    --static  --disable-system    --enable-linux-user     --disable-guest-agent

Qemu/static build/old way 
 

../configure --disable-bsd-user --disable-guest-agent --disable-strip --disable-werror --disable-gcrypt --disable-debug-info --disable-debug-tcg --enable-docs --disable-tcg-interpreter --enable-attr --disable-brlapi --disable-linux-aio --disable-bzip2 --disable-bluez --disable-cap-ng --disable-curl --disable-fdt --disable-glusterfs --disable-gnutls --disable-nettle --disable-gtk --disable-rdma --disable-libiscsi --disable-vnc-jpeg --disable-kvm --disable-lzo --disable-curses --disable-libnfs --disable-numa --disable-opengl --disable-vnc-png --disable-rbd --disable-vnc-sasl --disable-sdl --disable-seccomp --disable-smartcard --disable-snappy --disable-spice --disable-libssh2 --disable-libusb --disable-usb-redir --disable-vde --disable-vhost-net --disable-virglrenderer --disable-virtfs --disable-vnc --disable-vte --disable-xen --disable-xen-pci-passthrough --disable-xfsctl --enable-linux-user --disable-system --disable-blobs --disable-tools --target-list=arm-linux-user --static --disable-pie

> qemu-arm version 4.2.0

 

1. Enable/disable by /proc/sys/fs/binfmt_misc/status

 

[[email protected]_centos7 nfs]# ls /proc/sys/fs/binfmt_misc/
register  status
[[email protected]_centos7 nfs]# cat /proc/sys/fs/binfmt_misc/status
enabled
[[email protected]_centos7 nfs]# cat /proc/sys/fs/binfmt_misc/register
cat: /proc/sys/fs/binfmt_misc/register: Invalid argument

 

2.  qemu-aarch64  magic number 


###  try  qemu-aarch64
[[email protected]_centos7 nfs]# sudo echo ":qemu-aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64:" > /proc/sys/fs/binfmt_misc/register
[[email protected]_centos7 nfs]# cat /proc/sys/fs/binfmt_misc/status ^C                                                       [[email protected]_centos7 nfs]# ls -l  /proc/sys/fs/binfmt_misc/
total 0
-rw-r--r-- 1 root root 0 Jul 17 01:33 qemu-aarch64
--w------- 1 root root 0 Jul 17 01:33 register
-rw-r--r-- 1 root root 0 Jul 17 01:32 status
[[email protected]_centos7 nfs]# cat  /proc/sys/fs/binfmt_misc/qemu-aarch64
enabled
interpreter /usr/bin/qemu-aarch64
flags:
offset 0
magic 7f454c460201010000000000000000000200b700
mask ffffffffffffff00fffffffffffffffffeffffff
[[email protected]_centos7 nfs]#


echo 0 > /proc/sys/fs/binfmt_misc/<name>    # Disable the match
echo 1 > /proc/sys/fs/binfmt_misc/<name>    # Enable the match
echo -1 > /proc/sys/fs/binfmt_misc/<name>   # Delete the match


[[email protected]_centos7 nfs]# echo 0 > /proc/sys/fs/binfmt_misc/qemu-aarch64
[[email protected]_centos7 nfs]# cat  /proc/sys/fs/binfmt_misc/qemu-aarch64
disabled
interpreter /usr/bin/qemu-aarch64
flags:
offset 0
magic 7f454c460201010000000000000000000200b700
mask ffffffffffffff00fffffffffffffffffeffffff
[[email protected]_centos7 nfs]# echo -1  > /proc/sys/fs/binfmt_misc/qemu-aarch64
[[email protected]_centos7 nfs]# cat  /proc/sys/fs/binfmt_misc/qemu-aarch64
cat: /proc/sys/fs/binfmt_misc/qemu-aarch64: No such file or directory
[[email protected]_centos7 nfs]# ls -l   /proc/sys/fs/binfmt_misc
total 0
--w------- 1 root root 0 Jul 17 01:33 register
-rw-r--r-- 1 root root 0 Jul 17 01:32 status
[[email protected]_centos7 nfs]#

3. qemu-arm


[[email protected]_centos7 nfs]# echo ':qemu-arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register
[[email protected]_centos7 nfs]#
###################  Name 

echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-wrapper:' > /proc/sys/fs/binfmt_misc/register
==>   /proc/sys/fs/binfmt_misc/arm
 
echo ':qemu-arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register
==>   /proc/sys/fs/binfmt_misc/qemu-arm

#####################

[[email protected]_centos7 nfs]#
[[email protected]_centos7 nfs]# cat  /proc/sys/fs/binfmt_misc/qemu-arm
enabled
interpreter /usr/bin/qemu-arm
flags:
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff00fffffffffffffffffeffffff
[[email protected]_centos7 nfs]# sudo echo ":qemu-aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64:" > /proc/sys/fs/binfmt_misc/register
[[email protected]_centos7 nfs]# ls -l     /proc/sys/fs/binfmt_misc/
total 0
-rw-r--r-- 1 root root 0 Jul 17 01:38 qemu-aarch64
-rw-r--r-- 1 root root 0 Jul 17 01:37 qemu-arm
--w------- 1 root root 0 Jul 17 01:38 register
-rw-r--r-- 1 root root 0 Jul 17 01:32 status
[[email protected]_centos7 nfs]#

 

 

4.  Mount Ubuntu ARM ROOTFS on Intel X86_64 

 

Refer to https://blog.csdn.net/hushui/article/details/103791704 

相关标签: Qemu Linux ARM