Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-Drive_Manager | Allow separate swap partition on Btrfs formatted drive #1715

Closed
mgherghi opened this issue Apr 18, 2018 · 9 comments
Closed

Comments

@mgherghi
Copy link

Creating a bug report/issue:

Not sure if this is possible, but may i create a swap on my btrfs disk ?

Required Information:

  • DietPi Version | cat /DietPi/dietpi/.version?
  • SBC Device (EG: RPi 3)?
  • Power supply used (EG: 5v 1A RAVpower)?
  • SD card used (EG: Sandisk ultra)?
  • Distro (EG: Jessie) | uname -a?

Additional Information (if applicable):

  • Software title?
  • Can this issue be replicated on a fresh installation of DietPi?

Expected behaviour:

Actual behaviour:

Steps to reproduce:

Did you submit a dietpi-bugreport?

Extra details:

@elRadix
Copy link

elRadix commented Apr 18, 2018

maybe this will help or have it integrated with dietpi as an option?
https://github.com/sebastian-philipp/btrfs-swapon

@mgherghi
Copy link
Author

I am having a hard time understanding why i cant swap on btrfs. Its a fairly modern filesystem for Linux, is the os moving away from swap ?

@MichaIng
Copy link
Owner

MichaIng commented Apr 18, 2018

@mgherghi
"Linux" is not moving towards btrfs, thus it's not moving away from swap. Just few distributions use it as default, e.g. SUSE Linux and MeGoo, and Fedora has the plan to use it as default, but it did not yet happen since several versions. And if Fedora does not, than this means something 😉.
On the other hand RHEL e.g. want to drop support for btrfs as they (their users) seem to face some critical issues by times.

Overall btrfs still seems to have some issues, that prevent most distributions from using it as default. I am not sure about the performance issues with swap on btrfs, but I think there are good reasons why this is not possible without workarounds. Thus I would still name ext4 as default Linux fs for good reasons and as this is fact for most Linux distros 😉.

@elRadix
Thanks for the link. This seems quite easy and we could add this to our scripts with reference, no additional packages are required to run the commands. Maybe then at least show some hint to user, that this "hack" is not recommended for performance and stability reasons. Also note the warnings within script readme:

Keep in mind, that a copy-on-write file system is not the best choice to use a swap file. Don't expect high performance.
...
Don't balance your file system as long as you use this swap file.

@Fourdee
What do you think?

@Fourdee
Copy link
Collaborator

Fourdee commented Apr 19, 2018

@MichaIng

this "hack" is not recommended for performance and stability reasons

I'am not personally keen on running a loopback to achieve a swapfile on btrfs. As hacks goes, its long winded and the performance impact negates its purpose.

We do offer multiple filesystem support in DietPi, allowing users to experiment outside of the standard ext4, however, there is always downsides (EG: FAT doesn't support permissions).

Regardless, if our users want the ability to run a swapfile on btrfs, and Sebastian Philipp's workaround offers a solution, we can try to integrate it at the very least. But, this will be a low priority task.

@MichaIng
Copy link
Owner

MichaIng commented Apr 19, 2018

Further reference:
https://btrfs.wiki.kernel.org/index.php/FAQ#Does_btrfs_support_swap_files.3F
https://btrfs.wiki.kernel.org/index.php/Project_ideas#Swap_file_support

File corruption disk is mentioned there as well, if file system includes multiple drives (internal RAID), workaround via loopback workaround mentioned as well to provide bad performance.
But thus if used on single drive and just as worst case use with swappiness=1, it should be okay. Maybe we can do check for single/multiple drives as well to prevent user from file corruption.

@leggewie
Copy link
Contributor

Why bother? Anybody who prefers btrfs for the files (like me) should simply set up a separate swap partition. Anything else is insanity.

@MichaIng MichaIng changed the title Swapfile on btrfs ? DietPi-Drive_Manager | Allow swapfile on btrfs Oct 14, 2018
@MichaIng
Copy link
Owner

@leggewie
You are absolutely right. We should not enable a feature that is known to be risky and has performance disadvantages. No big deal to setup a separate partition.

This is actually something we could offer instead from within DietPi-Drive_Manager, if a btrfs formatted drive/partition is selected: Creating an ext4 formatted swap partition on the same drive.

  • Shrinking current partition to free disk space should generally work, however it would be best if the swap partition was the first on drive (relevant for HDDs). Not sure how to achieve that without reformatting the whole drive?

@MichaIng MichaIng changed the title DietPi-Drive_Manager | Allow swapfile on btrfs DietPi-Drive_Manager | Allow separate swap partition on Btrfs formatted drive Jan 15, 2019
@MichaIng
Copy link
Owner

Linux 5.0 supports swap file on BTRFS: https://kernelnewbies.org/LinuxChanges/#Linux_5.0.Btrfs_swap_file_support

Alternative reasonable request: Allow using an existing partition as swap partition. So it's then up to the user to create the partition manually. Our script will just toggle swap on it.

@MichaIng
Copy link
Owner

MichaIng commented May 6, 2019

I mark this as closed. Swap partition support is a separate topic and generally not related to BTRFS.

@MichaIng MichaIng closed this as completed May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants