The following linux commands will explain how to extract a content from compressed initrd initial RAM disk file. Before we begin we need to take care of prerequisites:
# apt-get install p7zip-full
The above command will install 7z and 7za file archivers which we will use to decompress and compress our initrd file.
To begin, first locate your initrd.lz
RAM disk file:
ls -l total 24692 -rw-r--r-- 1 root root 25281685 Dec 14 10:09 initrd.lz
Create a new directory to hold extracted files and directory structure from initrd.lz
:
# mkdir temp # ls initrd.lz temp
In this step we extract the content of initrd.lz
temp directory. Navigate to temp
directory and execute:
# cd temp/ # 7z e -so ../initrd.lz | cpio -id 7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 p7zip Version 9.20 (locale=en_AU.UTF-8,Utf16=on,HugeFiles=on,4 CPUs) Processing archive: ../initrd.lz Extracting initrd Everything is Ok Size: 68728832 Compressed: 25281685 134236 blocks
All files from our initrd file are now extracted and stored in temp
directory. At this stage, its time to make any desired changes. Once you have made your changes it is time to repackage our new initrd file. Still in the temp
directory execute:
# find | cpio -o -H newc > ../initrd_new 134236 blocks
The above command have created a new file initrd_new
:
# ls initrd.lz initrd_new temp
All what remains is to use compression to get initrd_new.lz
initial RAM disk file:
# 7z a -m0=lzma:a=1 initrd_new.lz initrd_new 7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 p7zip Version 9.20 (locale=en_AU.UTF-8,Utf16=on,HugeFiles=on,4 CPUs) Scanning Creating archive initrd_new.lz Compressing initrd_new Everything is Ok
Rename you new initrd file as appropriate.