Ubuntu 管理心得

搜尋此網誌

顯示具有 raspbian 標籤的文章。 顯示所有文章
顯示具有 raspbian 標籤的文章。 顯示所有文章

2023年12月26日 星期二

Check Pi Camera connected

sudo vcgencmd get_camera

If exists:
    supported=1 detected=1, libcamera interfaces=0

else
    supported=0 detected=0, libcamera interfaces=0


2023年12月11日 星期一

pi raspbian backup system

Browse the link: Image File Utilities
Download image-utils.zip

  1. Unzip image-utils.zip to ~/image-copy
  2. cd ~/image-copy
  3. Create shell script, mkpi4.sh from dash line to dash line:
    ----------------------------------------------------------------------
    #!/bin/bash
    if [ "$#" -lt 1 ]; then
        echo "Usage: $0 <path>"
        exit
    fi

    prefix=$1
    IMG=$(date +pi4_bookworm_%Y%m%d.img)
    START=$(date +%F\ %T)
    sudo /bin/bash /home/chiao/image-copy/image-backup --initial $prefix/$IMG,,1000 -o -P,--exclude-from=/home/chiao/image-copy/exclude.txt
    echo "Start:  $START"
    echo "End: $(date +%F\ %T)"
    ----------------------------------------------------------------------
  4. sudo mount -t nfs 192.168.1.2:/BACKUP-nvme1n1p2/pi4 /mnt/nfs
  5. sudo ./mkpi4.sh /mnt/nfs
  6. Wait ...
 



 

 

 


2023年10月28日 星期六

mouse slow and sticky lag

 cf: https://forums.raspberrypi.com/viewtopic.php?t=84999

Append 
 
usbhid.mousepoll=0 
 
to /boot/cmdline.txt in the same line separated from the other stuff by spaces


2023年5月4日 星期四

Too many "EDID block 0 is all zeroes" in syslog

Turn off hdmi at bootup.

sudo raspi-config

1. System Options -> S5 Boot -> B1 Console

Click 確定

done.

Too many "dhcpcd[469]: wlan0: received approval" in syslog

 cf: https://forums.raspberrypi.com/viewtopic.php?t=265516

Edit /etc/dhcpcd.conf:

interface wlan0
#chiao, 2023-5-5
#inform 192.168.1.14
static ip_address=192.168.1.14
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
static domain_search=61.31.1.1

2023年3月18日 星期六

Install phpmyadmin on pi raspbian bullseye

 cf: http://linux.how2shout.com/how-to-install-phpmyadmin-on-debian-11-bullseye-apache/

  1. sudo apt -y install php-cgi php-mysqli php-pear php-mbstring libapache2-mod-php php-common php-phpseclib php-mysql
  2. wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
  3. sudo tar xvf phpMyAdmin-latest-all-languages.tar.gz
  4. sudo mv phpMyAdmin-*-all-languages/ /var/www/html/phpmyadmin
  5. cd /var/www/html
    sudo cp phpmyadmin/config.sample.inc.php phpmyadmin/config.inc.php
  6. sudo mkdir /var/www/html/phpmyadmin/tmp
  7. openssl rand -base64 32
    (copy the output key)
  8. sudo vim /var/www/html/phpmyadmin/config.inc.php
  9. Put the key in Step 6 into:
    $cfg[‘blowfish_secret’] = ‘your-key‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
  10. And add this line:
    $cfg['TempDir'] = '/var/www/html/phpmyadmin/tmp';
  11. sudo chown -R www-data:www-data /var/www/html/phpmyadmin
  12. sudo vim /etc/apache2/conf-available/phpmyadmin.conf
  13. Add the followings:
    Alias /phpmyadmin /var/www/html/phpmyadmin

    <Directory /var/www/html/phpmyadmin/>
       AddDefaultCharset UTF-8
       <IfModule mod_authz_core.c>
              <RequireAny>
          Require all granted
         </RequireAny>
       </IfModule>
    </Directory>

    <Directory /var/www/html/phpmyadmin/setup/>
       <IfModule mod_authz_core.c>
         <RequireAny>
           Require all granted
         </RequireAny>
       </IfModule>
    </Directory>
  14. sudo a2enconf phpmyadmin.conf
  15. sudo systemctl restart apache2

php stuff in pi4

  1. sudo apt purge php*
  2. sudo apt install php8.0
  3. sudo apt install php8.0-mysql
    sudo apt install php8.0-dom
    sudo apt install php8.0-mbstring
    sudo apt install php8.0-fpm
    sudo apt install php8.0-pear
    sudo apt install php-pear

2023年2月27日 星期一

After certbot installed and renew

cf: https://pimylifeup.com/raspberry-pi-ssl-lets-encrypt/

Some settings about firewall:

  1. sudo vim /etc/arno-iptables-firewall/conf.d/00debconf.conf,
    add 443 for OPEN_TCP and OPEN_UDP
  2. Add 443 port forward in wifi web page
  3. Two more things:
    sudo a2enmod ssl
    sudo a2ensite default-ssl
  4. If it can be connected but shows secure error try this again:
    sudo certbot --apache

 IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/kpchiao9600k.sino.tw/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/kpchiao9600k.sino.tw/privkey.pem
   Your cert will expire on 2023-05-29. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Run this to update certificaion:

sudo certbot certonly --standalone -d example.com -d www.example.com

2022年11月17日 星期四

mount image img file

 cf: https://coldnew.github.io/ff159f7c/

  1. sudo fdisk -u -l pi3_20221116.img
    The outputs are
    ...
    所用裝置          可開機  Start     結束     磁區  Size Id 類型
    pi3_20221116.img1          8192   532480   524289  256M  c W95 FAT32 (LBA)
    pi3_20221116.img2        540672 30881791 30341120 14.5G 83 Linux

    Get the Start block 540672 for partition 2
  2. sudo mount -o loop,offset=$((540672 * 512)) pi3_20221116.img /mnt/myimg

The script file: (cf: https://github.com/AlexanderAmelkin/mountimg/blob/master/mountimg

#!/bin/bash
IMAGE="$1"
PART="$2"
WHERE="$3"
shift 3

OPTIONS="$*"

if [ ! -f "$IMAGE" ] || [ -z "$PART" ] || [ -z "$WHERE" ]; then
    echo "Disk image partition mounter by Alexander Amelkin."
    echo "Version 1.0"
    echo
    echo "Usage: mountimg <image> <partition> <where> [<mount options>]"
    echo "Example: mountimg sdcard.img 1 /mnt/sdcard0p1 -t vfat -o ro,codepage=866,iocharset=utf-8"
    exit 1
fi

# Now find the first unused loop device and use it
OFFSET=$(
    sfdisk -l $IMAGE |
    grep $IMAGE$PART |
    awk 'BEGIN { FS="[ *\t]+"}
         /.+/ { print $2; found=1 }
         END { if(!found) exit 1 }'
    ) || { echo "No such partition in the image"; exit 1; }

echo "Mounting $IMAGE partition $PART (offset $OFFSET) to $WHERE via $LODEV"

set -e

mount $OPTIONS -o loop,offset=$((OFFSET * 512)) $IMAGE $WHERE

2022年10月22日 星期六

Safely power off USB drive

  1. Umount all: e.g
    sudo umount /media/pi/ntfs_1TB
    sudo umount /media/pi/ext4_1.7TB
    sudo umount /media/pi/ext4_1TB
  2. sudo udisksctl power-off -b /dev/sda

2022年6月12日 星期日

Disable motion service

sudo update-rc.d motion disable
 

2022年2月6日 星期日

nmcli set static IP

  1. 執行: sudo  nmcli connection show 會出現下列:
    NAME            UUID                                  TYPE      DEVICE
    有線連線 1      7b62be74-2e0d-32e4-a08e-37a47c33d699  ethernet  eth0
    chiao-dlink842  710e0af6-9b51-455d-9b11-aac2091a2c87  wifi      --   
  2. 修改為 192.168.1.12 IP, 指令如下:
    sudo nmcli connection modify "有線連線 1" ipv4.addresses 192.168.1.12/24 ipv4.gateway 192.168.1.1 ipv4.gateway 192.168.1.1 ipv4.method manual
  3. sudo systemctl restart NetworkManager

eth0 ethernet 不受管理

cf: https://superuser.com/questions/1429490/unmanaged-network-manager-in-ubuntu

 

This works for my ubuntu 20.04.3 at pi4.

As root, edit /etc/NetworkManager/NetworkManager.conf to match the following. You can use the command sudo nano /etc/NetworkManager/NetworkManager.conf to do so.

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=true

[keyfile]
unmanaged-devices=*,except:type:wifi,except:type:gsm,except:type:cdma,except:type:wwan,except:type:ethernet,except:type:vlan

[device]
wifi.scan-rand-mac-address=no

2022年1月18日 星期二

vnc for preview using raspistill

  1. Click top right VNC icon:
  2. Click the top right setting in VNC server windows:
  3. Select Options:
  4. In Options window, select Troubleshooting:

  5. Turn on  Enable direct capture mode :
  6. Done.

網誌存檔