Category Archives: Linux

How to Decompress PetaLinux rootfs.cpio.gz with Script

Test environment: PetaLinux 2021.2

During development, it is often necessary to check the contents of the rootfs. Using the command, “gzip -d rootfs.cpio.gz”, “cpio -i < rootfs.cpio”, you can decompress the contents of rootfs.cpio.gz.
If you decompress frequently, you can use the following script to simplify the operation.

#!/bin/bash

echo -e "\nBegin to run script: $0"

# array definition, work for /bin/bash, does not work for /bin/sh
file_array_check=( 
bl31.bin
bl31.elf
BOOT.BIN
boot.scr
Image
image.ub
rootfs.cpio.gz
rootfs.manifest
system.dtb
u-boot.bin
u-boot.elf
vmlinux
)

# Get array elements number
file_array_check_length=${#file_array_check[@]}

# C-language style loop
# Check PetaLinux image/linux directory.
for (( i=0; i<$file_array_check_length; i++))
{
    CHECK_FILE=${file_array_check[i]}
    echo "Check No.$i directory: $CHECK_FILE";
    if [ ! -f  $CHECK_FILE ]; then 
        echo "Not PetaLinux project image directory. No file: $CHECK_FILE. "
        echo "Exit."
        exit 1
    fi 
}

mkdir -p rootfs
rm -rf ./rootfs/*
ls -l ./rootfs

cd rootfs
cp ../rootfs.cpio.gz ./
gzip -d rootfs.cpio.gz 
cpio -i < rootfs.cpio 
ls -l 

cd ../

[Solved] Failed to load the file C:\Users\Administrator\AppData\Roaming\npm\yarn.ps1, because script execution is prohibited in this system.

An error is reported after executing yarn install:

Unable to load file C:\Users\Administrator\AppData\Roaming\npm\yarn.ps1, because script execution is prohibited in this system.

Solution:

Runs PowerShell as administrator (Win7 location: C:\Windows\System32\WindowsPowerShell\v1.0)

Execution: set-ExecutionPolicy RemoteSigned

Centos7 View java-v Error [How to Solve]

[root@localhost ~]# java -v
Unrecognized option: -v
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

jdk1. 7 view the version number through java -V and java --version,
and jdk1 8 you have to check the version number through java -version

[Solved] Warning: World-writable config file ‘/etc/my.cnf’ is ignored

Today, use the shell to log in to MySQL directly, and the error is as follows

liup@ubuntu :~$ mysql
Warning: World-writable config file ‘/etc/mysql/my. cnf’ is ignored
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

‘/etc/my.cnf’ is ignored, which probably means that the permissions are globally writable and any user can write. mysql is worried about such files being maliciously modified by other users, so it ignores this configuration file. This makes it inaccessible, which is one of mysql’s security mechanisms. So we have to change some permissions. Set other users not writeable.

The shell is as follows

chmod 644 /etc/my.cnf

Then execute:

service mysql restart

[Solved] docker nginx localhost connection refused connect() failed (111: Connection refused)while connecting to upstream

problem

Visit nginx 502 bad gateway

connect() failed (111: Connection refused)while connecting to upstream

Possible causes 1 docker network problems

The bridge used by docker nginx container (default), and the forwarded service and nginx are on the same machine, but not in the same container, and nginx.conf proxy_pass  is localhost/127.0.0.1

Solution 1:

proxy_pass use intranet (starting with 172/10)/public address IP addr view the address of the machine.

Solution 2:

When starting the nginx container, use --net=host to specify the same network as the host.

docker run --name some-nginx --net=host -v /home/docker/nginx:/etc/nginx -v /home/docker/nginx/logs:/opt/app/logs -d nginx

Possible question 2 is the service started or not?

Make sure the service starts normally docker ps check whether the service exists;

Ensure proxy_ The port of pass is consistent with the service port being forwarded. Use telnet IP port to test

Possible question 3: is the port open

For ECS, if the proxy address is not the local IP address, please open the corresponding port in the corresponding security policy

[Solved] Linux-SSH: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

Linux-SSH:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED solution:

ssh 192.168.21.53:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:1
RSA host key for 192.168.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.

First input more ~/.ssh/known_hosts
You will see the following content:
… … … …
192.168.21.53 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQ25kqKE1uT7wtcaFp3zFSMxpwweif0YcKMNmpp4Alql/ZmPHaS/fI1dmXxyzq77wj8uXJgkh7xF0doyFeBk1c8D7jG/5SkAdpwlh6uixYEI3SlRY96InnQd/zEqRGjMvwoEcSmdMdkRsrK5EkPblhDfsQgc5RwKJpkQ+GWXM7oibHZB/P/G2Husnwb0rSwIRvUkwfamM9wDBtA3nEZLcG6wScwm2sZ8SwL9eJMNJXRHR90vewQ6MVrv+k5kB+BSrJ92TH8uZP3R9oO4X6tvRKNZOubQJqKqPDujVrTCD9XnMDb+Mx0yKMqvoGoVBM7fnZMGWtTHBkacsyYSiXaJrV
vi ~/.ssh/known_hosts, edit this file, delete the content beginning with 192.168.21.53, :wq! save and exit can be.

Cause Analysis:
It is also possible that a host key has just been changed.

[Solved] Ubuntu 18.04 Compile opencv-3.4.16 Error: “c++: internal compiler error: Killed (program cc1plus)”

Ubuntu 18.04 compiles opencv-3.4.16 with the command “make – J” and encounters the error “C + +: internal compiler error: killed (program cc1plus)”. In the system, there are 8 CPUs and 32GB memory, and 83 cc1plus processes are found. Check the help information of make, “- j [n], — jobs [= n] allow n jobs at once; infinite jobs with no arg.”, If there are no parameters, an unlimited number of worker processes are used. The previous command “make – J” can be compiled successfully on a 128GB server.

According to the following commands provided by C + +: internal compiler error, increase the switching space to 8GB. The same problem still exists.

#The size of count is the size of the increased swap space, 1M is the block size, so the space size is bs*count=8192MB
sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 
# format the space into swap format just now
sudo mkswap /swapfile 
chmod 0600 /swapfile  
#Use the swap space you just created
sudo swapon /swapfile

After increasing the size of swap space, the space of KIB swap listed by the top command increases.

~/proj/slam$ top
top - 11:25:12 up 23:59,  7 users,  load average: 24.55, 70.32, 66.93
Tasks: 495 total,  19 running, 400 sleeping,   0 stopped,   0 zombie
%Cpu(s): 95.5 us,  4.4 sy,  0.1 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 32760356 total, 28245364 free,  3986600 used,   528392 buff/cache
KiB Swap:  9392120 total,  8107088 free,  1285032 used. 28321152 avail Mem

Then use the command “make – J 16” to recompile and complete the task successfully.

Some information in case of error is as follows:

[ 96%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_resize_bitexact.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_smooth_bitexact.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_templmatch.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_thresh.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_subdivision2d.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_watershed.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/videoio/CMakeFiles/opencv_test_videoio.dir/build.make:110: recipe for target 'modules/videoio/CMakeFiles/opencv_test_videoio.dir/test/test_ffmpeg.cpp.o' failed
make[2]: *** [modules/videoio/CMakeFiles/opencv_test_videoio.dir/test/test_ffmpeg.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/core/CMakeFiles/opencv_perf_core.dir/build.make:590: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/perf/perf_math.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/perf/perf_math.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
modules/videoio/CMakeFiles/opencv_test_videoio.dir/build.make:62: recipe for target 'modules/videoio/CMakeFiles/opencv_test_videoio.dir/test/test_camera.cpp.o' failed
make[2]: *** [modules/videoio/CMakeFiles/opencv_test_videoio.dir/test/test_camera.cpp.o] Error 4
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/calib3d/CMakeFiles/opencv_test_calib3d.dir/build.make:494: recipe for target 'modules/calib3d/CMakeFiles/opencv_test_calib3d.dir/test/test_fisheye.cpp.o' failed
make[2]: *** [modules/calib3d/CMakeFiles/opencv_test_calib3d.dir/test/test_fisheye.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
modules/objdetect/CMakeFiles/opencv_objdetect.dir/build.make:212: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/qrcode.cpp.o' failed
make[2]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/qrcode.cpp.o] Error 4
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
CMakeFiles/Makefile2:3434: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/all' failed
make[1]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/core/CMakeFiles/opencv_perf_core.dir/build.make:110: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_bufferpool.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_bufferpool.cpp.o] Error 4
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.