Btrfs for save changes file

Technical issues/questions of an intermediate or advanced nature.
User avatar
istinnjazz
Samurai
Samurai
Posts: 115
Joined: 15 May 2016, 14:10
Distribution: Manjaro-OpenRC/Nemesis

Btrfs for save changes file

Post#1 by istinnjazz » 26 Jun 2016, 22:50

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]

fullmoonremix

Re: Btrfs for save changes file

Post#2 by fullmoonremix » 26 Jun 2016, 22:57

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.

User avatar
istinnjazz
Samurai
Samurai
Posts: 115
Joined: 15 May 2016, 14:10
Distribution: Manjaro-OpenRC/Nemesis

Re: Btrfs for save changes file

Post#3 by istinnjazz » 26 Jun 2016, 23:41

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

User avatar
istinnjazz
Samurai
Samurai
Posts: 115
Joined: 15 May 2016, 14:10
Distribution: Manjaro-OpenRC/Nemesis

Re: Btrfs for save changes file

Post#4 by istinnjazz » 27 Jun 2016, 00:12

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?

User avatar
francois
Contributor
Contributor
Posts: 6434
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Re: Btrfs for save changes file

Post#5 by francois » 27 Jun 2016, 01:41

Prendre son temps, profiter de celui qui passe.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Btrfs for save changes file

Post#6 by brokenman » 27 Jun 2016, 02:19

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
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
istinnjazz
Samurai
Samurai
Posts: 115
Joined: 15 May 2016, 14:10
Distribution: Manjaro-OpenRC/Nemesis

Re: Btrfs for save changes file

Post#7 by istinnjazz » 27 Jun 2016, 12:20

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.

Bogomips
Full of knowledge
Full of knowledge
Posts: 2564
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: Btrfs for save changes file

Post#8 by Bogomips » 27 Jun 2016, 14:00

@ istinnjazz

If you can bear with me will provide you all the steps of what I know should work. 8)
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
istinnjazz
Samurai
Samurai
Posts: 115
Joined: 15 May 2016, 14:10
Distribution: Manjaro-OpenRC/Nemesis

Re: Btrfs for save changes file

Post#9 by istinnjazz » 27 Jun 2016, 14:42

@ Bogomips
there is no hurry, take your time :good: .
Keep in mind that I use nemesis 3.5, the arch based porteus

Bogomips
Full of knowledge
Full of knowledge
Posts: 2564
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: Btrfs for save changes file

Post#10 by Bogomips » 27 Jun 2016, 23:32

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.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
istinnjazz
Samurai
Samurai
Posts: 115
Joined: 15 May 2016, 14:10
Distribution: Manjaro-OpenRC/Nemesis

Re: Btrfs for save changes file

Post#11 by istinnjazz » 28 Jun 2016, 10:16

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.

Bogomips
Full of knowledge
Full of knowledge
Posts: 2564
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: Btrfs for save changes file

Post#12 by Bogomips » 28 Jun 2016, 11:12

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.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
istinnjazz
Samurai
Samurai
Posts: 115
Joined: 15 May 2016, 14:10
Distribution: Manjaro-OpenRC/Nemesis

Re: Btrfs for save changes file

Post#13 by istinnjazz » 03 Jul 2016, 21:14

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 # 

Post Reply