一、查遗补缺之SSH连接到香橙派
上一篇我们讲到,为了可以使用SSH连接到香橙派,我们勾选了dropbear软件包,这是一个轻量级的SSH软件,包含了客户端和服务端[1]。如何使用呢?在上一篇的末尾,PuTTY界面上,我们输入root并回车登录香橙派,然后立即修改root的密码
Starting network: [ 2.671965] dwmac-sun8i 1c30000.ethernet eth0: PHY [0.1:01] driver [Generic PHY] (irq=POLL)
[ 2.698792] dwmac-sun8i 1c30000.ethernet eth0: No Safety Features support found
[ 2.706155] dwmac-sun8i 1c30000.ethernet eth0: No MAC Management Counters available
[ 2.715218] dwmac-sun8i 1c30000.ethernet eth0: PTP not supported by HW
[ 2.721938] dwmac-sun8i 1c30000.ethernet eth0: configuring for phy/mii link mode
[ 2.730703] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
udhcpc: started, v1.32.0
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending select for 192.168.1.53
udhcpc: lease of 192.168.1.53 obtained, lease time 86400
deleting routers
adding dns 192.168.1.1
OK
Starting dropbear sshd: OK
Welcome to Buildroot for the Orange Pi PC
OrangePi_PC login: root
# passwd root
Changing password for root
New password:
Bad password: too short
Retype password:
passwd: password for root changed by root
#
由上面可以看出,网卡已经启动并成功动态获取到了IP地址。下面使用dropbearkey来生成key文件。
# dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
Generating 2048 bit rsa key, this may take a while...
Public key portion is:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCAla4zmSlhrhIoN9MG1U4lNfdtNl7AVdTc9UazlsHZ7nfIargg6mtt4FTI+Xktfq+xWnvT+9m8lwgLblybYjYn95BG48cOEeZsIG1x6gmb35Gh21eql+xc8kvQ5ADKq3YSyfYgWvtNI9Eo2S3u+NJ+wbTHZbX/Up5pZUfbwbN2Hq2bX92ZWSWbGk4KCmtIItBmW05L0SZs9YO8CS7+vDF4jjZR0CuAVjkQJmHi8gYUMb56RR66lFp1C08vCBtZJnproxm60s6KPtDJ8C0r5L8BtA8FQZImfusNnDDqXbqxv+yIJi/7OIMiRVexkHKFlOYlDZpieWsP0QjTPLPoXAIL root@OrangePi_PC
Fingerprint: sha1!! 56:3c:09:7a:31:55:dc:56:c5:6c:18:2e:e0:b9:91:f0:61:1a:6f:fb
#
现在关闭PuTTY,打开终端使用SSH连接香橙派
dpmicro@dpmicro-PC:~/Desktop$ ssh 192.168.1.53 -l root
The authenticity of host '192.168.1.53 (192.168.1.53)' can't be established.
ECDSA key fingerprint is SHA256:q7n7pkav3Ew2eAbuLir0/7E3BxJfH03GSMf+Yl/bxho.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.53' (ECDSA) to the list of known hosts.
root@192.168.1.53's password:
# pwd
/root
#
好了,可以甩开你的USB转串口线了!
二、查遗补缺之TF卡扩容
不知道大家发现没,不管你用多大容量的TF卡,写入镜像后可用空间似乎很小。
# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 54.1M 5.1M 44.8M 10% /
devtmpfs 494.1M 0 494.1M 0% /dev
tmpfs 502.6M 0 502.6M 0% /dev/shm
tmpfs 502.6M 36.0K 502.5M 0% /tmp
tmpfs 502.6M 24.0K 502.6M 0% /run
看上去只有40M多可以使用。
# fdisk -l
Disk /dev/mmcblk0: 7744 MB, 8120172544 bytes, 15859712 sectors
247808 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes
Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/mmcblk0p1 * 0,32,33 1,102,37 2048 22527 20480 10.0M c Win95 FAT32 (LBA)
/dev/mmcblk0p2 1,102,38 66,171,41 22528 1071103 1048576 512M 83 Linux
看到这里更觉着诡异,明明mmcblk0p2分区有512M的空间啊。可是也不对哦,我的TF卡可是8G的,上面也显示磁盘容量为7744MB。这些空间都去哪儿了呢?我们把TF卡插入读卡器,在电脑上一探究竟。
这个10MB卷倒是没有什么问题。rootfs卷显示总共512MB,已用5.1MB。我们使用分区编辑器进一步查看。
这下真相大白了,是有7.05GB的空间压根没分配。我们再看sdc2分区,已用+未用=60M,这个数值似乎在哪里见过?没错,就是在下面的配置里
这个配置规定了文件系统的大小。那么512M又从何而来呢?查看buildroot-2020.11/board/orangepi/orangepi-pc/genimage.cfg文件
# Minimal SD card image for the OrangePi PC
#
image boot.vfat {
vfat {
files = {
"zImage",
"sun8i-h3-orangepi-pc.dtb",
"boot.scr"
}
}
size = 10M
}image sdcard.img {
hdimage {
}partition u-boot {
in-partition-table = "no"
image = "u-boot-sunxi-with-spl.bin"
offset = 8192
size = 1040384 # 1MB - 8192
}partition boot {
partition-type = 0xC
bootable = "true"
image = "boot.vfat"
}partition rootfs {
partition-type = 0x83
image = "rootfs.ext4"
size = 512M
}
}
由此可见,512M是物理分区大小,而60M是逻辑分区大小。如何才能使用全部的容量呢?是不是需要修改上述配置呢?当然可以,但是换用不同容量的TF卡就修改一次配置文件并生成一次镜像未免有些费事。
在分区编辑器上右击sdc2选择卸载
再次右击选择检查,并点击应用。
此时可以看到,sdc2空间已扩充至全部的512M。下面点击调整大小/移动
将新的容量修改为最大数值,点击调整大小/移动,最后点击应用。
可以看到,至此已完成扩容。