1、先用串口把计算机和NanoPI M2 连接起来

2、打开串口调试器:设置为对应的端口号,波特率:115200,打开串口。

3、给NanoPi M2上电,就可以看到控制台打印出信息,其中有一条信息是我们要设置启动分区的,把它给拷贝出来,内容如下:

[    0.000000] Kernel command line: console=ttyAMA0,115200n8 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait init=/sbin/init systemd.show_status=false g_ether.host_addr=82:cf:ce:fa:44:18 lcd=HDMI720P60

4、输入用户名和密码进入系统,查看系统分区信息。

root@Ubuntu-mate:~# fdisk -l

Disk /dev/mmcblk0: 14.5 GiB, 15560867840 bytes, 30392320 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00098996

Device         Boot  Start     End Sectors Size Id Type
/dev/mmcblk0p1        2048  133119  131072  64M 83 Linux
/dev/mmcblk0p2      133120 6424575 6291456   3G 83 Linux

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc360b343

Device     Boot    Start       End   Sectors   Size Id Type
/dev/sda1           2048  39070926  39068879  18.6G 83 Linux
/dev/sda2       39071744 976773167 937701424 447.1G  5 Extended
/dev/sda5       39073792  97677316  58603525    28G 83 Linux
/dev/sda6       97681408 976773167 879091760 419.2G 83 Linux

root@Ubuntu-mate:~#

/dev/mmcblk0为安装系统的SD卡

/dev/mmcblk0p1 为系统引导分区

/dev/mmcblk0p2 为文件系统,挂载到"/"根目录下

5、需要把文件系统挂载到sda1分区下,先把根目录下的所有文件拷贝到sda1,使用命令如下:

a、格式化sda1分区

root@Ubuntu-mate:~# mkfs.ext4 /dev/sda1
mke2fs 1.42.12 (29-Aug-2014)
/dev/sda1 contains a ext4 file system labelled 'usblinux'
        last mounted on / on Thu Jan  1 00:00:19 1970
Proceed anyway? (y,n) y
Creating filesystem with 4883609 4k blocks and 1221600 inodes
Filesystem UUID: 8df75b44-6ea2-46c9-b93f-5ea9b3c2877c
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

b、拷贝数据

root@Ubuntu-mate:~# dd if=/dev/mmcblk0p2 of=/dev/sda1
6291456+0 records in
6291456+0 records out
3221225472 bytes (3.2 GB) copied, 169.821 s, 19.0 MB/s
root@Ubuntu-mate:~#

拷贝完成后,重新启动系统

6、在uboot启动阶段输入任意键进入uboot命令界面后,输入如下命令,修改启动参数,并重启。

a、把上面的root=/dev/mmcblk0p2改为 root=/dev/sda1,执行如下的命令

s5p4418# setenv bootargs console=ttyAMA0,115200n8 root=/dev/sda1 rootfstype=ext4 rootwait init=/sbin/init systemd.show_status=false g_ether.host_addr=82:cf:ce:fa:44:18 lcd=HDMI720P60

b、输入“saveenv”保存设置

s5p4418# saveenv

Saving Environment to MMC...
Writing to MMC(0)... done

c、输入“run bootcmd”重新启动uboot

s5p4418# run bootcmd
## Booting kernel from Legacy Image at 48000000 ...
   Image Name:   Linux-3.4.39-FriendlyARM
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4554096 Bytes = 4.3 MiB
   Load Address: 40008000
   Entry Point:  40008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

   ......................

 7、验证根文件系统是否被安装到sda1分区

a、先展开根文件分区大小

root@Ubuntu-mate:~# resize2fs /dev/sda1
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/sda1 is now 4883609 (4k) blocks long.

root@Ubuntu-mate:~#

b、查看文件系统大小

root@Ubuntu-mate:~# fdisk -l

Disk /dev/mmcblk0: 14.5 GiB, 15560867840 bytes, 30392320 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00098996

Device         Boot  Start     End Sectors Size Id Type
/dev/mmcblk0p1        2048  133119  131072  64M 83 Linux
/dev/mmcblk0p2      133120 6424575 6291456   3G 83 Linux

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc360b343

Device     Boot    Start       End   Sectors   Size Id Type
/dev/sda1           2048  39070926  39068879  18.6G 83 Linux
/dev/sda2       39071744 976773167 937701424 447.1G  5 Extended
/dev/sda5       39073792  97677316  58603525    28G 83 Linux
/dev/sda6       97681408 976773167 879091760 419.2G 83 Linux

root@Ubuntu-mate:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        19G  2.5G   16G  14% /
devtmpfs        406M     0  406M   0% /dev
tmpfs           406M     0  406M   0% /dev/shm
tmpfs           406M   12M  394M   3% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           406M     0  406M   0% /sys/fs/cgroup
tmpfs           406M  4.0K  406M   1% /tmp
tmpfs            82M  4.0K   82M   1% /run/user/117
tmpfs            82M     0   82M   0% /run/user/0
root@Ubuntu-mate:~#

从上面的信息可以看出,设置已经生效


从NFS启动根文件系统,只需要在uboot终端如如下设置(把“/”目录下的所有文件拷贝到nfs目录下--/share/nanopi 或者进入到根文件系统下,使用“sudo rsync -aH ./ nfs服务目录“同步到NFS服务指定的目录下即:/share/nanopi)

s5p4418#set serverip 192.168.1.35
s5p4418#set ipaddr 192.168.1.36
s5p4418#set netmask 255.255.255.0
s5p4418#set gateway 192.168.1.1
s5p4418#set netdev eth0
s5p4418#ping 192.168.1.35
s5p4418#set hostname Ubuntu-mate
s5p4418#set rootpath /share/nanopi
s5p4418#setenv bootargs root=/dev/nfs rw nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip:$gateway:$netmask:$hostname:$netdev:off console=ttyAMA0,115200n8 rootfstype=ext4 rootwait init=/sbin/init systemd.show_status=false g_ether.host_addr=82:cf:ce:fa:44:18 lcd=HDMI720P60

s5p4418# saveenv

s5p4418# run bootcmd




注意:本文归作者所有,未经作者允许,不得转载