[Diskless start]:
Diskless startup means that the operating system can be started without a disk (EMMC or sdcard or nvme). Diskless startup usually uses the DHCP, TFTP and NFS functions of uboot,
This time, we will use another way to realize diskless startup. We will combine PXE of network card with NFS of uboot to realize diskless startup.
You nead to prepare:
- rockpi4;
- server host (ubuntu);
- Ethernet Cable;
- Serial port line;
How to do:
- Download uboot to SPI flash on rockpi4;
- Install TFTP and NFS server on the server host(PC):
(1). NFS server installation:
xxx@xxx:~$ sudo apt-get install nfs-kernel-server
xxx@xxx:~$ mkdir -p /home/xxx/nfs_rootfs
xxx@xxx:~$ sudo vim /etc/exports
/home/xxx/nfs_rootfs *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)
xxx@xxx:~$ sudo service nfs-kernel-server restart #Restart service
xxx@xxx:~$ sudo mount -t nfs 127.0.0.1:/home/xxx/nfs_rootfs /mnt #Test services for NFS
(2). TFTP server installation:
xxx@xxx:~$ sudo apt-get install tftp-hpa tftpd-hpa
xxx@xxx:~$ mkdir -p /home/xxx/tftpboot
xxx@xxx:~$ chmod 777 /home/xxx/tftpboot
xxx@xxx:~$ sudo vim /etc/default/tftpd-hpa
TFTP_DIRECTORY="/home/xxx/tftpboot"
TFTP_OPTIONS="-l -c -s"
xxx@xxx:~$ sudo service tftpd-hpa restart #Restart service
- Put the kernel and DTB in the TFTP directory, and extract the root file system to the NFS directory. The operation is as follows:
(1). Update the kernel in Debian of rockpi4:
root@linaro-alip:~# apt-get update
root@linaro-alip:~# apt install linux-4.4-latest -y
...
Setting up linux-headers-4.4.154-110-rockchip-gcef30e88a9f5 (4.4.154-110-rockchip) ...
Setting up linux-4.4-latest (4.4.154-110-rockchip) ...
root@linaro-alip:~#
(2). Copy the latest kernel and other files in the boot directory of Debian (you need to update the kernel to version 110):
root@linaro-alip:/boot# cp * /media/linaro/1877-4F6E/boot/ -r #This is my U stick
(3). In the server (PC), copy all files in the boot directory of the U disk to the TFTP Directory:
xxx@xxx:/data/tftp_server$ cp /media/yulingle/1877-4F6E/boot/* . -r
(4). Create a configuration file for PXE to read:
xxx@xxx:/data/tftp_server$ mkdir pxelinux.cfg
xxx@xxx:/data/tftp_server$ cd pxelinux.cfg/
xxx@xxx:/data/tftp_server/pxelinux.cfg$ cp ../extlinux/extlinux.conf .
xxx@xxx:/data/tftp_server/pxelinux.cfg$ vim 01-d2-13-dc-b9-d4-10 #The physical address of the network card can be obtained by entering **print ehaddr** in the command line of **uboot**
timeout 10
menu title select kernel
label kernel-4.4.154-110-rockchip-gcef30e88a9f5
kernel /vmlinuz-4.4.154-110-rockchip-gcef30e88a9f5
devicetreedir /dtbs/4.4.154-110-rockchip-gcef30e88a9f5
initrd initrd.img-4.4.154-110-rockchip-gcef30e88a9f5
append earlyprintk console=ttyFIQ0,1500000n8 init=/sbin/init root=/dev/nfs rw nfsroot=192.168.2.181:/home/xxx/nfs_rootfs,v3 ip=192.168.2.244:192.168.2.181:192.168.2.1:255.255.255.0:xxx::off rootwait
#The contant of 01-d2-13-dc-b9-d4-10 file can copy from pxelinux.cfg/extlinux.conf
#192.168.2.181 is IP of server.
#/home/xxx/nfs_rootfs is the directory where the root file system resides.
#v3 is version number of nfs.
#xxx is hostname of your server host.
#192.168.2.1 is gateway.
(5). Next, unzip the root file system to the NFS directory:
Unzip the file system:
$ tar -xzf linaro-stretch-alip-20200623-1.tar.gz -C /home/xxx/ #After unzipping, you will get the binary folder.
$ mv binary nfs_rootfs #nfs_rootfs is the directory name specified in the /etc/exports file.
linaro-stretch-alip-20200623-1.tar.gz The creation of the root file system can refer to here.
(6). done.
4、Start rockpi4, enter the uboot command line, and set IP:
=> setenv ipaddr xx.xx.xx.xx
=> setenv serverip xx.xx.xx.xx #The IP address of rockpi4 and server must be in the same network segment.
Using PXE:
=> pxe get
=> pxe boot
5、When the kernel is started successfully and the NFS file system is mounted, the following is displayed:
Starting Update UTMP about System Runlevel Changes...
[ OK ] Started Update UTMP about System Runlevel Changes.
[ 27.195702] tty_port_close_start: tty->count = 1 port count = 2.
Debian GNU/Linux 9 linaro-alip ttyFIQ0
linaro-alip login: root (automatic login)
Linux linaro-alip 4.4.154-110-rockchip-gcef30e88a9f5 #1 SMP Mon Jun 22 07:37:10 UTC 2020 aarch64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@linaro-alip:~#
root@linaro-alip:~#
root@linaro-alip:~#
root@linaro-alip:~#
6、done