I'm trying to create a swap partition/file on my board where a core-image-minimal
has been installed.
The fdisk -l
command doesn't show any partition thus I'm not able to figure out which block device I need to use to create a new partition.
Secondly, launchig a swapon
command on a swapfile
correctly initialized using mkswap
will raise an invalid argument error saying that the file contains holes even though I created it using dd
.
At this point I'm not sure if I can do something like this since the free
output looks like:
total used free shared buff/cache available
Mem: 503304 32108 101108 216 370088 465180
Swap: 0 0 0
To add any partition to your image, you need to modify the wks
file that is used for your build.
To get the current wks
file run :
bitbake -e | grep ^WKS_FILE=
Then, look for that file in your layers sources.
In that file you can add (example 1GB swap):
part swap --ondisk mmcblk0 --size 44 --label swap --fstype=swap --size=1024M --overhead-factor 1
For a real example, you can see the raspberry-pi machine swap support commit here.
You can use a custom wks
file and set it to your custom machine conf file:
WKS_FILE ?= "custom-image.wks"
For detailed info, check the Yocto reference about wks.