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

11pi Linux disk management

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

Share

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

1the Linux system currently supports two dynamic scalable disk management methods:

1Query raid management: this is a way to initialize hard disk management before system installation, and logical disk array management methods such as raid0,raid1,raid5,raid10 are commonly used.

Raid0: at least 1 disk read and write fast without redundancy one disk damaged data is lost raid1: at least 2 disks read and write slow one read and write a backup can lose a disk raid5: at least 3 disks can be sketched fast and a check disk can be used Loss of a disk raid10: at least 4 disk read and write speed, half read and write speed, half backup can lose half of the hard disk raid5 check disk logic diagram:

2, after the system is installed, use the LVM command to manage the disk (slowly less)

2. Hard disk classification:

1. Classify by hard disk structure:

Mechanical hard disk (HDD: slow speed is suitable for large amounts of data storage with low cost

Solid state disk (SSD) read fast SSD (memory) cost is expensive

2. Classified by hard disk interface:

SCSI

SATA

SAS (mainstream)

PCI-E

/ dev is the Linux system, so the hardware device file

/ dev/sda represents the first hard disk

/ dev/sda1 represents the first partition of the first hard disk

/ dev/sda2 represents the first hard disk and the second partition

/ dev/sda3 represents the first hard disk and the third partition

/ dev/sda4 represents the first hard disk and the fourth partition

Note: there are up to 4 primary partitions for a hard drive. Or three primary partitions, and the fourth primary partition is set aside as an extended partition (extend). The name starts with / dev/sda5.

/ dev/sdb represents the second hard drive

/ dev/sdc represents the third hard drive

MBR sector: 512K in total, where the master boot record is located

Fdisk-l to view current hard disk partitions

Df-h to view the mount usage of the current partition

Lsblk displays partitions in a tree structure

Blkid View Partition only represents UUID

/ etc/fstab partition automatically mounts files

3. There are two main disk partition commands:

Fdisk: maximum support for 2T partitions

Parted: supports GPT and is suitable for large capacity partitions

Fidsk Partition Command

Step 1: fdisk / dev/sda

P displays the current partition situation

N create Partition

Primany selects the primary partition

Extended Select extended Partition

D delete partition

W Save Settings

Step 2: mkfs.xfs / dev/sda1

Ext2

Ext3

File system format for ext4 Linux6 series

File system format for xfs Linux7 series

Of course: a hard disk can also be formatted and used without partition, and the whole disk is faster than partition.

Step 3: Mount

Mount / dev/sda1 / mnt mounts the partition in the / mnt directory. When you write data in the / mnt directory, you write the data to / dev/sda1.

Umount / dev/sda1

Umount / mnt unmount mount

Step 4: realize auto-mount partition on boot

1dyne echo 'mount / dev/sda1 / mnt' > > / etc/rc.local

2, write / etc/fstab

Parted: command partition

Parted-l to view the current partition

Step 1: parted / dev/sda partition

Mktable creates disk labels GPT,fdiskz supports MBR

Gpt handwritten gpt

P check the partition situation

Mkpart start Partition

It can be zoned all the time. Parted partition supports 128primary partitions

Step 2: mkfs.xfs / dev/sdb1

Step 3: Mount

Step 4: realize automatic mount on boot

4. Enterprise case:

The java environment does not have enough memory and occupies swap partitions

Free-h view current mem and swap details

The essence of dd if=/dev/zero of=/tmp/200m bs=1M count=200 dd is the command function of creating and copying files

/ dev/zero White Hole continuous content output

/ dev/null black hole continuous inhalation of content

Mkswap / tmp/200 formatted partition

Swapon / tmp/200 activate swap Partition

5. Find large files in the system

1find /-type f-szie + 2G | xargs ls-lh

2find /-type f-size + 2G-exec ls-lh {}\

3,du

6, add a default gateway

Route add default gw xxxx

Route del defalut gw xxxx

Add a route entry

Ip route add 0ap0 via Gateway

Ip route del 0ap0 via Gateway

Add ip to the network card

Ip address add xxxx/24 dev eth0

Ip address add xxxx/24 dev eth2

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