FOGProject / fos

FOG Operating System
30 stars 33 forks source link

[Feature req] Support F2FS #50

Closed bence98 closed 1 year ago

bence98 commented 1 year ago

From FOGProject/fogproject#517

I installed Linux to an NVMe drive, and I heard that EXT4 is not great for flash-based media, so I chose to use F2FS as my root partition instead. Now I can't image it with FOG, as it fails with "No resizable partitions found". Using FOG 1.5.9, FOS kernel 5.15.68 on amd64 arch.

If I comment out the check in fog_upload:63, then it clones with Partclone.image, albeit slowly. A proper F2FS support would be much appreciated, with resize.f2fs and Partclone.f2fs

rluzuriaga commented 1 year ago

I was looking over the resizing code for BTRFS and EXT4 today because I am having issues with it. It looks to me like it should be pretty straightforward to add F2FS support. I will start work on it later this week.

rluzuriaga commented 1 year ago

I was able to add resize.f2fs and partclone.f2fs very easily. I am starting the work for the expand and shrink functions. @Sebastian-Roth I noticed that you had started a branch for a newer version of partclone. Should we continue that work and include F2FS support or add support to the current working version?

Sebastian-Roth commented 1 year ago

@rluzuriaga Great, thanks for looking into this! You are right. We still have the partcline-0320 branch open with the latest update of Buildroot (2022.02.6) as well. This has been in use by people who updated or installed FOG dev-branch after 9th of October this year. As we had no issue reports on this I will merge these changes into master some time this week. Have had this on my list anyway. Good you are reminding me. May I ask you to wait until this merge is done before you open a PR on the master branch?

Sebastian-Roth commented 1 year ago

Found some time just now and merged the mentioned branch. Feel free to send a pull request on F2FS support.

rluzuriaga commented 1 year ago

Okay, so I have done A LOT of research on F2FS so here are a few things I have learned.

  1. F2FS partitions CANNOT be shrunk. resize.f2fs can only expand the partition.
  2. The only way to "shrink" an F2FS partition is to rsync all the data out of it, delete the partition, and make a new smaller partition. (I am still testing to see if this fully works without issues).
  3. partclone.f2fs captures only the used space of the partition, but the image on FOG will still show up as the full size since the partition table was never changed.

There are two ways I see that we could implement support for F2FS.

  1. Add support without shrinking the partition on an upload/capture.
  2. If the tests are successful, add support for "shrinking" the partition with the method stated above.
    • In both cases, when doing a download/deploy, the partition can be expanded using resize.f2fs if there is more space on the drive.

@Sebastian-Roth Any thoughts/preferences?

Sebastian-Roth commented 1 year ago

@rluzuriaga Thanks a lot for taking the effort and looking into F2FS support!

  1. Add support without shrinking the partition on an upload/capture.

I'd probably vote for this option because ... (see my comment below)

  1. If the tests are successful, add support for "shrinking" the partition with the method stated above.

I am really wondering where you find room to place the data temporarily to be able to delete and re-create the partition? This is a high risk operation in any case. As FOG defaults to resizable image type I don't have a great feeling for such a move of data.

Overall having F2FS support in general would be great. We don't support shrinking for some other common filesystems either (e.g. XFS, FAT32).

Sebastian-Roth commented 1 year ago

@rluzuriaga Any chance we can get this ready for merging into the official code?

rluzuriaga commented 1 year ago

@Sebastian-Roth Sorry I've been busy with work. I have been testing the changes and found some issues. I am working on those issues and should have a PR by the end of the week.

Sebastian-Roth commented 1 year ago

@rluzuriaga Great work, thanks! PR merged just now - see #54.