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

Simple partitions and file systems in the management system of [basic]

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

Mbr 446 bytes (boot CD read system partition)

Mpt primary partition table 64 bytes (record partition information) (can be divided into several regions to see here)

55aa: hard disk identification

P Primary Partition E extended Partition logical Partition (partition in extended partition)

How to create a new partition

1. Partition the hard disk first

Fdisk / dev/vdb (disk that you want to partition)

Finally, wq exits the save

Partprobe synchronizes the partition table

Cat / proc/partitions view partitions recognized by the system

two。 The device needs to be formatted after partition.

Mkfs.XXX

Write to / etc/fstab for permanent mount

3. After changing the partition

Enter partprobe synchronization Partition Table

Cat / proc/partitions view partitions recognized by the system

Second, establish the swap partition

1. Modify partition ID to ID of swap (82)

Swapon-s to view swap partition status

Fdisk / dev/vdb5

Create a partition and modify the partition id to 82 by t

Partprode synchronizes the partition table

Cat / proc/partitions view partitions recognized by the system

two。 Format swap Partition

Mkswap / dev/vdb5

Swapon-a / dev/vdb5 to see if there is any error

Swapon-s / dev/vdb5 scan swap partition information

3. Permanently mount swap

Vim / etc/fstab

Note (the first swap is the mount point, and the second is the mount type)

4. If the disk runs out of space, you can use files to create swap partitions

First create an empty 1G file (line 1)

View empty file size (2)

Format this file in swap (3)

Error checking this file (4)

View swap partitions (6)

Stop swap (7)

Modify the priority of swapfile to give priority to vdb5

View swap Partition

Priority changed to 1

5. Delete swap Partition

Swapon-s = cat / proc/swaps

Close the swap partition before deleting it

Swapoff / dev/vdb5

Swapoff / mnt/swapfile

Rm-fr / mnt/swapfile

Fdisk / dev/vdb Delete swap Partition

Partprobe synchronizes the partition table

Check if there is any information in / etc/fstab and delete it at the same time.

Third, allocate disk quota to users

1. First divide a partition, and format the partition in xfs mode

Add partition quotas for users and groups

Activate the partition quota function for users and groups

(U user, g group, v display process)

two。 Permanently activate quota function

Modify / etc/fstab

Chmod 1777 / public

Modify the quota of user student

Blocks (number of writes) soft (warning value of amount of writes)

Hard (maximum writes) inodes (maximum number of files)

Switch to student user authentication

3. Turn off the quota function

Quotaoff / dev/vdb5

IV. Disk array

Divided into hard raid and software raid

1. Soft raid 1 ()

Create three partitions

Change id to fd

Monitoring command

Watch-n 1 cat / proc/mdstat

Commands that make up disk arrays

-C specifies the name after the array

-a create a name if the name does not exist

-l specify the array level (0pl 1pm 5)

-n number of array partitions

-x number of remaining partitions (if the previous partition is hung up)

two。 Disk array device management

Mdadm-D / dev/md0 view device configuration information

Mdadm / dev/md0-f / dev/vdb5 manually damage the equipment

Mdadm / dev/md0-r / dev/vdb5 removal device

Mdadm / dev/md0-a / dev/vdb5 recovery device

Mdadm-S / dev/md0 # # stop the device

5. Disk encryption (luks encryption) (cannot be partitioned to an extension)

1. Encrypt

Cryptsetup luksFormat / dev/vdb5 (encrypting partitions)

Cryptsetup open / dev/vdb5 qqq (decrypted to qqq partition)

There is qqq in / dev/mapper/

Mkdf.xfs / dev/mapper/qqq format encryption device

Mount / dev/mapper/qqq / mnt/ mount

Write data in it. And then

Umount / dev/mapper/qqq

Cryptsetup close qqq (turn off encrypted disk)

two。 Remove encryption

Cryptsetup close qqq first

Then format and encrypt the / dev/vdb5 and remove it.

VI. Lvm management

Lvm

(logical volume. A device management software that allows the device to scale freely)

Pv physical Volume

Vg physical volume group

Pe physical extension, the smallest storage unit of lvm

Lvm monitoring command

Watch-n 1

'pvs;echo===;vgs;echo===;lvs;echo====;df-h / mnt'

The production of 1.lvm

First partition and change ID to 8e

Establishment of 2.lvm

Pvcreate / dev/vdb1 turns physical partitions into physical volumes

Vgcreate vg0 / dev/vdb1

(make a physical volume group vg0 with the physical volume / dev/vdb1)

Lvcreate-L 200m-n lv0 vg0

(set up lv0 device-L to specify device size-n to specify device name in vg0 group)

Mkfs.xfs / dev/vg0/lv0 mount / dev/vg0/lv0 / mnt

After formatting, mount to mnt

Expansion of 3.lvm

The Xfs file system can be expanded but not reduced

Lvextend-L 500m / dev/vg0/lv0 hard disk expands lvm

Expansion of the xfs_growfs / dev/vg0/lv0 file system

Reduction of 4.lvm

Ext file systems can be expanded or shrunk

(1) lvm expansion

Lvextend-L 2G / dev/vg0/lv0 expands lvm physical devices to 2G

Resize2fs / dev/vg0/lv0 expands the file system to lvm size

(2) expansion of vg

Pvcreate / dev/vdb2 adds a piece of equipment to pv

Vgextend vg0 / dev/vdb2 add vdb2 to vg0

(3) lvm reduction

Umount / dev/vg0/lv0 unmount device, replace file system

E2fsck-f / dev/vg0/lv0 examines the file system to determine the size of the data already in the file system to prevent excessive reduction

Resize2fs / dev/vg0/lv0 1G file system reduced by 1G

Lvreduce-L 1G / dev/vg0/lv0

(4) vg reduction

Pvmove device 1 device 2 move device 1 to 2

Vgreduce vg0 / dev/vdb1 removes vdb1 from vg0

Pvremove / dev/vdb1 removes lvm management information from vdb1

(5) deletion of lost devices in lvm

5.lvm Snapshot

Uninstall the original lv0 first

Lvcreate-L 100m-n lv0-test-s / dev/vg0/lv0

Specify size, specify name, specify original lv0 location

Deletion of 6.lvm

Lvremove--- > vgremove--- > pvremove

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

Network Security

Wechat

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

12
Report