Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos7 disk partitioning, formatting and LVM management, logical volume snapshots

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Disk Management of centos7

Centos7 disk management is not much different from the previous system, you can use disk tools or command tools (such as: fdisk,gdisk, parted) to manage hard disk devices, fdisk can configure MBR format, gdisk can configure gpt format, parted can be configured after both.

Traditional hard disk partitions are in MBR format, MBR partition is located in sector 0, a total of 512 bytes, the first 446 bytes are grub bootstrap, and the middle 64 bytes are partition tables, because each partition needs 16 bytes, so there can only be 4 main partitions and extended partitions. More than 4 can only be represented by setting logical partitions on extended partitions, and the size of each partition cannot exceed 2T. The last two bytes of the MBR are closing symbols.

GPT format, breaking the limitation of MBR rules, can set up to 128partitions. The size of partitions varies according to the operating system, but all break through the 2T space limit, support volume sizes up to 18EB (1EB-1024PB, 1PB=1024TB), allow primary disk partitions and backup disk partition tables to be used for redundancy, and support unique disk and partition ID (GUID).

One: let's show you how to create a swap partition on centos7, which is about the same as the previous version.

1) first add the required hard disk for the virtual machine

There are two ways to make swap partitions:

1. Use the entire partition as the swap partition

Enter fdisk / dev/sdb to start making a swap partition: enter n to create a new primary partition, t change iD to the swap type of 82, and finally press w to save and exit

Press p to see if the created swap partition has been created successfully

Then start formatting the swap partition

Check the size of the swap

Then open the swap partition, check the size of the swap partition again, and find that it is 8G more than the previous size.

Finally, the swap partition is automatically mounted in the, / etc/fstab configuration file

two。 Is to create a file block that uses the space occupied by the file as a swap

Use the dd command to create a swapfile file block in the root directory with a size of 2G

Then check the permissions that were successfully created and set to 600

After that, format the file block to swap, enable swap, and check the size again by 2G.

Second: create logical volumes and create snapshots of logical volumes

There are also two ways to create a snapshot of a logical volume

1. Traditional tools create logical volumes and create snapshots

First create a physical volume

View physical volume created successfully

Create a volume group

Finally, create a logical volume

Format the created logical volume as a file system of xfs

The newly created logical volume can be automatically mounted on boot.

Mount-a makes the mount effective immediately

Mount to see if the mount is successful.

Then go to the mounted directory to create data

Start creating a snapshot of the logical volume

Check that the snapshot was created successfully

Then simulate data loss and delete all data under data

There are two ways to recover data:

1. Unmount the previous logical volume, and then mount a snapshot of the logical volume

two。 You can write the contents of the snapshot back to the original lvm through lvconvert. Unmount the original logical volume first # umount / dev/vg/lv00 execute lvconvert to merge the snapshot data into the original logical volume # lvconvert-- merge / dev/vg00/lvsp00 finally mount the original logical volume to check whether the data is recovered successfully

The second way to create a snapshot of a logical volume:

To prepare for ssm, on CentOS/RHEL 7, you need to install the system storage manager first. You can use rpm or yum tools

Then use ssm tool to realize the snapshot function of logical volume.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report