Page 1 of 1

Btrfs for save changes file

Posted: 26 Jun 2016, 22:50
by istinnjazz
I was wondering if a btrfs file system is possible for a changes file. I have formated one to test but it does not seem to work. I am not thinking of any benefit from it right now instead of an ext3/4, just testing it [in nemesis 3.5]

Re: Btrfs for save changes file

Posted: 26 Jun 2016, 22:57
by fullmoonremix
I used btrfs for quite a while with Porteus.
I moved on after the file system locked on me.

I'm sure it works... it just appears to require certain pre-conditions.
I will research this tonight and report my findings tomorrow.

Unless someone else elaborates.

Re: Btrfs for save changes file

Posted: 26 Jun 2016, 23:41
by istinnjazz
just for reference
commands used:

Code: Select all

dd if=/dev/zero of=save-bt2.dat bs=1M count=128
mkfs.btrfs save-bt2.dat
could the dd "bs" parameter be a problem?
edit: nope, tested with 64k also

Re: Btrfs for save changes file

Posted: 27 Jun 2016, 00:12
by istinnjazz
I realized that btrfs kernel module is not loaded with my custom kernel, even if I can use those commands of the btrfs tools and I can also manually mount it. But not at boot run level.

Code: Select all

root /home/guest # modinfo btrfs
filename:       /lib/modules/4.5.5-xanmod8-porteus/kernel/fs/btrfs/btrfs.ko
license:        GPL
alias:          devname:btrfs-control
alias:          char-major-10-234
alias:          fs-btrfs
depends:        raid6_pq,xor,zlib_deflate
intree:         Y
vermagic:       4.5.5-xanmod8-porteus SMP preempt mod_unload 
Maybe it has to be compiled in kernel core and not as a module, I do not know if it can be loaded at boot as a module. This is probably the issue. Can I pass a kernel parameter to load btrfs module at boot before changes param at porteus.cfg?

Re: Btrfs for save changes file

Posted: 27 Jun 2016, 01:41
by francois

Re: Btrfs for save changes file

Posted: 27 Jun 2016, 02:19
by brokenman
udev handles all the kernel module loading but you can put the modules you want to load in /etc/rc.d/rc.modules
modprobe btrfs

In your case you may need to compile btrfs into the kernel or unpack initrd.xz and add the modprobe command into linuxrc

Re: Btrfs for save changes file

Posted: 27 Jun 2016, 12:20
by istinnjazz
Ok, i have extracted intrd, have edited linuxrc adding "modprobe btrfs" at the end of code (so core xmz will load first and command will find the module).

to create the new initrd i have used:

Code: Select all

find . | cpio --create --format='newc' > /mnt/sdb5/linux/tmp/newinit-btrfs
and of course set the new entry in porteus.cfg
I do not know if it really can find and load the module from the core xzm, initrd is working and booting but module can not be loaded again.
I will have to recompile, and use a new vmlinuz to be sure. But it would be good to know a way that works for modules in initrd level.

Re: Btrfs for save changes file

Posted: 27 Jun 2016, 14:00
by Bogomips
@ istinnjazz

If you can bear with me will provide you all the steps of what I know should work. 8)

Re: Btrfs for save changes file

Posted: 27 Jun 2016, 14:42
by istinnjazz
@ Bogomips
there is no hurry, take your time :good: .
Keep in mind that I use nemesis 3.5, the arch based porteus

Re: Btrfs for save changes file

Posted: 27 Jun 2016, 23:32
by Bogomips
istinnjazz wrote:Keep in mind that I use nemesis 3.5, the arch based porteus
No worries. Will do example without being confined to single distro. :wink:
  1. Get kriss's script enhanced from http://forum.porteus.org/viewtopic.php? ... =15#p41205
  2. Name it punpin.sh

    Code: Select all

    mkdir ird
    cp  /Path/to/initrd.xz  ird
    sh  ../punpin.sh
  3. Edit linuxrc:

    Code: Select all

    #======================================
    # ENTRY (Put this right at the start!)
    #--------------------------------------
    .	modprobe  btrfs	#	2016-07-27
    ## Let's start!
    mount -nt devtmpfs none /dev
    
  4. Looks like there is already a kernel module: /lib/modules/`uname -r`/kernel/fs/btrfs/btrfs.ko available.
  5. Add the module. (For this exercise we'll use: /lib/modules/4.1.15/kernel/fs/btrfs/btrfs.ko)

    Code: Select all

    cd  /home/guest
    cp --parents /lib/modules/4.1.15/kernel/fs/btrfs/btrfs.ko  ird
  6. Do Dependency
    1. Code: Select all

      mkdir -p dep/lib/modules/4.1.15
      cp -a /lib/modules/4.1.15/kernel  dep/lib/modules/4.1.15
      /sbin/depmod -b dep 4.1.15
      
    2. Should now have something like:

      Code: Select all

      guest@porteus:~$ ls dep/lib/modules/4.1.15/
      kernel/        modules.alias.bin    modules.dep      modules.devname  modules.symbols
      modules.alias  modules.builtin.bin  modules.dep.bin  modules.softdep  modules.symbols.bin
      
    3. Code: Select all

      cp -p dep/lib/modules/4.1.15/*  ird/lib/modules/4.1.15
  7. Pack Initrd:

    Code: Select all

    cd ird
    sh ../punpin.sh xz
    cd ..
    # Assuming same directory as for initrd.xz
    cp -p newinitrd.xz  /Path/to/newinitrd.xz  
    
  8. Testing. At the boot screen hit tab key, in order to edit entry. Replace initrd.xz with newinitrd.xz
  9. Good Luck!
Well, that's more or less what was done for a missing ntfs module. Simplified some of the statements from the documentation, hope have not introduced any errors in the process.

Re: Btrfs for save changes file

Posted: 28 Jun 2016, 10:16
by istinnjazz
Thanks, I will try it
It is good to have same good instructions to deal with initd, I have never touched it and it seems very selective on the way it has to be packed.

To sum up some of my findings, if correct
1. If we will change/upgrade kernel, modules directory inside initrd becomes obsolete and/or possibly incompatible
2. It seems that the save.dat file is being read before anything else in the union sequence. And I guess is impossible if not designed as such, to have a special xzm with those modules so initrd can access them before loading save.dat outside of the initrd itself. But this seems specific and rare, so not much of a deal here.
3. It seems a good method in cases where exotic/old drivers or special fs has to be recognized upon boot. I have already a kernel panic on an old machine upon boot and I suspect there is a chip/set driver as a module behind this (some other distros boot ok).


Anyway, I think it is better (for this particular case) to recompile kernel with core btrfs in my next upgrade and keep initrd intact.
Thanks for your method.

P.S. I will test Btrfs, it seems there is future in this and it seems relatively stable on latest versions. I have read good opinions about it compared to ext4 especially for failure recovery. I want to test its behavior in savefile mode, https://wiki.archlinux.org/index.php/Btrfs.

Re: Btrfs for save changes file

Posted: 28 Jun 2016, 11:12
by Bogomips
istinnjazz wrote:2. It seems that the save.dat file is being read before anything else in the union sequence.
A quick glance at an annotated linuxrc, seems to confirm that changes are processed before modules dealt with.

Re: Btrfs for save changes file

Posted: 03 Jul 2016, 21:14
by istinnjazz
I compiled with btrfs as a part of the kernel, btrfs save.dat loads and saves OK.

Code: Select all

root /home/guest # dmesg | grep BTRFS
[    5.853178] BTRFS: device fsid 78050861-e19d-49fa-974a-8cd8af3aeeb5 devid 1 transid 18 /dev/loop0
[    5.857306] BTRFS info (device loop0): disk space caching is enabled
[    5.857308] BTRFS: has skinny extents
I had also compiled with F2FS as a part of the kernel, I will probably test it some day

Code: Select all

root /home/guest # dmesg | grep F2FS
[    5.849154] F2FS-fs (loop0): Magic Mismatch, valid(0xf2f52010) - read(0x0)
[    5.849157] F2FS-fs (loop0): Can't find valid F2FS filesystem in 1th superblock
[    5.849200] F2FS-fs (loop0): Magic Mismatch, valid(0xf2f52010) - read(0x0)
[    5.849202] F2FS-fs (loop0): Can't find valid F2FS filesystem in 2th superblock
[    5.849206] F2FS-fs (loop0): Magic Mismatch, valid(0xf2f52010) - read(0x0)
[    5.849208] F2FS-fs (loop0): Can't find valid F2FS filesystem in 1th superblock
[    5.849210] F2FS-fs (loop0): Magic Mismatch, valid(0xf2f52010) - read(0x0)
[    5.849211] F2FS-fs (loop0): Can't find valid F2FS filesystem in 2th superblock
root /home/guest #