The officially official Devuan Forum!

You are not logged in.

#1 Re: Off-topic » Refracta-SnapShot - Question » 2024-04-22 12:19:43

Dear fsmithred, The new [/bin/refractasnapshot-gui] version 10.4.0 does not solve my problem.

Problem:
"Compression error for type [cpio archive]" when extracting initrd.img-6.5.0-26-generic.

Investigation:
1. [xed /var/log/refractasnapshot.log]:

Replace "xed" with your favorite editor.

++ file -L /boot/initrd.img-6.5.0-26-generic
++ egrep -o 'Zstandard compressed|gzip compressed|XZ compressed|cpio archive'
+ initrd_compression='cpio archive'
+ '[' '!' 'cpio archive' ']'
+ popd
+ '[' 'cpio archive' == 'Zstandard compressed' ']'
+ '[' 'cpio archive' == 'gzip compressed' ']'
+ '[' 'cpio archive' == 'XZ compressed' ']'
+ popd
+ echo 'Initrd is extracted'
+ edit_initrd
+ pushd /tmp/extracted
+ '[' -f conf/conf.d/cryptroot ']'
+ '[' -f cryptroot/crypttab ']'
+ '[' -f conf/conf.d/resume ']'
+ '[' -f conf/conf.d/zz-resume-auto ']'
+ popd
+ rebuild_initrd
+ pushd /tmp/extracted
+ '[' 'cpio archive' == 'gzip compressed' ']'
+ '[' 'cpio archive' == 'XZ compressed' ']'
+ '[' 'cpio archive' == 'Zstandard compressed' ']'
+ echo 'Compression error for type [cpio archive]...'
+ exit 1

2. The command [file -L /boot/initrd.img-6.5.0-26-generic] returns "ASCII cpio archive (SVR4 with no CRC)". This information is flaw.

Cause:
Linux Mint 21.3 uses an initrd.img file of type "initramfs" as of kernel version 5.15.0-94, and cannot be extracted/rebuilded using the cpio command.

Solution:
Use unmkinitramfs to extract- and mkinitramfs to rebuild the initrd file.

(tested on kernel: vmlinuz-6.5.0-26-generic, initrd: initrd.img-6.5.0-26-generic, distro: Linux Mint 21.3, desktop: Cinnamon 6.0.4, base: Ubuntu 22.04)

> [sudo xed /bin/refractasnapshot-gui]
> search for: "extract_initrd ()"

> replace:
from: extract_initrd () {
to:    }
with:

extract_initrd () {
# Customized {FillInCurrentDateTime} by {FillInYourName} 

    rm -rf /tmp/extracted
    mkdir /tmp/extracted
    pushd /tmp/extracted	
    
    unmkinitramfs "$initrd_image" "/tmp/extracted"
    
    if [ $? -eq 0 ]; then 
        echo "SUCCESS: unmkinitramfs has successfully extracted the original Initrd to /tmp/extracted" 
    else 
        echo "ERROR: unmkinitramfs has failed to extract the original Initrd"
        echo "Script execution terminated"
        rm -rf /tmp/extracted
        exit 1 
    fi
    popd
}

> search for: "rebuild_initrd ()"

> replace:
from: rebuild_initrd () {
to:    }
with:

rebuild_initrd () {
# Customized {FillInCurrentDateTime} by {FillInYourName}

    pushd /tmp/extracted
    mkinitramfs -c gzip -o ${work_dir}/iso/live/${initrd_image##*/}

    if [ $? -eq 0 ]; then 
        echo "SUCCESS: mkinitramfs has successfully rebuilded the custom Initrd" 
    else 
        echo "ERROR: mkinitramfs has failed to rebuild the custom Initrd"
        echo "Script execution terminated"
        rm -rf /tmp/extracted
        exit 1 
    fi
    popd
    rm -rf /tmp/extracted
}

Notice that the container is compressed using the gzip algorithm. I guess this solution can also help Ubuntu users.

Nonetheless, still very happy using Refracta Snapshot!

Board footer

Forum Software