Linux archive compression, partition management and LVM management, linuxlvm

Source: Internet
Author: User

Linux archive compression, partition management and LVM management, linuxlvm

Archiving and compression commands:

Command Format:

Gzip [-9] File Name

Bzip2 [-9] File Name

Compressed files in gzip-d. gz format

Bzip2-d. bz2 compressed file


-9: high compression ratio, mostly used for compression;

-D: Decompress the file.

-V: displays the compression process.

-L: displays the internal information of a compressed file.-c


Tip: to view the content in the compressed file, run the zcat command. Bzcat is used for bz2 compression.

If you want to retain the original file during compression, use:

Gzip-9-c man. config> man.config.gz


Lzma command: compress and decompress files. Commands with better compression performance than gzip \ bz2.

Lzma: a compressed file name;

Unlzma decompress the lzma compressed file.


Zip command: A common compression command.

Format: zip compressed file name. zip [source file name]

Option:-r: Used to compress the entire directory.

Unzip: Decompress the zip file.


Xz command: Create and release archive files

Format: xz <source file name>

Option:-d: Used to release an archive.

-K: the source file can be retained during compression.


Tar: Pack and archive Related Files

Format: tar [Option] archive file name source file or directory


-C: Create an archive file;

-X: Release the archive file;

-V: displays the progress;

-F: the compressed file name to be used.

-P: The File Permission is retained during packaging.

-T: view files in the package.

-C: Specify the target folder to be released when unpacking

-Z: Specify to use gzip for compression or decompression;

-J: Call bzip2 for compression or decompression.


Example: tar-czvf etc.tar.gz/etc compression/etc directory

Tar-ztvf etc.tar.gz

Note: The files in the compressed package do not contain the/root directory. In this way, the original directory is not overwritten during decompression. If the root directory is forcibly included, option-P is used.

Tar-zxvf etc.tar.gz decompress the compressed package

Tar-zxvf etc.tar.gz etc/httpd/conf/httpd. conf decompress a file

To use lzma and tar for compression, you can:

Tar-cvf etc.tar/etc

Tar-lzma-cvvf etc.tar. lzma etc.tar

Decompress the package using tar-lzma-xvvf etc.tar. lzma-C/home.


Common backup:


Chmod 700/backup

Tar-cjvf/backup-system-'date too f_0000t'.tar.bz2/etc/home/root/var/spool/cron


Faster archive command: bpzip2. It can quickly archive data using multiple cores.

Tar-cvf etc.tar/etc

Bpzip2 etc.tar // compress the archive file

Bpzip2-d etc.tar.bz2 // extract the file

Bpzip2-p2 etc.tar // use two cores to compress the file



Fdisk-cul: view basic information about a disk partition.

Fdisk options:

-M: View operation instruction help

-P: list the partition information.

-N: Create a partition.

-D: delete a partition.

-T: Change the partition type.

-W: Save the partition settings and exit.

-Q: discard partition settings and exit


For example, fdisk/dev/sdb is used to partition a new hard disk.


Mkfs command: create a file system (Format)

-L: view the partition system

-T: format a partition.

Mkfs-t ext4/dev/sdb1


E2label command: set or view the volume label of the file system

Format: e2label device [new-label]

For example, e2label/dev/sda1 // view the name of the partition volume

E2label/dev/sda1 boot // set the volume name to boot


Query the file system type of a device: blkid (block id) command

View partition format: blkid-s TYPE/dev/sdb1

View All devices mounted on the system: blkid-o device

View the mounted file system type in the system: blkid


Swap partition: equivalent to virtual memory, used when the physical memory is insufficient.

Create swap partition: mkswap

View memory size, including swap partition size: free-m


For example, how to create and use swap partitions:

If you want to disable this swap partition, use swapoff.


If no additional partition exists, you can use the file system as the file partition:

Dd if =/dev/zero of =/tmp/swap bs = 1 M count = 512 // create the/tmp/swap file on the 0 device, which is 512 M.

Mkswap/tmp/swap // create swap Partition

Swapon/tmpswap // use swap Partition


Recommended swap partition values:


Mount and detach a file system:

Mount and umount commands.

Mount format:


Umount format:


View partition size: df-h/mailbox


View mounted partitions:

Mount | grep sdb1 // view the sdb1 partition mounting status

You can mount the optical drive:

Mount-t iso9660/dev/cdrom/media

You can also mount the image file:

Mount-o loop linux. iso/mnt



Automatic mounting: edit the/dev/fstab file

Find the UUID of the partition to be mounted:

Edit the/dev/fstab file and add a mount entry:

Restart the machine and use the mount-a command to re-mount the fstab file partition;


LVM Overview

Related Article

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: 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.