LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-27-2017, 09:28 AM   #1
Roberto Alvarez
LQ Newbie
 
Registered: Aug 2010
Location: Staten Island, New York
Distribution: Slackware
Posts: 13

Rep: Reputation: 2
Is there a way to prepend a CPIO archive file to a Gzip archive file?


Is there a way to prepend a CPIO archive file to an Gzip archive file?

The following is a quotation from another post:


Yes iucode_tool and intel-microcode are what you need.

(1) build and install iucode_tool from SBo

(2) build and install intel-microcode from SBo, this creates a file /boot/intel-ucode.cpio

(3) If you do not use an initrd at the moment, use /boot/intel-ucode.cpio as your initrd -- for example, with lilo you will have to modify /etc/lilo.conf and then re-run /sbin/lilo, or with elilo you will have to edit /boot/efi/EFI/Slackware/elilo.conf and copy /boot/intel-ucode.cpio to /boot/efi/EFI/Slackware/

(4) If you do use an initrd (presumably /boot/initrd.gz) do this:

Code:
cp /boot/initrd.gz /tmp
cat /boot/intel-ucode.cpio /tmp/initrd.gz > /boot/initrd.gz

[/B]
and then (important) re-run /sbin/lilo, or copy the new /boot/initrd.gz to /boot/efi/EFI/Slackware, or do whatever your own boot loader wants. And you will have to repeat this after every time you run mkinitrd.

I wonder, if someone added support to mkinitrd for /boot/intel-ucode.cpio and sent a patch to volkerdi, would that be welcomed?
_______________

I copied the above lines from a post ([SOLVED] Broken HyperThreading in SkyLake and Kaby Lake Processors), on a reply to it by senior member 55020.

The problem does not affect me because I have an older system: core i5-2500K @3.30 with an Asus P8Z77-V LX motherboard. I am using Slackware64 14.2 with linux 4.4.38 and GNU coreutils 8.25. Normally I use the the vmlinuz-generic kernel with initrd. Nevertheless it seems a good thing to keep track of potential flaws and been able to fix them. Asus no longer issues upgrades for the bios (last one I got was from 1915, probably earlier). The last microcode for the processor was issue 20150121; although according to the intel website 201705 applies to all intel processors.

The above recommendation does as it pertain to kernel huge but not with generic+intitrd.

The problem seems that it is not possible to use 'cat' to prepend intel-ucode-cpio (a CPIO archive) to the inird.gz (a Gzipped CPIO archive), instead cat override initrd (the compressed CPIO archive).

The result is that with vmlinuz-generic-4.438 the system hangs. If I want to use the microcode I have to revert to using a huge kernel.

So my question is: Is there a way to prepend a CPIO archive file to an Gzip archive file?
 
Old 06-27-2017, 11:58 AM   #2
bassplayer69
Member
 
Registered: Jul 2007
Location: In a van down by the river...
Distribution: MX Linux 21
Posts: 237

Rep: Reputation: 56
Just out of curiosity, would the following work for you?

cat /boot/intel-ucode.cpio | gzip > /boot/initrd.gz

then run lilo.
 
Old 06-27-2017, 12:18 PM   #3
Darth Vader
Senior Member
 
Registered: May 2008
Location: Romania
Distribution: DARKSTAR Linux 2008.1
Posts: 2,727

Rep: Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247
Code:
cat /boot/intel-ucode.img /boot/initramfs-linux.img > /boot/initramfs-merged.img
The goods only know why we should stuck in a specific name of initrd...

PS. When you merge two initrd, both should be the same, compressed or not.
 
Old 06-27-2017, 12:21 PM   #4
dejank
Member
 
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
Quote:
Asus no longer issues upgrades for the bios (last one I got was from 1915, probably earlier).
Quote:
The result is that with vmlinuz-generic-4.438 the system hangs. If I want to use the microcode I have to revert to using a huge kernel.
Far from expert, but think that upgrade of BIOS is needed for microcode updates to work properly.
 
Old 06-27-2017, 12:21 PM   #5
55020
Senior Member
 
Registered: Sep 2009
Location: Yorks. W.R. 167397
Distribution: Slackware
Posts: 1,307
Blog Entries: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by Roberto Alvarez View Post
The problem seems that it is not possible to use 'cat' to prepend intel-ucode-cpio (a CPIO archive) to the inird.gz (a Gzipped CPIO archive), instead cat override initrd (the compressed CPIO archive).

So my question is: Is there a way to prepend a CPIO archive file to an Gzip archive file?


The kernel knows exactly what to do with an uncompressed cpio followed by a compressed cpio in one file. See https://www.kernel.org/doc/Documenta...-microcode.txt

What I posted works for me, and works for multiple other people. It's probable your initrd and/or intel-ucode.cpio and/or bootloader config is broken some other way.

If I was you, I would start again with mkinitrd. Verify the contents of intel-ucode.cpio. Be sure to copy the initrd.gz somewhere else, because 'cat a b >b' won't work. And be sure to update your bootloader before you reboot.

Last edited by 55020; 06-27-2017 at 12:23 PM.
 
2 members found this post helpful.
Old 06-27-2017, 12:29 PM   #6
Darth Vader
Senior Member
 
Registered: May 2008
Location: Romania
Distribution: DARKSTAR Linux 2008.1
Posts: 2,727

Rep: Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247
BTW, maybe the system hang is similar with my (not so fun) adventures on Slackware 14.2, where its graphics stack, who know? from kernel to whatever GL crap, well... something hate with passion my unlucky hardware. SIX computers in line.

Usually I call that naughty behavior: "it freeze", but also "it hang" is a good word to describe the phenomena.

IF that OP's computer is not on critical duty, I suggest using/upgrading to Slackware-current, which acts like a nice pal, at least on my hardware.

Last edited by Darth Vader; 06-27-2017 at 12:31 PM.
 
Old 06-27-2017, 03:30 PM   #7
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Roberto Alvarez --

55020's instructions worked perfectly for me this morning on two different kernels.

But one thing not explicitly stated in 55020's original instructions is that you've got to first create an initrd.gz file as you've always done for your kernel.

Once you've got a /boot/initrd.gz file for your new kernel, proceed:

Code:
cp /boot/initrd.gz /tmp/
cat /boot/intel-ucode.cpio /tmp/initrd.gz > /boot/initrd.gz
substitute the `basename` of your initrd.gz as required ...

edit /etc/lilo.conf with the new /boot/initrd.gz file ; run lilo and reboot.

HTH.

-- kjh
 
Old 06-27-2017, 09:55 PM   #8
Roberto Alvarez
LQ Newbie
 
Registered: Aug 2010
Location: Staten Island, New York
Distribution: Slackware
Posts: 13

Original Poster
Rep: Reputation: 2
I thank all the replies for their attention and help, but the question still stands--How do we prepend a type of archive to another type of archive?

My understanding is that cat is used to concatenate 'files' not archives or directory trees. Sorry I don't think my system is broken.

I do use a generic kernel with an initrd and elilo for boot loader. My understanding so far is that in order to modify the system initialization one modifies the /boot/initrd-tree, then run mkinitrd in order to sync the tree with the contents of the initrd file, and then, in my case run eliloconfig.

The problem that the alteration of this file (initrd.gz) poses is that the content is organize as a directory tree which by the way is organize in alphabetical order. In it a directory 'kernel' would follow a dirictory 'bin'.

In our case the folder 'kernel' has to precede the folder 'bin',within the tree, for the early application of the microcode.

The name 'kernel' in the intel-ucode.cpio file is relevant, so are the names of the folders inside the initrd-tree, unlike the name of the initrd which is define in whatever configuration/initialization file as needed by the particular boot loader.

I have tried many things today in order to circumvent this problem with no success. I tried using cat, gzip, KDE's arc. I tried manually adding the contents of the intel-ucode.cpio and altering the top folder's name by prepending an 'a' to its name--the boot loader ignores the file.
I will continue looking, perhaps their is a configuration file or a means of aliasing to force the presedence of the microcode to the booting process.

Thankyou again and excuse the lateness (and the length) of my response.
 
Old 06-28-2017, 02:35 AM   #9
phenixia2003
Senior Member
 
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
Hello,

Quote:
Originally Posted by Roberto Alvarez View Post
I thank all the replies for their attention and help, but the question still stands--How do we prepend a type of archive to another type of archive?

My understanding is that cat is used to concatenate 'files' not archives or directory trees. Sorry I don't think my system is broken.

I do use a generic kernel with an initrd and elilo for boot loader. My understanding so far is that in order to modify the system initialization one modifies the /boot/initrd-tree, then run mkinitrd in order to sync the tree with the contents of the initrd file, and then, in my case run eliloconfig.

The problem that the alteration of this file (initrd.gz) poses is that the content is organize as a directory tree which by the way is organize in alphabetical order. In it a directory 'kernel' would follow a dirictory 'bin'.

In our case the folder 'kernel' has to precede the folder 'bin',within the tree, for the early application of the microcode.

The name 'kernel' in the intel-ucode.cpio file is relevant, so are the names of the folders inside the initrd-tree, unlike the name of the initrd which is define in whatever configuration/initialization file as needed by the particular boot loader.

I have tried many things today in order to circumvent this problem with no success. I tried using cat, gzip, KDE's arc. I tried manually adding the contents of the intel-ucode.cpio and altering the top folder's name by prepending an 'a' to its name--the boot loader ignores the file.
I will continue looking, perhaps their is a configuration file or a means of aliasing to force the presedence of the microcode to the booting process.

Thankyou again and excuse the lateness (and the length) of my response.
In case of trouble with a cpio+initrd archive, you can check its content as in example below :

1. Extract the cpio archive

Code:
$ mkdir -p /tmp/cpio_tmp
$ cd /tmp/cpio_tmp
$ cpio -id</boot/initrd-generic-4.4.74-intel-microcode.gz
1922 blocks

$ tree .
.
└── kernel
    └── x86
        └── microcode
            └── GenuineIntel.bin

3 directories, 1 file
2. Extract the gzip archive which is, in the example above 1922 blocks after the cpio archive.

Code:
$ mkdir -p /tmp/initrd_tmp
$ cd /tmp/initrd_tmp
$ dd if=/boot/initrd-generic-4.4.74-intel-microcode.gz  of=initrd.gz bs=512 skip=1922
12692+1 records in
12692+1 records out
6498656 bytes (6.5 MB, 6.2 MiB) copied, 0.0190934 s, 340 MB/s

$ gunzip initrd.gz
$ cpio -id<initrd
38216 blocks

$ ls 
bin  init         keymap  load_kernel_modules  mnt        root     run   usr
dev  initrd       lib     luksdev              proc       rootdev  sbin  wait-for-root
etc  initrd-name  lib64   lukskey              resumedev  rootfs   sys
--
SeB
 
Old 06-28-2017, 04:16 AM   #10
audriusk
Member
 
Registered: Mar 2011
Location: Klaipėda, Lithuania
Distribution: Slackware
Posts: 360

Rep: Reputation: 199Reputation: 199
Quote:
Originally Posted by Roberto Alvarez View Post
I thank all the replies for their attention and help, but the question still stands--How do we prepend a type of archive to another type of archive?

My understanding is that cat is used to concatenate 'files' not archives or directory trees.
Roberto, your understanding here is correct, cat indeed simply concatenates files. In general this won't do any good for compressed archives, but in this case the kernel code is designed to handle such concatenated initrd file.

If you have read the link provided by 55020 carefully, you have noticed the following:
Quote:
The format of the combined initrd image is microcode in cpio format followed by the initrd image (maybe compressed). Kernel parses the combined initrd image during boot time.
And the last line of provided example script:
Code:
cat ucode.cpio /boot/initrd-3.5.0.img >/boot/initrd-3.5.0.ucode.img
Please note that the output filename differs from original initrd filename. As others have already noted, this is a very likely place you have made a mistake.
 
Old 06-28-2017, 09:10 AM   #11
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Technically, you can't really prepend to a file, you have to append the second thing to the first. cat concatenates things in the order given.
 
Old 06-28-2017, 11:03 AM   #12
Roberto Alvarez
LQ Newbie
 
Registered: Aug 2010
Location: Staten Island, New York
Distribution: Slackware
Posts: 13

Original Poster
Rep: Reputation: 2
If you have read the link provided by 55020 carefully, you have noticed the following:
Quote:
The format of the combined initrd image is microcode in cpio format followed by the initrd image (maybe compressed). Kernel parses the combined initrd image during boot time.
And the last line of provided example script:

Code:
cat ucode.cpio /boot/initrd-3.5.0.img >/boot/initrd-3.5.0.ucode.img

Please note that the output filename differs from original initrd filename. As others have already noted, this is a very likely place you have made a mistake.
__________________
Audrius Kažukauskas

neither initrd.gz nor intel-ucode.cpio are raw disk data. They are differen archives. Perhaps in some distribution (other than Slackware), that is the case.

In inspecting a flash memmory stick that I use for installing Slackware, I found an image,

bash-4.3$ cd /run/media/roberto/SlackDVD/EFI/BOOT
bash-4.3$ ls -l initrd.img
-rw-r--r-- 1 roberto roberto 39424516 Jun 24 2016 initrd.img
bash-4.3$

which is a raw data disk. I will not tweak with things I do not understand.
But this I know cat will not concatenate the contents of a CPIO archive with a compress Gzip file; and if you pipe it to a new file, it simply will write the contents of the CPIO file into it. Might as well use mv.!

Roberto Alvarez
 
Old 06-28-2017, 01:00 PM   #13
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Roberto Alvarez --

The cat command will concatenate one-or-more 'source' files of any type to stdout.

The cat command know nothing about the content of the source files -- it simply spits the bits from each file to stdout in the order you specify

Like most of the good old UNIX commands, they do exactly what you tell them to do -- even if it makes no sense.

There is no guarantee that the results of a cat command will be useful for any purpose.

However, in the case of the intel-ucode.cpio + initrd.gz source files, as 55020 alread said, the Kernel understands that particular concatenation and it will do 'the right thing' with it.

man cat

One common gotcha with cat ( actually a gotcha with the shell ) is to redirect output into one of your source files.

For example this will not work as one might imagine:
Code:
cat foo bar baz > foo
That's because the shell truncates the target file ( foo ) before it begins the cat operation so when cat 'sees' foo, foo has been truncated

! dooh ! been there, done that !!

HTH.

-- kjh
 
1 members found this post helpful.
Old 06-29-2017, 01:03 PM   #14
Roberto Alvarez
LQ Newbie
 
Registered: Aug 2010
Location: Staten Island, New York
Distribution: Slackware
Posts: 13

Original Poster
Rep: Reputation: 2
kjh
Quote:
There is no guarantee that the results of a cat command will be useful for any purpose
Indeed, this is what happens in my case. If you have actually concatanated heterogeneous files with cat and gotten something different, please let me know. It might be that the instance of the program I have is defective or something.

During reboot the system froze and a message of something like kernel panic and not sysncing, is the same that happens when you forget to update the initrd.gz file or to run mkinitrd.

I tried, in a mock directory many combinations of files processed through cat: gzip-img gzip-cpio cpio-img in different order and in all instances got incomplete files with the content of the first readable and the rest loss, although in some cases the math of adding the single files to the combined, match. Also when the resuling file was aknowledge as gzip, the compression ratio % revealed with gzip -l was often exhorbitant (in the order of 700 and up) and in some cases negative.
 
Old 06-29-2017, 01:08 PM   #15
Roberto Alvarez
LQ Newbie
 
Registered: Aug 2010
Location: Staten Island, New York
Distribution: Slackware
Posts: 13

Original Poster
Rep: Reputation: 2
About the question of presedence, I read it first from someone who uses Syslinux in his machine. I have never used this bootloader but I am contemplating trying it.

It has a very pertinent feature: it accepts multiple files in the initrd= directive and it executes them in the order given.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error: unpacking of archive failed on file ........:cpio: Digest mismatch adams kpewa Linux - Newbie 0 12-13-2016 10:42 AM
[SOLVED] how to archive torrent file + the iso files , like the ova archive of virtual box jheengut Linux - Software 2 12-22-2013 05:04 PM
rpm install proble--cpio: Archive file not in header mlgill Linux - Newbie 0 07-24-2004 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration