Cpio instance description

Source: Internet
Author: User

Function Description: backup files.

 

Note: cpio is a tool used to create and restore backup files.ProgramIt can be used to remove files in the cpio, IMG, or tra backup files.

 

Cpio file type judgment:

[Root @ localhost test] # file test. cpio
Test. cpio: ASCII cpio archive (svr4 with no CRC) 

 

Cpio instance description

1. Common Operation Modes

(1) backup: cpio-ocvb> [file | device]
(2) Restoration: cpio-ivcdu>
[File | device]
(3) view: cpio-ivct>[File | device]

2. related examples

1) cpio-out mode

(1) Find all the files in the current directory and package them into a cpio compressed file.
Find.-depth | cpio-ocvb> Backup. cpio or find.-Depth-Print | cpio-ocvb> Backup. cpio
Note: The archive file created by cpio consists of the file header and file data. The file header contains information about the corresponding file. Such as the file uid, GID, number of connections, and file size. The advantage is that the hard connection can be retained, and the timestamp is retained by default during restoration without the limit on the length of the file name.

(2) Add the inittab file in the current directory to the initrd. cpio package
Command 1: find.-Name inittab-depth | cpio-ovcb-a-f initrd. cpio
Command 2: find.-Name inittab-depth | cpio-ovcb-a-o initrd. cpio
Command 3: find.-Name inittab-depth | cpio-ovcb-A -- quiet-O initrd. cpio(-- Quit: indicates that the copy block is not displayed)

 

Cpio -- absolute-filenames-VTC <boot. cpio(Do not ignore "/" at the top of the file name list)
Cpio -- no-absolute-filenames-VTC <boot. cpio(By default, the first part of the file in the file list is ignored.

 

(2) Extract files from the cpio compressed package
Cpio -- absolute-filenames-icvu <test. cpio (extract the file to the original location and change the time attribute of each file to the current time)
Cpio -- absolute-filenames-icvum <test. cpio (extract to the original location without changing the time attribute of each extracted file)

 

Cpio-icvu <test. cpio (decompress it to the current directory)OrCpio-icvum <test. cpio

 

(3) Rename the interaction between the decompressed files when the cpio is unwrapped
Cpio-icvdu-r <grub. cpio

 

(4) decompress the files in the cpio package and input the standard output.
Cpio-icvu -- to-stdout <grub. cpio
Note: Since the standard output is extracted, the-D parameter cannot be used.

 

3) cpio-out mode

(1) copy and change the owner and group of the file
Find.-Depth| Cpio-r ruanxi: ruanxi-PL/backup/

 

4) analyze the initrd-2.6.30.9.img file under the system directory/boot
[Root @ server TMP] # file/boot/initrd-2.6.30.9.img
/Boot/initrd-2.6.30.9.img: gzip compressed data, from UNIX, last modified: Fri Nov 13 22:12:38 2009, Max Compression
# As you can see above,Initrd-2.6.30.9.img it is a GZIP file
-------------------------------------------------------------------
[Root @ server TMP] # cp/boot/initrd-2.6.30.9.img./initrd.img.gz
[Root @ server TMP] # gzip-D initrd.img.gz
# Decompress the file using the gzip command
-------------------------------------------------------------------
[Root @ server TMP] # file initrd. img
Initrd. IMG: ASCII cpio archive (svr4 with no CRC)
# We can see that the extracted file is a cpio compressed package.
[Root @ server TMP] # cpio-ivcdu <initrd. img
# Use the cpio command to solve the problemPackage

 

from: http://hi.baidu.com/9812658/blog/item/8ada5e0187890183d53f7c65.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.