Tiny Core Linux

Tiny Core Extensions => TCE Talk => Topic started by: qingquan on January 06, 2023, 05:06:16 AM

Title: Which module supports Linux-IO Target
Post by: qingquan on January 06, 2023, 05:06:16 AM
I want to set up an iscsi server
Who knows, please?
Which module supports Linux-IO Target.
Title: Re: Which module supports Linux-IO Target
Post by: Rich on January 06, 2023, 06:48:11 AM
Hi qingquan
Quote
The iSCSI target fabric is included since Linux 3.1.

The important kernel modules are target_core_mod and iscsi_target_mod, which should be in the kernel ...
Found here:
https://wiki.archlinux.org/title/ISCSI/LIO

That suggests the following kernel config options need to be enabled:
CONFIG_TARGET_CORE
https://cateee.net/lkddb/web-lkddb/TARGET_CORE.html
CONFIG_ISCSI_TARGET
https://cateee.net/lkddb/web-lkddb/ISCSI_TARGET.html

If you look at the kernel config:
http://tinycorelinux.net/12.x/x86_64/release/src/kernel/config-5.10.3-tinycore64
it shows:
Quote
# CONFIG_TARGET_CORE is not set
and  CONFIG_ISCSI_TARGET  does not exist since it requires  CONFIG_TARGET_CORE.

That means  Linux-IO Target  support is not included in your kernel.
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 06, 2023, 08:57:29 PM
Hi Rich
Thank you for your reply. I have learned skills from it.

TinyCorePure64-12.0 Not supported Linux-IO Target.
 sorry to hear that,I'm not up to the task of recompiling the kernel.
 Is there any other way? For example, install a tcz.
Title: Re: Which module supports Linux-IO Target
Post by: Juanito on January 06, 2023, 11:55:46 PM
You will need to re-compile the tinycore kernel - it's not difficult.
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 07, 2023, 12:14:08 AM
Thanks to Juanito's encouragement, I downloaded the source code:
http://tinycorelinux.net/12.x/x86_64/release/src/kernel/linux-5.10.3-patched.txz
Next, how to get the source code,or how to set it up?

TARGET_CORE, ISCSI_TARGET,TCM_IBLOCK,TCM_FILEIO,TCM_PSCSI,TCM_USER

Thank you very much!
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 07, 2023, 12:48:43 AM
Thanks to Juanito's encouragement, I downloaded the source code:
http://tinycorelinux.net/12.x/x86_64/release/src/kernel/linux-5.10.3-patched.txz
Next, how to get the source code,or how to set it up?

TARGET_CORE, ISCSI_TARGET,TCM_IBLOCK,TCM_FILEIO,TCM_PSCSI,TCM_USER

Thank you very much!
-------------------------------------------------------------------
https://cateee.net/sources/lkddb/lkddb-5.10-rc3.list
module target_core_file "TCM/FILEIO Subsystem Plugin for Linux/VFS" : CONFIG_TCM_FILEIO : drivers/target/Kconfig
module target_core_iblock "TCM/IBLOCK Subsystem Plugin for Linux/BLOCK" : CONFIG_TCM_IBLOCK : drivers/target/Kconfig
module target_core_mod "Generic Target Core Mod (TCM) and ConfigFS Infrastructure" : CONFIG_TARGET_CORE : drivers/target/Kconfig
module target_core_pscsi "TCM/pSCSI Subsystem Plugin for Linux/SCSI" : CONFIG_TCM_PSCSI : drivers/target/Kconfig
module target_core_user "TCM/USER Subsystem Plugin for Linux" : CONFIG_TCM_USER2 : drivers/target/Kconfig

Title: Re: Which module supports Linux-IO Target
Post by: Juanito on January 07, 2023, 12:49:16 AM
You also need to download http://tinycorelinux.net/12.x/x86_64/release/src/kernel/config-5.10.3-tinycore64

Then:
Code: [Select]
tce-load -i compiletc perl5 ncursesw-dev bc glibc_apps elfutils-dev
cd linux-5.10.3
make mrproper
cp ../config-5.10.3-tinycore64 ./.config
make oldconfig
make menuconfig

..choose your new configuration options (set them as modules "m", then save and exit menuconfig

Then:
Code: [Select]
make
Once completed, you will need to copy the new vmlinuz and the new modules.

The new modules can used to create a new extension and the new vmlinuz will replace the existing tinycore vmlinuz64.
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 07, 2023, 09:42:12 PM
Hi Juanito

Compiling in a "Linux partition" is a good choice
http://tinycorelinux.net/12.x/x86_64/release/src/kernel/linux-5.10.3-patched.txz
http://tinycorelinux.net/12.x/x86_64/release/src/kernel/config-5.10.3-tinycore64
Code: [Select]
tce-load -iw compiletc.tcz
tce-load -iw perl5.tcz
tce-load -iw ncursesw-dev.tcz
tce-load -iw bc.tcz
tce-load -iw glibc_apps.tcz
tce-load -iw elfutils-dev.tcz
tar -xvf linux-5.10.3-patched.txz
cd linux-5.10.3
make mrproper
cp ../config-5.10.3-tinycore64 ./.config
make oldconfig
make menuconfig
Choose what I need:TARGET CORE
Device Driver-- <M>  Generic Target Core Mod (TCM) and ConfigFS Infrastructure
<M>  TCM/IBLOCK Subsystem Plugin for Linux/BLOCK
<M>  TCM/FILEIO Subsystem Plugin for Linux/VFS
<M>  TCM/pSCSI Subsystem Plugin for Linux/SCSI
<M>  TCM/USER Subsystem  Plugin for Linux
<M>  TCM Virtual SAS target and Linux/SCSI LDD fabric loopback module
<M>  TCM FC fabric Plugin
<M>  Linux-iSCSI.org iSCSI Target Mode Stack
<M>        Chelsio iSCSI target offload driver
<M>  FireWire SBP-2 fabric module
[esc][esc]--[Save]
Code: [Select]
make
......
time: [2:56]  CPU:i5-4210Y SSD:intel S3700 200G RAM: 8G
Generate the following file:
Module.symvers                     1,197 KB
modules.builtin                           15 KB
modules.builtin.modinfo             113 KB
modules.order                            90 KB
System.map                          4,239 KB
vmlinux                               35,200 KB
vmlinux.o                            32,173 KB
vmlinux.symvers                      605 KB
----------------------------------------------
What should I do next? thank you!
Title: Re: Which module supports Linux-IO Target
Post by: Juanito on January 08, 2023, 12:05:11 AM
Your vmlinuz seems large - it should be +/- 5,500KB.

You need to search the source tree for the additional modules you created (named *.ko) and make them into an extension.
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 08, 2023, 12:59:48 AM
I'll try to deal with the module(name*.ko).

My kernel compiled to vmlinux, not vmliunz.
Do you need to compress? "gzip" or "make zImage"

thanks.
Title: Re: Which module supports Linux-IO Target
Post by: Juanito on January 08, 2023, 02:02:36 AM
How big is the file bzImage?
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 08, 2023, 02:46:56 AM
Since it takes too long to compile, I didn't use it
"make bzImage" recompiles.
Not sure what file size this will give you.

I compressed vmlinux with winrar and got a file of 5,406 KB
Estimated compression should be at +/-5,400KB

What am I supposed to do now? Recompile it or gzip it?
Title: Re: Which module supports Linux-IO Target
Post by: Juanito on January 08, 2023, 02:53:17 AM
I asked because I have a feeling that we are using bzImage renamed to vmlinuz - @curaga can confirm.
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 08, 2023, 03:12:01 AM
vmliunx -->vmliunz, what should I do? thanks.

vmliunx is a file generated with make and should not be compressed
Title: Re: Which module supports Linux-IO Target
Post by: Juanito on January 08, 2023, 03:29:32 AM
You can use bzImage directly or rename it to vmlinuz64 (with a "z") and replace the existing vmlinuz64.
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 08, 2023, 04:15:18 AM
I want to compress vmliunx (35.200 KB) to make vmliunz (+/-5.400KB),Just like the official website distribution.
Don't like to rename it because it's too big.

I have searched the documentation and seem to need "objcopy" and "gzip", but don't know the specific command line, please comment.
Title: Re: Which module supports Linux-IO Target
Post by: Rich on January 08, 2023, 05:52:12 AM
Hi Juanito
I asked because I have a feeling that we are using bzImage renamed to vmlinuz - @curaga can confirm.
I just checked my notes and they show:
Code: [Select]
make -j 2 bzImage
cp arch/x86/boot/bzImage /path/to/save/vmlinuz
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 08, 2023, 07:28:47 AM
I looked at the previous post and found "make -j 2 bzImage". I started recompiling it half an hour ago, so it looks like the problem has been fixed.

Extract the driver file:
With experience:
Code: (bash) [Select]
/5.10.3-tinycore64/kernel/drivers/target/
iscsi(folder) loopback(folder) sbp(folder) tcm_fc(folder)
target_core_file.ko target_core_iblock.ko target_core_mod.ko
target_core_pscsi.ko target_core_user.ko
Extract them, compress them into gz format, copy them to the corresponding path,
edit them /5.10.3-tinycore64/kernel/modules.dep, add the path to the driver file.

Is there a clear way to extract driver files? Thanks!

Title: Re: Which module supports Linux-IO Target
Post by: Rich on January 08, 2023, 07:48:48 AM
Hi qingquan
I want to compress vmliunx (35.200 KB) to make vmliunz (+/-5.400KB),Just like the official website distribution. ...
Then you will have to run  make bzImage  because compression is a compile time option.
vmlinuz  is basically a self extracting file so not all of it is compressed.
Found here:
https://superuser.com/questions/445507/how-do-i-compress-a-vmlinux-kernel-into-vmlinuz

You can see that not all of the file is compressed because there are readable strings
present in the file.

These show up in the first 200 bytes of the file:
Code: [Select]
tc@E310:~$ head -c 200 bbox/tempdir/vmlinuz | strings
Use a boot loader.
Remove disk and press any key to reboot...

These show up in the last 2000 bytes of the file:
Code: [Select]
tc@E310:~$ tail -c 2000 bbox/tempdir/vmlinuz | strings
ng output buffer
Out of memory while allocating input buffer
Out of memory while allocating z_stream
Out of memory while allocating workspace
Kernel is not a valid ELF file
Failed to allocate space for phdrs
32-bit relocation outside of kernel!
Avoiding potentially unsafe overlapping memcpy()!
 -- System halted
Failed to get handle for LOADED_IMAGE_PROTOCOL
Failed to allocate lowmem for boot params
Trying to load files to higher address
Failed to allocate memory for 'pci_handle'
Failed to allocate memory for 'rom'
Unsupported properties proto version
Failed to allocate memory for 'properties'
Failed to allocate memory for 'gdt' structure
Failed to allocate memory for 'gdt'
efi_relocate_kernel() failed!
initrd=
Failed to read rom->vendor
Failed to read rom->devid
efi_main() failed!
exit_boot() failed!
nokaslr
quiet
efi=
nochunk
Failed to handle fs_proto
Failed to open volume
Failed to open file:
Failed to get file info size
Failed to get initrd info
EFI stub: ERROR: Failed to alloc mem for file handle list
Failed to alloc mem for file info
EFI stub: ERROR: Failed to alloc highmem for files
EFI stub: ERROR: We've run out of free low memory
EFI stub: ERROR: Failed to read file
EFI stub: ERROR: Failed to allocate usable memory for kernel.
EFI stub: UEFI Secure Boot is enabled.
EFI stub: ERROR: Could not determine UEFI Secure Boot status.
Unable to allocate memory for event log
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 08, 2023, 08:02:29 AM
I've recompiled it with "make -j 2 bzImage",
Replace vmlinuz64 in the iso and start successfully.
old  vmlinuz64      5,241KB
new vmlinuz64     5,442 KB

Now what I'm not sure about is the method of extracting the driver file!
Title: Re: Which module supports Linux-IO Target
Post by: Rich on January 08, 2023, 08:34:00 AM
Hi qingquan
Example for packaging a kernel module:
Code: [Select]
mkdir -p /tmp/pkg/usr/local/lib/modules/4.19.10-tinycore64/kernel/drivers/gpu/drm/nouveau
sudo cp nouveau.ko /tmp/pkg/usr/local/lib/modules/4.19.10-tinycore64/kernel/drivers/gpu/drm/nouveau
sudo chown -R root:root /tmp/pkg/usr
cd /tmp
sudo mksquashfs pkg/ nouveau-4.19.10-tinycore64.tcz
sudo chown tc:staff nouveau-4.19.10-tinycore64.tcz

You would replace  4.19.10-tinycore64  with the version that matches your kernel.
If you are not sure what that is, run  uname -r  to find out.

Instead of  drivers/gpu/drm/nouveau  create  drivers/target/iscsi, drivers/target/loopback, etc.
Then copy the drivers into the appropriate folders.

When you make the extension it will be something like this:
Code: [Select]
sudo mksquashfs pkg/ target-5.10.3-tinycore64.tcz
... Extract them, compress them into gz format, ...
The  squashfs  is already a compressed format. Converting to  .gz  just makes the file bigger.

Quote
... edit them /5.10.3-tinycore64/kernel/modules.dep, add the path to the driver file. ...
No need for that.  tce-load  handles that for you.
Title: Re: Which module supports Linux-IO Target
Post by: Juanito on January 08, 2023, 09:33:42 AM
Just for completeness sake, I checked and "make" builds both the modules and arch/x86_64/boot/bzImage, but not vmlinuz, so vmlinuz is indeed a renamed bzImage.
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 09, 2023, 08:06:18 PM
Hi Juanito Rich
Thanks to juanito and Rich for your encouragement and support,
it was with your help that I started my first kernel compilation journey and finally succeeded after hard work.
Here is a summary to share with those who have not compiled the kernel.

Download address:
http://tinycorelinux.net/12.x/x86_64/release/src/kernel/linux-5.10.3-patched.txz
http://tinycorelinux.net/12.x/x86_64/release/src/kernel/config-5.10.3-tinycore64
Code: [Select]
tce-load -iw compiletc.tcz
tce-load -iw perl5.tcz
tce-load -iw ncursesw-dev.tcz
tce-load -iw bc.tcz
tce-load -iw elfutils-dev.tcz

tar -xvJf linux-5.10.3-patched.txz  #Preferably in a Linux partition
cd linux-5.10.3
sudo make mrproper
sudo cp ../config-5.10.3-tinycore64 ./.config
sudo make oldconfig
sudo make menuconfig
I need the module:TARGET CORE
Device Driver-- <M>  Generic Target Core Mod (TCM) and ConfigFS Infrastructure
<M>  TCM/IBLOCK Subsystem Plugin for Linux/BLOCK
<M>  TCM/FILEIO Subsystem Plugin for Linux/VFS
<M>  TCM/pSCSI Subsystem Plugin for Linux/SCSI
<M>  TCM/USER Subsystem  Plugin for Linux
<M>  TCM Virtual SAS target and Linux/SCSI LDD fabric loopback module
<M>  TCM FC fabric Plugin
<M>  Linux-iSCSI.org iSCSI Target Mode Stack
<M>        Chelsio iSCSI target offload driver
<M>  FireWire SBP-2 fabric module
[esc][esc]--[Save]
Code: [Select]
make -j 2 bzImage #Compile kernel
#.............About half an hour..........
sudo cp arch/x86/boot/bzImage ../vmlinuz64

make  -j 2 modules #Compile module(Inclusion drive)
#.............About an hour and a half..........

#(ctrl+insert):copy,In the terminal window,May be useful
#(shift+insert):paste,In the terminal window,May be useful

sudo mkdir ../target
sudo cp -a ./drivers/target/* ../target
#Tidy up the files in target and keep *.ko
cd ..
sudo mkdir -p tmp/pkg/usr/local/lib/modules/5.10.3-tinycore64/kernel/drivers/target
sudo cp -a ./target/*  tmp/pkg/usr/local/lib/modules/5.10.3-tinycore64/kernel/drivers/target
cd tmp
sudo mksquashfs pkg/  iscsi-target.tcz
sudo chown tc:staff iscsi-target.tcz

Keep well vmlinuz64 and iscsi-target.tcz
Repackage to iso with ezremaster.tcz
Code: (bash) [Select]
depmod -n | grep iscsi
All the necessary modules are here. Great!
Title: Re: Which module supports Linux-IO Target
Post by: patrikg on January 10, 2023, 11:39:38 AM
Hi Juanito Rich
Thanks to juanito and Rich for your encouragement and support,
it was with your help that I started my first kernel compilation journey and finally succeeded after hard work.
Here is a summary to share with those who have not compiled the kernel.

Thank you for letting us know that you succeeded to compile your own kernel, welcome to the Great Linux Community :)
And you show what commands for making it.

To making this little faster you can maybe.
Have seen some another tips to just compile one module that can been see here.
This applies to the old chip soc, but i think this also applies just to another Linux dist's as well.
I think you need some more files from the old kernel compiling not just config.
I think you also need "Module.symvers"

https://yoursunny.com/t/2018/one-kernel-module/
 
Title: Re: Which module supports Linux-IO Target
Post by: Juanito on January 10, 2023, 09:04:38 PM
Unfortunately the Module.symvers trick no longer works with >5.x
Title: Re: Which module supports Linux-IO Target
Post by: patrikg on January 10, 2023, 11:48:10 PM
Hi Juanito

Thanks for letting me know and also the community, but sadly then it's not working for newer versions of kernel.

Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 12, 2023, 02:34:15 AM
Oh, thank you patrikg for joining me. I am a beginner. I started with the application and gradually progressed.

I'm going to configure targetcli on tinycore, which seems like a lot of work and a lot of dependencies.


                                                                                 |--python-pyparsing
                                                                                 |                                   |--filesystem
                                                                                 |--python-urwid----glibc  --linux-api-headers
                                                                                 |                                   |--tzdata
                                                                                 |
                             |--python-configshell-fb>=1.1.fb17-|
                             |
                             |                        |--dbus
                             |                        |
                             |--python-dbus  --glib2
                             |                        |
                             |                        |--gobject-introspection-runtime   
                             |
  targetcli-fb-2.1.54  --python-gobject
                             |
                             |                                             
                             |                                            |--python-pyudev
                             |                                            | 
                             |--python-rtslib-fb>=2.1.fb52  --python-six
                                                                          |
                                                                          |--systemd  --acl
                                                                                           |--audit
                                                                                           |--bash
                                                                                           |--cryptsetup
                                                                                           |--dbus
                                                                                           |--hwdata
                                                                                           |--iptables
                                                                                           |--kbd
                                                                                           |--kmod
                                                                                           |--libacl.so
                                                                                           |--libaudit.so
                                                                                           |--libblkid.so
                                                                                           |--libcap
                                                                                           |--libcap.so
                                                                                           |--libcrypt.so
                                                                                           |--libcrypto.so
                                                                                           |--libcryptsetup.so
                                                                                           |--libelf
                                                                                           |--libgcrypt
                                                                                           |--libidn2
                                                                                           |--libkmod.so
                                                                                           |--libmount.so
                                                                                           |--libp11-kit
                                                                                           |--libp11-kit.so
                                                                                           |--libseccomp
                                                                                           |--libseccomp.so
                                                                                           |--libssl.so
                                                                                           |--libxcrypt
                                                                                           |--lz4
                                                                                           |--openssl
                                                                                           |--pam
                                                                                           |--pcre2
                                                                                           |--systemd-libs
                                                                                           |--util-linux
                                                                                           |--xz
             
Title: Re: Which module supports Linux-IO Target
Post by: gadget42 on January 12, 2023, 03:03:10 AM
Oh, thank you patrikg for joining me. I am a beginner. I started with the application and gradually progressed.

I'm going to configure targetcli on tinycore, which seems like a lot of work and a lot of dependencies.

Code: [Select]
                                                                                 |--python-pyparsing
                                                                                 |                                   |--filesystem
                                                                                 |--python-urwid----glibc  --linux-api-headers
                                                                                 |                                   |--tzdata
                                                                                 |
                             |--python-configshell-fb>=1.1.fb17-|
                             |
                             |                        |--dbus
                             |                        |
                             |--python-dbus  --glib2
                             |                        |
                             |                        |--gobject-introspection-runtime   
                             |
  targetcli-fb-2.1.54  --python-gobject
                             |
                             |                                             
                             |                                            |--python-pyudev
                             |                                            | 
                             |--python-rtslib-fb>=2.1.fb52  --python-six
                                                                          |
                                                                          |--systemd  --acl
                                                                                           |--audit
                                                                                           |--bash
                                                                                           |--cryptsetup
                                                                                           |--dbus
                                                                                           |--hwdata
                                                                                           |--iptables
                                                                                           |--kbd
                                                                                           |--kmod
                                                                                           |--libacl.so
                                                                                           |--libaudit.so
                                                                                           |--libblkid.so
                                                                                           |--libcap
                                                                                           |--libcap.so
                                                                                           |--libcrypt.so
                                                                                           |--libcrypto.so
                                                                                           |--libcryptsetup.so
                                                                                           |--libelf
                                                                                           |--libgcrypt
                                                                                           |--libidn2
                                                                                           |--libkmod.so
                                                                                           |--libmount.so
                                                                                           |--libp11-kit
                                                                                           |--libp11-kit.so
                                                                                           |--libseccomp
                                                                                           |--libseccomp.so
                                                                                           |--libssl.so
                                                                                           |--libxcrypt
                                                                                           |--lz4
                                                                                           |--openssl
                                                                                           |--pam
                                                                                           |--pcre2
                                                                                           |--systemd-libs
                                                                                           |--util-linux
                                                                                           |--xz
           

maybe there is a distribution that already has all this?  perhaps?
https://distrowatch.com/search.php
Title: Re: Which module supports Linux-IO Target
Post by: qingquan on January 12, 2023, 03:38:33 AM
Quote
maybe there is a distribution that already has all this?  perhaps?
https://distrowatch.com/search.php

The website you provided is good, but I can't find "targetcli",
is the distribution you are referring to "targetcli"? Or maybe
I got it wrong. I need "targetcli", or something about it.

 thanks!