§2023-08-24

¶Step 1. /etc/fstab

(chroot) hc4Gentoo / # blkid
/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL_FATBOOT="BOOT_MNJRO" LABEL="BOOT_MNJRO" UUID="DDBA-9480" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="6319cfe2-01"
/dev/mmcblk0p2: LABEL="ROOT_MNJRO" UUID="c116cbd4-ed1c-408d-88c7-6901ccb65d60" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="6319cfe2-02"
/dev/sda4: PARTUUID="69ed71c7-04"
/dev/sda2: UUID="f4e47b4d-3ecc-4e27-83ec-4b9aafa71882" TYPE="swap" PARTUUID="69ed71c7-02"
/dev/sda3: UUID="0eec5082-3336-4c1d-be70-2a9e34a8fd2d" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="69ed71c7-03"
/dev/sda1: SEC_TYPE="msdos" UUID="F63A-4702" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="69ed71c7-01"
/dev/zram0: LABEL="zram0" UUID="71f971f6-e6b3-4a5f-96e0-143c479f5630" TYPE="swap"
# /etc/fstab: static file system information.

# <fs>                  <mountpoint>    <type>          <opts>          <dump> <pass>

# /boot
UUID=F63A-4702                                  /boot           vfat            defaults,noexec,nodev,showexec          0 0

# swap
UUID=f4e47b4d-3ecc-4e27-83ec-4b9aafa71882       none            swap            sw                                      0 0             

# /
UUID=0eec5082-3336-4c1d-be70-2a9e34a8fd2d       /               ext4            defaults                                0 1  

# /dev/sda2: UUID="f4e47b4d-3ecc-4e27-83ec-4b9aafa71882" TYPE="swap" PARTUUID="69ed71c7-02"
# /dev/sda3: UUID="0eec5082-3336-4c1d-be70-2a9e34a8fd2d" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="69ed71c7-03"
# /dev/sda1: SEC_TYPE="msdos" UUID="F63A-4702" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="69ed71c7-0

¶Step 2. emerge app-admin/sudo

(chroot) hc4Gentoo / # emerge --search  sudo
  
[ Results for search key : sudo ]
Searching...

*  app-admin/sud [ Masked ]
      Latest version available: 1.3-r2
      Latest version installed: [ Not Installed ]
      Size of files: 115 KiB
      Homepage:      http://www.s0ftpj.org/projects/sud/index.htm
      Description:   A daemon to execute processes with special privileges in a nosuid environment
      License:       BSD

*  app-admin/sudo
      Latest version available: 1.9.14_p2
      Latest version installed: [ Not Installed ]
      Size of files: 5108 KiB
      Homepage:      https://www.sudo.ws/
      Description:   Allows users or groups to run commands as other users
      License:       ISC BSD

*  app-vim/sudoedit
      Latest version available: 0.21
      Latest version installed: [ Not Installed ]
      Size of files: 13 KiB
      Homepage:      https://www.vim.org/scripts/script.php?script_id=2709 https://github.com/chrisbra/SudoEdit.vim
      Description:   vim plugin: edit files using sudo or su
      License:       vim

*  games-puzzle/gnome-sudoku
      Latest version available: 44.0
      Latest version installed: [ Not Installed ]
      Size of files: 383 KiB
      Homepage:      https://wiki.gnome.org/Apps/Sudoku https://gitlab.gnome.org/GNOME/gnome-sudoku
      Description:   Test your logic skills in this number grid puzzle
      License:       GPL-3+ CC-BY-SA-3.0

*  kde-apps/ksudoku
      Latest version available: 23.04.3
      Latest version installed: [ Not Installed ]
      Size of files: 1663 KiB
      Homepage:      https://apps.kde.org/ksudoku/
      Description:   Logic-based symbol placement puzzle by KDE
      License:       GPL-2

*  lxqt-base/lxqt-sudo
      Latest version available: 1.3.0
      Latest version installed: [ Not Installed ]
      Size of files: 37 KiB
      Homepage:      https://lxqt-project.org/
      Description:   LXQt GUI frontend for sudo
      License:       LGPL-2.1 LGPL-2.1+

*  sec-keys/openpgp-keys-sudo
      Latest version available: 20220321
      Latest version installed: [ Not Installed ]
      Size of files: 6 KiB
      Homepage:      https://www.sudo.ws/
      Description:   OpenPGP keys used by the sudo project
      License:       public-domain

*  sec-policy/selinux-sudo
      Latest version available: 2.20221101-r4
      Latest version installed: [ Not Installed ]
      Size of files: 1017 KiB
      Homepage:      https://wiki.gentoo.org/wiki/Project:SELinux
      Description:   SELinux policy for sudo
      License:       GPL-2

[ Applications found : 8 ]

(chroot) hc4Gentoo / # emerge app-admin/sudo

¶Step 3. add alexlai as in group sudo

(chroot) hc4Gentoo / # sudo groupadd -g 1026 alexlai
(chroot) hc4Gentoo / # sudo useradd -u 1026 -g 1026 -m alexlai
Creating mailbox file: No such file or directory
(chroot) hc4Gentoo / # visudo   --> add alexlai ALL=(ALL) ALL
(chroot) hc4Gentoo / # passwd alexlai

You can now choose the new password or passphrase.

A valid password should be a mix of upper and lower case letters, digits, and
other characters.  You can use a password containing at least 7 characters
from all of these classes, or a password containing at least 8 characters
from just 3 of these 4 classes.
An upper case letter that begins the password and a digit that ends it do not
count towards the number of character classes used.

A passphrase should be of at least 3 words, 11 to 72 characters long, and
contain enough different characters.

Alternatively, if no one else can see your terminal now, you can pick this as
your password: "Prior$Parrot5pray".

Enter new password: 
Weak password: not enough different characters or classes for this length.
Re-type new password: 
passwd: password updated successfully

¶Step 3.1. chane root passwd

(chroot) hc4Gentoo ~ # passwd


You can now choose the new password or passphrase.

A valid password should be a mix of upper and lower case letters, digits, and
other characters.  You can use a password containing at least 7 characters
from all of these classes, or a password containing at least 8 characters
from just 3 of these 4 classes.
An upper case letter that begins the password and a digit that ends it do not
count towards the number of character classes used.

A passphrase should be of at least 3 words, 11 to 72 characters long, and
contain enough different characters.

Alternatively, if no one else can see your terminal now, you can pick this as
your password: "swing&fancy_worst".

Enter new password:  <--b2nnnnnnn
Weak password: not enough different characters or classes for this length.
Re-type new password: 
passwd: password updated successfully

¶ 4. Set time zone

(chroot) hc4Gentoo / # date
Thu Aug 24 12:53:30 -00 2023
(chroot) hc4Gentoo / # timedatectl list-timezones
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
(chroot) hc4Gentoo / # timedatectl set-timezone Asia/Taipeik
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
(chroot) hc4Gentoo / # date
Thu Aug 24 12:56:06 -00 2023

¶5. hostname

(chroot) hc4Gentoo / # nano /etc/hostname

¶ Step 6. copy /boot partion

(chroot) hc4Gentoo / # lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0 223.6G  0 disk 
├─sda1        8:1    0   487M  0 part 
├─sda2        8:2    0   7.5G  0 part 
├─sda3        8:3    0    60G  0 part /
└─sda4        8:4    0 155.6G  0 part 
mtdblock0    31:0    0    16M  0 disk 
mmcblk0     179:0    0  28.3G  0 disk 
├─mmcblk0p1 179:1    0 457.8M  0 part 
└─mmcblk0p2 179:2    0  27.9G  0 part /etc/resolv.conf
zram0       253:0    0   5.4G  0 disk [SWAP]

(chroot) hc4Gentoo / # mount /dev/mmcblk0p1 /mnt
(chroot) hc4Gentoo / # mount /dev/sda1 /opt

(chroot) hc4Gentoo / # rsync -av --progress  /mnt/*  /opt
(chroot) hc4Gentoo / # ls -l /opt
total 57448
-rwxr-xr-x 1 root root 30165504 Jun  4 19:02 Image
-rwxr-xr-x 1 root root 12551598 Jun  4 19:02 Image.gz
-rwxr-xr-x 1 root root      794 Aug 24 00:11 boot.ini
drwxr-xr-x 3 root root     8192 Aug 24 00:06 dtbs
-rwxr-xr-x 1 root root  7600929 Aug 24 00:07 initramfs-linux.img
-rwxr-xr-x 1 root root  7600993 Aug 24 00:07 initramfs-linux.uimg
-rwxr-xr-x 1 root root   872304 May 25  2021 u-boot.bin

(chroot) hc4Gentoo / # ls -l /opt
total 57448
-rwxr-xr-x 1 root root 30165504 Jun  4 19:02 Image
-rwxr-xr-x 1 root root 12551598 Jun  4 19:02 Image.gz
-rwxr-xr-x 1 root root      794 Aug 24 00:11 boot.ini
drwxr-xr-x 3 root root     8192 Aug 24 00:06 dtbs
-rwxr-xr-x 1 root root  7600929 Aug 24 00:07 initramfs-linux.img
-rwxr-xr-x 1 root root  7600993 Aug 24 00:07 initramfs-linux.uimg
-rwxr-xr-x 1 root root   872304 May 25  2021 u-boot.bin
(chroot) hc4Gentoo / # lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0 223.6G  0 disk 
├─sda1        8:1    0   487M  0 part /opt
├─sda2        8:2    0   7.5G  0 part 
├─sda3        8:3    0    60G  0 part /
└─sda4        8:4    0 155.6G  0 part 
mtdblock0    31:0    0    16M  0 disk 
mmcblk0     179:0    0  28.3G  0 disk 
├─mmcblk0p1 179:1    0 457.8M  0 part /mnt
└─mmcblk0p2 179:2    0  27.9G  0 part /etc/resolv.conf
zram0       253:0    0   5.4G  0 disk [SWAP]
(chroot) hc4Gentoo / # umount /opt
(chroot) hc4Gentoo / # cd /mnt
(chroot) hc4Gentoo /mnt # ls
Image  Image.gz  boot.ini  dtbs  initramfs-linux.img  initramfs-linux.uimg  u-boot.bin
(chroot) hc4Gentoo /mnt # dd if=u-boot.bin of=/dev/sda bs=1k seek=1
851+1 records in
851+1 records out
872304 bytes (872 kB, 852 KiB) copied, 0.0384871 s, 22.7 MB/s

(chroot) hc4Gentoo ~ # umount /mnt
(chroot) hc4Gentoo ~ # lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0 223.6G  0 disk 
├─sda1        8:1    0   487M  0 part 
├─sda2        8:2    0   7.5G  0 part 
├─sda3        8:3    0    60G  0 part /
└─sda4        8:4    0 155.6G  0 part 
mtdblock0    31:0    0    16M  0 disk 
mmcblk0     179:0    0  28.3G  0 disk 
├─mmcblk0p1 179:1    0 457.8M  0 part 
└─mmcblk0p2 179:2    0  27.9G  0 part /etc/resolv.conf   <-- ???
zram0       253:0    0   5.4G  0 disk [SWAP]

¶ Setp 7. /boot/boot.ini

(chroot) hc4Gentoo ~ # mount /dev/sda1 /mnt
(chroot) hc4Gentoo ~ # blkid
/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL_FATBOOT="BOOT_MNJRO" LABEL="BOOT_MNJRO" UUID="DDBA-9480" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="6319cfe2-01"
/dev/mmcblk0p2: LABEL="ROOT_MNJRO" UUID="c116cbd4-ed1c-408d-88c7-6901ccb65d60" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="6319cfe2-02"
/dev/sda2: UUID="f4e47b4d-3ecc-4e27-83ec-4b9aafa71882" TYPE="swap" PARTUUID="69ed71c7-02"
/dev/sda3: UUID="0eec5082-3336-4c1d-be70-2a9e34a8fd2d" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="69ed71c7-03"
/dev/sda1: SEC_TYPE="msdos" UUID="F63A-4702" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="69ed71c7-01"
/dev/zram0: LABEL="zram0" UUID="71f971f6-e6b3-4a5f-96e0-143c479f5630" TYPE="swap"
/dev/sda4: PARTUUID="69ed71c7-04"
(chroot) hc4Gentoo ~ # nano /mnt/boot.ini 
(chroot) hc4Gentoo ~ # cat /mnt/boot.ini 
ODROIDC4-UBOOT-CONFIG

# Default Console Device Setting
setenv condev "console=ttyAML0,115200n8"   # on both

# setenv bootlabel
setenv bootlabel "2023-08-24 From Manjaro-arm-installer To Gentoo"

# Boot Args
setenv bootargs "root=UUID=0eec5082-3336-4c1d-be70-2a9e34a8fd2d rootwait rw ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 clk_ignore_unused quiet splash plymouth.ignore-serial-consoles"
# /dev/sda3: UUID="0eec5082-3336-4c1d-be70-2a9e34a8fd2d"
# Set load addresses
setenv dtb_loadaddr "0x20000000"
setenv loadaddr "0x1080000"
setenv initrd_loadaddr "0x4080000"

# Load kernel, dtb and initrd
load mmc ${devno}:1 ${loadaddr} /Image
load mmc ${devno}:1 ${dtb_loadaddr} /dtbs/amlogic/meson-sm1-odroid-hc4.dtb
load mmc ${devno}:1 ${initrd_loadaddr} /initramfs-linux.uimg
#fdt addr ${dtb_loadaddr}

# boot
booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr}