maxnet / berryboot

Berryboot -- Boot menu / OS installer
http://www.berryboot.com/
Other
808 stars 133 forks source link

swapon failed: Input/output error #408

Closed macmpi closed 7 years ago

macmpi commented 7 years ago

Hi,

I'm trying to use Volumio2 distribution under Berryboot. It's mostly fine, except on lower-RAM devices when Volumio tries to dynamically enable a swap file with this: this generates the error message in the title. Tried manually, and same thing happens at last swapon command, verbose message says:

volumio@volumio:/data$ sudo swapon /data/swapfile --verbose
swapon /data/swapfile
swapon: /data/swapfile: found swap signature: version 1d, page-size 4, same byte order
swapon: /data/swapfile: pagesize=4096, swapsize=536870912, devsize=536870912
swapon: /data/swapfile: swapon failed: Input/output error

Could this be due to aufs filesystem ? Any suggested workaround?

Thanks!

maxnet commented 7 years ago

You will need a swap partition instead of file if you really want that. Do not recommend having swap at all though.

macmpi commented 7 years ago

Curious why it works on native, and not under berryboot though... I'd like to minimize changes to image. Maybe something around this may do the trick...

maxnet commented 7 years ago

But why do you want to have swap in the first place? SD cards do not make good swap devices.

macmpi commented 7 years ago

It's not me, it what's built-into the original distribution... I doubt I have enough argument to push such kind of change in that proven distribution, built for many platforms (some not relying on SD for storage). Some low-RAM devices (such as PiZero) are a bit short to run without swap apparently...

I guess some other Raspi distributions may use swap too, no?

macmpi commented 7 years ago

It seems RetroPie does similar things

maxnet commented 7 years ago

Yeah, standard Raspbian has that as well, but it is the first thing one normally disables. Your mouse pointer shocks every time it swaps if you have a cheap SD card.

macmpi commented 7 years ago

sure, but what if distribution does not work without it... Any idea on how to have berryboot support this, if user can live with slowed (albeit working) app? Thanks for any tip!

maxnet commented 7 years ago

Would need to activate a swap file before the aufs layer goes on, so in berryboot-init. And even then it may not work if LUKS encryption was activated during Berryboot installation. In that case you can only use swap partitions, not files.

macmpi commented 7 years ago

Interesting, thanks, will look into that: any suggested location for that file at that time? no LUKS for me ;p

macmpi commented 7 years ago

berryboot-init file must pertain to original squashfs image, so that it can be loaded from /squashfs directory when image is mounted, right?

Would be nice to have similar modifiable berryboot-init which may reside outside of squash image (could be in /mnt/data for instance), but with image name being passed as parameter, so that some switch case can be done according to specific images (like currently in a way). This would avoid to unsquash/modify/resquash images for berryboot-init file inclusion at each image update...

Make sense? A bit like similar suggested change to enable custom image update scripts...

macmpi commented 7 years ago

Followed your suggestion (thanks !) and it seems to sort-of work. However, while I created swap file as /mnt/swpafile, it gets remapped elsewhere after aufs magics and image mounting stuff (in /media/berryboot/swapfile or whatever), and original location does not exist anymore when image runs... Still, cat /proc/swaps reports the original location and free shows swap is active/used !... I wonder if this remapping-thing will not cause problems: it looks a bit weird. Any suggestion on where it shall be set in first place, or eventually bind-mounted? Not a specialist of this... Thanks.

PS: appreciate if you can consider the PR (or some better thought-out alternative?), which would definitely make things easier for berryboot-init feature.

maxnet commented 7 years ago

Any suggestion on where it shall be set in first place, or eventually bind-mounted?

The only good place is in a partition.

But best is not to have it all. Ever. I do not think swap is ever a good solution. Let alone on flash memory. If your device has insufficient memory to do without it, get a different one.

macmpi commented 7 years ago

...or optimize RAM allocation (gpu vs arm) to set arm side to maximum, which would greatly help in that case. But it seems there is an issue (https://github.com/maxnet/berryboot/issues/411) in setting gpu_mem through image file naming since move to 4.9 kernel...

shunobies commented 2 years ago

I had to create a new image for the most recent Raspberry Pi OS 64bit and had several issues with it that were solved by: sudo mount /dev/mmcblk0p1 /boot

sudo crontab -e

@reboot mount /dev/mmcblk0p1 /boot

I wouldn't use the swap unless you have an SSD or NVME drive. If your using SD card this probably isn't a good idea. However the above commands allowed me to actual install some of the apt packages I was having issues with.

BerryBoot Workaround SwapFile sudo nano /etc/dphys-swapfile

CONF_SWAPFILE=/boot/swapfile

sudo dphys-swapfile setup sudo dphys-swapfile swapon