0

I have followed this link to set up a kernel development environment. In summary, I am running a Linux kernel 5.11.5 with a custom root file system. I am using buildroot to creating a root file system. Now, the filesystem image size is fixed so I'm not able to even create a directory at runtime from within a guest. So, I am not able to create a swap space.

Please provide a way to create a swap space for a guest.

5
  • 1
    Please provide a way to create a swap space for a guest. the filesystem image size is fixed -> unfix the image size. Create a partition in image. Format it for swap. Add the swap to that linux. The link there just uses -hda ../buildroot/output/images/rootfs.ext4. Create your own qmeu disc, format it with fdisk, create the partitions there with swap partition, copy the ext4 filesystem there and edit /etc/fstab in that partition to use swap. Commented Apr 2, 2021 at 12:16
  • I found free space under /tmp so I created a swap file in /tmp directory using fallocate. But when I tried to activate that swap file using swapon /tmp/1GiB.swap I got an error swapon: /tmp/1GiB.swap: Invalid argument. Can you please tell me what is going wrong over here? Commented Apr 2, 2021 at 12:59
  • I found free space under /tmp Assuming tmp is mounted as tmpfs, you basically created a swapfile in RAM and called it swap. Just use ram as ram instead. Swap should be on disc. Commented Apr 2, 2021 at 13:05
  • Ough, I am very new to qemu. So is it the reason (/tmp not being actual physical file) I am getting that error? Commented Apr 2, 2021 at 13:06
  • 1
    Finally, I was able to create a swap file by increasing the image size from 60MB to 4GB in buildroot configuration. Thanks @KamilCuk. Commented Apr 2, 2021 at 13:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.