Fdisk partition in Linux

I. hard disk interface
    from the overall perspective, the hard disk interface is divided into IDE, SATA, SCSI SAS, and four kinds, the IDE hard disk interface used for household products, also partially used in servers,
hard disk SCSI interface is mainly used in the server market, the SAS only on high-end servers, expensive.
Two types of hard drives.
    SATA hard drive: The hard drive also known serial SATA interface hard disk, is the future mainstream of development of the PC, because it has a stronger error correction capability, upon discovery of the error can be automatically corrected, thus greatly improving the data security of the transmission. The new use of a differential signaling system SATA "differential-signal-amplified-system ". Such a system can effectively filter out noise from the normal signal, the noise filtering capability so good as long as the SATA operation using a low voltage, and high transmission voltage 5V Parallel ATA compared, as long as the SATA 0.5V (500mv) of peak to peak voltage to operate over a higher speed. "It is more correct to say: peak to peak 'voltage differential mode'." Usually speed of up to 7200 rev / min. SCSI hard drives: a hard disk SCSI hard i.e. SCSI interface. Advantages: SCSI interface has a wide range of applications, multitasking, wide bandwidth, CPU occupancy rate is low, and hot swap. Because of its good performance, high stability, so widely used on the server. Disadvantages: Because SCSI hard disk price is very expensive, so the average PC will not use SCSI hard drives. Usually speed of up to 10,000 rev / min.

III. Partition symbol understanding

    LINUX states: logical partitions must be based on the extended partition, rather than on the primary partition

    Zoning action:

    Primary partition: mainly used to start the operating system, it is mainly put the operating system boot or boot program, / boot partition preferably placed on the primary partition

    Extended partition can not be used, it only exists as a container for logical partitions, create an extended partition, create logical partitions on the expansion of the partition; we really stored data is the primary and logical partitions, large amounts of data are placed in logic partition.

    Note: Use fdisk disk partitioning tool to operate, partition, format (focus)

    Note: The primary partition + extended partition can have up to four

    Extended partition can be 0, at most, a

    Extended partition can not be used directly, you must first create an extended partition into logical partitions can use

    0 logical partitions may be more than one
IV. File system data
    file that a user performs hardware storage devices is established, write, read, modify, and control operation of dump file systems rely to complete . The role of the file system is reasonable plan hard to ensure the user's normal needs. As shown in the Linux system to support dozens of file system, and the most common file system as follows.

    Ext3: is a journaling file system, the file system can avoid data loss when the system is abnormal downtime, and can automatically fix inconsistencies and erroneous data. However, when a large hard drive capacity, required repair time will be very long, and can not guarantee 100% data is not lost. It will every detail of the entire disk write operation is pre-recorded, in order to be able to trace back to the interrupted portion of downtime after an exception occurs, and then try to repair it.

    Ext4: improved version of Ext3, as the default RHEL 6 system document management system, which supports a storage capacity of up to 1EB (1EB = 1,073,741,824GB), and can have an unlimited number of subdirectories. Further, Ext4 file system can allocate block block quantities, thereby greatly enhancing the efficiency of reading and writing.

    XFS: it is a high performance journaling file system, and is the default RHEL 7 document management system, its advantages particularly evident after the occurrence of unplanned downtime, which can quickly recover files may be corrupted, and the powerful logging computing and storage functions with only a very low cost performance. And it can support a maximum storage capacity is 18EB, which meets almost all needs.
Five .fdisk management partition
    fdisk: disk partition, Linux distribution is the most common partitioning tool
    commonly used options:
    the -l to view the hard disk partition table
 parameters:

d delete a partition	                    删除一个分区
l list known partition types	            列出已知的分区类型
m print this menu	                    帮助
n add a new partition	                    添加一个新的分区
q quit without saving changes	            退出不保存
t change a partition's system id	      更改分区类型ID
w write table to disk and exit	            保存并退出

  

(一)静态添加硬盘(关机状态)
通过fdisk -l 查看分区是否生效
使用命令fdisk /dev/sd[a-z] 进行分区 其中:a-z 表示设备的序号,如sda表示第一块scsi硬盘,sdb就是第二块......
(二)动态添加硬盘(运行状态)
方法1:

ls /sys/class/scsi_host/                         #查看硬盘数
echo "- - -" > /sys/class/scsi_host/host0/scan   #添加硬盘命令 
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
fdisk -l   #查看硬盘

  

方法2:

cat /proc/scsi/scsi	              #查看设备ID,在最大的ID上加1.每次添加一块硬盘
例:echo "scsi add-single-device 0 0 4 0" > /proc/scsi/scsi  #添加硬盘
echo "scsi add-single-device 0 0 5 0" > /proc/scsi/scsi
fdisk -l

  

六.分区的作用

    防止数据丢失:如果系统只有一个分区,那么这个分区损坏,用户将会丢失所的有数据。

    增加磁盘空间使用效率:可以用不同的区块大小来格式化分区,如果有很多1K的文件,而硬盘分区区块大小为4K,那么每存储一个文件将会浪费3K空间。这时我们需要取这些文件大小的平均值进行区块大小的划分。

    数据激增到极限不会引起系统挂起:将用户数据和系统数据分开,可以避免用户数据填满整个硬盘,引起的系挂起


添加一块硬盘进行分区操作流程:
#1.检查环境
     getenforce


#2.分区

fdisk -l
echo "- - -" > /sys/class/scsi_host/host0/scan 
echo "- - -" > /sys/class/scsi_host/host1/scan 
echo "- - -" > /sys/class/scsi_host/host2/scan 
fdisk -l
fdisk /dev/sdb
fdisk -l

 

#3.格式化
   mkfs.xfs /dev/sdb1


#4.挂载
   mkdir /work
   mount /dev/sdb1 /work/


#5.永久挂载
   vim /etc/fstab
   ###############
   /dev/sdb1 /work xfs defaults 0 0
   ###############


#6.重启验证
   reboot

Guess you like

Origin www.cnblogs.com/t-ym/p/11615421.html