You are not logged in.

#1 2024-03-19 09:12:42

usbpc
Member
Registered: 2021-08-02
Posts: 23

[SOLVED] Kernel module linear missing in 6.8.1-arch1-1

I'm using a "linear raid" for the disk of a virtual machine. It is automatically generated with a script, but it is not working anymore.

The specific error I'm getting is this:

$ sudo modprobe linear                                                                                                                                                                                                               
modprobe: FATAL: Module linear not found in directory /lib/modules/6.8.1-arch1-1

How can I get the linear kernel module, is there now a package I need to install?

Last edited by usbpc (2024-03-21 15:42:50)

Offline

#2 2024-03-19 09:57:49

fmc000
Member
Registered: 2020-05-12
Posts: 85

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

It was removed, along with other options. Please see here, line 3003.


Linux user since 1996. Currently running Arch on an I7 11th gen laptop with root on zfs with zrepl.

Offline

#3 2024-03-19 10:07:56

usbpc
Member
Registered: 2021-08-02
Posts: 23

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

Ah, I see. This is the script qemu script I used so far to make a bootable virtual disk from a physical windows partition:

#!/bin/bash

if [[ $1 == "phy_win11" ]] && [[ $2 == "prepare" || $2 == "stopped" ]] ; then
   if [[ $2 == "prepare" ]] ; then
     # startup logic here
     modprobe loop
     modprobe linear
     LOOP1=$(sudo losetup -f)
     # echo "Loop device 1 is $LOOP1"
     losetup ${LOOP1}  /home/user/.qemu/win_disk_pre.img
     LOOP2=$(sudo losetup -f)
     # echo "Loop device 2 is $LOOP2"
     losetup ${LOOP2}  /home/user/.qemu/win_disk_post.img
     mdadm --build --verbose /dev/md/phy_win11 --chunk=512 --level=linear --raid-devices=3 ${LOOP1} /dev/disk/by-id/nvme-something-part3 ${LOOP2}
   else
     # shutdown logic here
     echo "Stopping array"
     mdadm --stop /dev/md/phy_win11
     echo "removing loopback devices"
     losetup | grep "win_disk" | awk '{print $1}' | xargs sudo losetup -d
   fi
fi

What is the way to do the same with the new kernel?

Last edited by usbpc (2024-03-19 10:09:57)

Offline

#4 2024-03-19 10:24:49

fmc000
Member
Registered: 2020-05-12
Posts: 85

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

No idea, first of all I'd ask the Arch kernel package maintainer why they removed the module, maybe it was done by mistake.


Linux user since 1996. Currently running Arch on an I7 11th gen laptop with root on zfs with zrepl.

Offline

#5 2024-03-19 10:43:19

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,171

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

It was removed *upstream*, not by Arch

Offline

#6 2024-03-19 11:22:54

loqs
Member
Registered: 2014-03-06
Posts: 18,123

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

Offline

#7 2024-03-20 07:01:26

janoschz
Member
Registered: 2015-10-06
Posts: 19

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

usbpc wrote:

I'm using a "linear raid" for the disk of a virtual machine. It is automatically generated with a script, but it is not working anymore.

I was using the linear raid for exactly the same purpose. Have you found a solution to this?

Offline

#8 2024-03-20 07:33:55

frostschutz
Member
Registered: 2013-11-15
Posts: 1,474

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

Unfortunately mdadm gives no deprecated warning whatsoever when creating linear raid, I also do not see it mentioned in mdadm man page. So users who do not build their own kernel are unaware of deprecated status.

You can use device mapper (dmsetup) to emulate it. There are some corner cases (if the block device / partition size is not aligned) since md linear only uses multiple of 64K  (or 512K or otherwise, if specified).

Basically like this https://docs.kernel.org/admin-guide/dev … inear.html but if you have odd block device sizes, you might have to round off the size yourself.

       --rounding=
              Specify the rounding factor for a Linear array.  The size of each component
              will be rounded down to a multiple of this size.  This is a synonym for
              --chunk but highlights the different meaning for Linear as compared to other
              RAID levels.  The default is 64K if a kernel earlier than 2.6.16 is in use,
              and is 0K (i.e. no rounding) in later kernels.

This claims 0K (no rounding) is the default but mdadm --detail displays 64K by default for me. If you used --chunk=512 it should be 512K.

If you do create a dm-linear device to emulate mdadm linear, create it in read-only mode first, and make sure all files are intact, otherwise it could be using wrong offsets for the 2nd, 3rd devices and corrupt data on any writes to those devices.

If your partitions, and partition sizes are MiB aligned then it won't make a difference but if you used bare block devices without partitioning, or files / loop devices with random sizes, it could affect you.

If you are using a partition table, dm-linear by default does not support partitions; you'd have to use kpartx or generate separate partition mappings yourself.

Last edited by frostschutz (2024-03-20 07:34:47)

Offline

#9 2024-03-20 11:31:30

usbpc
Member
Registered: 2021-08-02
Posts: 23

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

janoschz wrote:
usbpc wrote:

I'm using a "linear raid" for the disk of a virtual machine. It is automatically generated with a script, but it is not working anymore.

I was using the linear raid for exactly the same purpose. Have you found a solution to this?

As a "quick fix" I installed and booted the linux-lts kernel. I'll try what frostschutz wrote about device mapper, and when I get it working I will post my new script. If you get it working first then I'd be great if you could post a script.

Offline

#10 2024-03-21 15:27:34

usbpc
Member
Registered: 2021-08-02
Posts: 23

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

Okay, using device mapper I'm now using the following script:

#!/bin/bash

if [[ $1 == "phy_win11" ]] && [[ $2 == "prepare" || $2 == "stopped" ]] ; then
   if [[ $2 == "prepare" ]] ; then
     # startup logic here
     modprobe loop
     table=""
     cur_size=0

     LOOP1=$(sudo losetup -f)
     losetup ${LOOP1}  /home/user/.qemu/win_disk_pre.img
     sector_size=$(sudo blockdev --getsz $LOOP1)
     table+="$cur_size $sector_size linear $LOOP1 0"
     table+=$'\n'
     cur_size=$((cur_size+sector_size))

     win_part="/dev/disk/by-id/nvme-something-part3"
     sector_size=$(sudo blockdev --getsz $win_part)
     table+="$cur_size $sector_size linear $win_part 0"
     table+=$'\n'
     cur_size=$((cur_size+sector_size))

     LOOP2=$(sudo losetup -f)
     losetup ${LOOP2}  /home/user/.qemu/win_disk_post.img
     sector_size=$(sudo blockdev --getsz $LOOP2)
     table+="$cur_size $sector_size linear $LOOP2 0"
     cur_size=$((cur_size+sector_size))
     
     echo "$table" | dmsetup create phy_win11
   else
     # shutdown logic here
     echo "Stopping array"
     dmsetup remove phy_win11
     echo "removing loopback devices"
     losetup | grep "win_disk" | awk '{print $1}' | xargs sudo losetup -d
   fi
fi

This now creates the device

/dev/mapper/phy_win11

instead of the 

/dev/md/phy_win11

it was before.

Offline

#11 2024-03-21 18:48:37

H1GHL4ND3R
Member
Registered: 2024-03-21
Posts: 1

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

I have ran in the same issue (I'm the issue creator on the gitlab), and came up with the same solution
switching from mdadm to dmsetup, this approach and others possible solutions are present on the QEMU`s wiki page

Here a snippet of how i'm doing it:

DEV='/dev/mapper/partition'
DEV_MBR='/root/partition.mbr'

LOOP_DEV=$(losetup -f -L --show ${DEV_MBR}) # -f is deprecated watch out
LOOP_SIZE=$(blockdev --getsz ${LOOP_DEV})
DEV_SIZE=$(blockdev --getsz ${DEV})

TABLE=$(echo -e "0 ${LOOP_SIZE} linear ${LOOP_DEV} 0\n${LOOP_SIZE} ${DEV_SIZE} linear ${DEV} 0")
echo "${TABLE}" | dmsetup create linear_block_dev

# remove
dmsetup remove linear_block_dev

LOOP_DEV=$(losetup -j ${DEV_MBR})
LOOP_DEV=${LOOP_DEV%%:*}
losetup -d "$LOOP_DEV"

Offline

#12 2024-04-17 08:09:00

janoschz
Member
Registered: 2015-10-06
Posts: 19

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

usbpc wrote:

Okay, using device mapper I'm now using the following script:

Thanks a lot! This works flawlessly!

Offline

#13 2024-04-19 23:13:40

nos4a2
Member
Registered: 2024-04-19
Posts: 3

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

janoschz wrote:
usbpc wrote:

Okay, using device mapper I'm now using the following script:

Thanks a lot! This works flawlessly!

Have you made it work, I think I might be following the same blog post as you were, but I'm getting into a lot of issues and not really understanding whats happening.

The blog post is https://simgunz.org/posts/2021-12-12-bo … linux-kvm/

Any help would be apreciated

Offline

#14 2024-08-31 21:18:36

dougvj
Member
Registered: 2023-05-26
Posts: 1

Re: [SOLVED] Kernel module linear missing in 6.8.1-arch1-1

If anyone else is just now discovering this here's a quick and dirty hack to build the md-linear back in the latest kernel.

https://github.com/dougvj/md-linear

This allowed me to pull data off an old array. I recommend only using it for recovery purposes

Offline

Board footer

Powered by FluxBB