1.在ubuntu 制作一个64M的amge
$dd if=/dev/zero of=swap.img bs=512 count=131072
2.通过mtd卡方式加载swap.img 到qemu
qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -m 2048 -smp 2 -kernel arch/arm64/boot/Image --append "rdinit=/linuxrc console=ttyAMA0"
swapoff swapon switch_root
/ # mkswap /dev/mtdblock0
Setting up swapspace version 1, size = 134213632 bytes
random: mkswap urandom read with 17 bits of entropy available
UUID=04eaf296-2598-4058-bf9f-2c7a364a8218
/ # swapo
swapoff swapon
/ # swapon /dev/mtdblock0
Adding 131068k swap on /dev/mtdblock0. Priority:-1 extents:1 across:131068k SS
/ # free on
total used free shared buffers cached
Mem: 1988072 10828 1977244 18