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.

Vimal Patel
  • 211
  • 2
  • 9
  • 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. – KamilCuk Apr 02 '21 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? – Vimal Patel Apr 02 '21 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. – KamilCuk Apr 02 '21 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? – Vimal Patel Apr 02 '21 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. – Vimal Patel Apr 02 '21 at 13:40

0 Answers0