Raspberry OS在5月28号发布了64位OS的beta版本可以供Pi3和Pi4的设备使用。之前做的树莓派网络启动更换OS非常简单,只需要把Boot镜像和文件系统镜像更换了就行。
准备NFS镜像
下载镜像文件并解压,得到2020-05-27-raspios-buster-arm64.img。链接:2020.5.27 beta版下载地址
在nfs服务器上挂载img文件里面的boot和root分区
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15mkdir -p /mnt/boot /mnt/arm64
fdisk -l 2020-05-27-raspios-buster-arm64.img
Disk 2020-05-27-raspios-buster-arm64.img: 3.5 GiB, 3711959040 bytes, 7249920 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: 0x99cc74d8
Device Boot Start End Sectors Size Id Type
2020-05-27-raspios-buster-arm64.img1 8192 532479 524288 256M c W95 FAT32 (LBA)
2020-05-27-raspios-buster-arm64.img2 532480 7249919 6717440 3.2G 83 Linux
mount -o loop,offset=4194304 /volume1/nfs/2020-05-27-raspios-buster-arm64.img /mnt/boot
mount -o loop,offset=272629760 /volume1/nfs/2020-05-27-raspios-buster-arm64.img /mnt/arm64/
root@DS1515:/volume1/nfs#mount的offset是根据分区的StartSector size。比如boot分区是8192512=4194304,root分区是532480*512=272629760
将boot和root分区拷贝到nfs和tftproot。
1
2
3mkdir /volume1/nfs/tftproot/newroot/ /volume1/nfs/rpi4b-arm64
rsync -xa --progress /mnt/boot/ /volume1/nfs/tftproot/newroot/
rsync -xa --progress /mnt/arm64/ /volume1/nfs/rpi4b-arm64/
更改启动配置
打开ssh
1
touch /volume1/nfs/tftproot/newroot/ssh
从nfsroot启动
1
echo "console=serial0,115200 console=tty1 rw root=/dev/nfs nfsroot=192.168.2.45:/volume1/nfs/rpi4b-arm64,v3,tcp ip=dhcp elevator=deadline rootwait" > /volume1/nfs/tftproot/57360526/cmdline.txt
也可以使用静态IP取代dhcp
1
2cat /volume1/nfs/tftproot/57360526/cmdline.txt
console=serial0,115200 console=tty1 rw root=/dev/nfs nfsroot=192.168.2.45:/volume1/nfs/rpi4b-arm64,v3,tcp ip=192.168.2.11:::255.255.255.0:rpi:eth0:off elevator=deadline rootwaitip的参数看kernel的文档
1
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>:<ntp0-ip>
将之前的系统文件复制到新系统
需要同步的文件的列表.因为新系统,没有太多需要同步的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15cat sync_sys.files
+ /
+ /etc/
+ /etc/passwd
+ /etc/fstab
+ /etc/shadow
+ /etc/group
+ /etc/gshadow
+ /etc/sudoers
+ /etc/localtime
+ /etc/ssh/
+ /etc/ssh/**
+ /home/
+ /home/**
- *同步文件
1
rsync --progress -xa --include-from sync-sys.files /volume1/nfs/rpi4b-8g/ /volume1/nfs/rpi4b-arm64/
重新启动
更换tftproot的启动目录。树莓派缺省是通过tftp服务器上的/{序列号}/目录启动,将新的目录替代原来的
1
2mv /volume1/nfs/tftproot/57360526 /volume1/nfs/tftproot/32bit
mv /volume1/nfs/tftproot/newroot /volume1/nfs/tftproot/57360526重新启动搞定
看看系统已经是aarch64了。1
2
3
4uname -a
Linux raspberrypi 5.4.42-v8+ #1319 SMP PREEMPT Wed May 20 14:18:56 BST 2020 aarch64 GNU/Linux
file /bin/bash
/bin/bash: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=b11533bde88bb45ef2891fbf3ad86c1869ed3a41, stripped镜像源,目前国内的镜像源还没有同步raspberry arm64的包,清华raspbian镜像目录只有armhf的。所以只能改debian buster的arm64镜像。
1
2
3
4
5
6
7
8
9
10
11cat /etc/apt/sources.list
deb http://mirrors.tuna.tsinghua.edu.cn/debian buster main non-free contrib
deb http://mirrors.tuna.tsinghua.edu.cn/debian buster-updates main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
deb http://deb.debian.org/debian buster main contrib non-free
deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free
deb http://deb.debian.org/debian buster-updates main contrib non-free
Uncomment deb-src lines below then 'apt-get update' to enable 'apt-get source'
deb-src http://deb.debian.org/debian buster main contrib non-free
deb-src http://deb.debian.org/debian-security/ buster/updates main contrib non-free
deb-src http://deb.debian.org/debian buster-updates main contrib non-free/etc/apt/sources.list.d/raspi.list保持不动。
- 本文作者: KCN
- 本文链接: https://www.kcn.me/2020/06/25/Raspberry-upgrade-64bit/
- 版权声明: 未经允许,请勿转载