1, Basic knowledge
1 hard disk classification
Common disk types | explain | picture |
---|---|---|
SAS hard disk | (Serial Attached SCSI) Serial Attached SCSI interface. Serial attached small computer system interface is a new generation of SCSI technology. Like the popular Serial ATA(SATA) hard disk, it adopts serial technology to obtain higher transmission speed, and improves the internal space by shortening the connecting line. SAS interface technology can be downward compatible with SATA | |
SATA hard disk | Also known as serial hard disk, it increases the theoretical value of the external transmission rate of the hard disk to 150MB/s | |
SSD hard disk | Solid state drive, speed lever | |
SCSI HardDisk | The interface is fast and is mainly used for servers | |
linux | IDE is the transmission interface representing the hard disk. We often call IDE interface (also called ATA) and PATA interface |
2 hard disk size
3.5 inches and 2.5 inches
Previously, the mainstream desktop disk and server disk were designed in 3.5 inches, while the SAS hard disk, in addition to the traditional 3.5-inch specification, also adopted a 2.5-inch reduced version, which can install more disks in the limited space of rack server to expand the capacity of storage system, and also make more space for other accessories for ventilation and heat dissipation, Using eight 2.5-inch SAS hard disk bits within 2U height has become the choice of most server manufacturers
3 power interface
Serial and parallel serial ports are fast. The serial port is described as one lane, while the parallel port has eight lanes. 8-bit (one byte) data can be transmitted at the same time
But the parallel port is not fast because of the mutual interference between 8-bit channels. Transmission speed is limited. The more serious the interference, the faster the data will be transmitted at the same time. This is a hard injury, so the speed can't be improved
There is no interference on the serial port. Just resend one bit after transmission error. And the clock frequency of serial port transmission is higher than that of parallel port
4 Classification
The earliest hard disk
In 1956, a 5mb IBM hard disk was loaded into the plane, weighing more than a ton
Classification in principle | characteristic |
---|---|
solid state | The price is relatively expensive, the service life is long, and the reading speed is high |
Mechanics | Fear of falling and magnetism, (the bad disk replaced by the unit will be degaussed), reading speed - "track addressing time, latency" |
Classification on interface | characteristic |
---|---|
STAT | Used in low-end servers |
SAS,SCSI | Used in medium and high servers |
PCIE M.2 | Performance pursuit |
Operating system identification | IDE | STAT|SCSI | SAS |
---|---|---|---|
RHEL5 | /dev/hda | /dev/sda | /dev/sda |
RHEL6 | /dev/sda | /dev/sda | /dev/sda |
KVM | /dev/vda | — | — |
Hard disks are classified by color, including blue disk, green disk, black disk, red disk and purple disk
colour | quality |
---|---|
Black enterprise hard drive | With excellent performance and quality, it is mostly used for enterprise hard drives |
Blue disk mainstream PC hard disk | The blue disk is characterized by being regular, without the high performance of the black disk and the large capacity of the green disk |
Green mass storage hard disk | The speed of the green disk decreases from 7200 rpm to 5400 RPM in the mainstream to reduce its power consumption. Another feature of green disk is its large capacity. The maximum capacity can reach 6TB, which is very suitable for data storage warehouse |
Red NAS networked storage hard disk | The red disk has the characteristics of large capacity and low speed. With NASWare technology, the red disk focuses on the NAS network storage market and is suitable for individuals and small office users who build network storage |
Purple disk is a monitoring level hard disk | Optimized for monitoring storage, it can read and write continuously 24 hours a day, 24 hours a day, with extremely low power consumption. Through exclusive firmware upgrade and ATA streaming technology, it can reduce the number of pixel errors and video interrupts when the desktop hard disk is wrongly used as the storage device of the security system |
Identify the authenticity of the hard disk: check the serial number on the official website
2, Hard disk partition
1 basic knowledge
MBR overview: the full name is Master Boot Record, that is, the Master Boot Record of the hard disk
The 0 cylinder, 0 head and 1 sector of the hard disk are called the main boot sector (also known as the main boot record MBR). It consists of three parts, the main boot program, the hard Disk Partition table DPT (Disk Partition table) and the partition valid flag (55AA). In the main boot sector with a total of 512 bytes, the main boot loader accounts for 446 bytes. The second part is the Partition table area (Partition table), that is, DPT, which accounts for 64 bytes. The number of partitions in the hard disk and the size of each partition are recorded in it. The third part is magic number, which takes up 2 bytes and is fixed to 55AA.
Partition number: primary partition 1-4, logical partition 5-n. there can only be 4 primary partitions and multiple logical partitions
LINUX stipulates that the logical partition must be built on the extended partition, not on the primary partition
Primary partition: it is mainly used to start the operating system. It is mainly used to put the startup or boot program of the operating system. The / boot partition is best placed on the primary partition
The extended partition cannot be used. It only exists as a container of logical partition; What we really store data is the main partition and logical partition. A large amount of data is placed in the logical partition
If you use GPT partition mode, it does not limit the number of primary partitions
Hard disk naming method: / dev/sd[a-z]n
a-z represents the serial number of the device. For example, sda represents the first scsi hard disk, and sdb is the second
n indicates the partition number of each disk
[root@qianshuiliyu ~]# ls /dev/sda1 /dev/sda1 dev: Directory of devices sd: Hard disk type SCSI a: First hard disk 1: Partition number
2. Partition with fdisk tool
CentOS 7 selects xfs format as the default file system
xfs is designed for big data. Each single file system can support up to 8eb and a single file can support 16tb. It not only has a large amount of data, but also has high scalability. You can also backup and restore through xfsdump and xfsrestore.
Process of adding disks: add disks > partition > Format > mount
Simulation using virtual machines
1. Add a SCSI type hard disk
2. Check whether the computer has a display. sdb is the second hard disk
[root@qianshuiliyu ~]# ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sdb
3. fdisk partition
[root@qianshuiliyu ~]# fdisk /dev/sd /dev/sda /dev/sdb [root@qianshuiliyu ~]# fdisk /dev/sdb Welcome fdisk (util-linux 2.23.2). The changes remain in memory until you decide to write the changes to disk. Think twice before using the write command. Device does not contain a recognized partition table Use disk identifier 0 x90636adc Create a new DOS Disk label. command(input m get help): m Command operation a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition#delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types# Display partition type m print this menu#Print help menu n add a new partition# Add a new partition o create a new empty DOS partition table p print the partition table#Show partition table q quit without saving changes#Exit without saving s create a new empty Sun disklabel t change a partition's system id#Change partition type u change display/entry units v verify the partition table w write table to disk and exit#Write partition table information to the hard disk, save the operation and exit x extra functionality (experts only)
4. View partition information
command(input m get help): p disk /dev/sdb: 10.7 GB, 10737418240 Bytes, 20971520 sectors Units = a sector of 1 * 512 = 512 bytes Sector Size (logic/Physics): 512 byte / 512 byte I/O size(minimum/optimum): 512 byte / 512 byte Disk label type: dos Disk identifier: 0 x90636adc equipment Boot Start End Blocks Id System
5. Add partition
command(input m get help): n Partition type: p primary (0 primary, 0 extended, 4 free)#p: Main partition e extended#e: Extended partition Select (default p): p#Enter directly default p Partition number (1-4,Default 1): 1#Set primary partition Start sector (2048-20971519,The default is 2048): #Start sector, default is OK The default value 2048 will be used Last a sector, +a sector or +size{K,M,G} (2048-20971519,The default is 20971519): +5G#Size of the first primary partition Partition 1 is set to Linux Type, size set to 5 GiB command(input m get help): w#Save exit The partition table has been altered! Calling ioctl() to re-read partition table. Synchronizing disks.
6. The new partition takes effect
reboot restart perhaps partx -a /dev/sda
Get partition list information [root@qianshuiliyu ~]# partx -l /dev/sdb \# 1: 2048 - 10487807 (10485760 sectors, 5368 MB)
7. Format
[root@qianshuiliyu ~]# mkfs.xfs -f /dev/sdb1 #-f force formatting of partitions with existing file systems meta-data=/dev/sdb1 isize=512 agcount=4, agsize=327680 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=1310720, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
8. Mount and use
[root@qianshuiliyu ~]# mkdir /sdb1 [root@qianshuiliyu ~]# mount /dev/sdb1 /sdb1/ [root@qianshuiliyu ~]# cp /etc/passwd /sdb1/
9. Permanent mount, automatic mount after startup
[root@qianshuiliyu ~]# vim /etc/fstab /dev/sdb1 /sdb1 xfs defaults 0 0
Partition device to mount | Mount point | file system type | Mount options | Backup | Whether to detect |
---|---|---|---|---|---|
/dev/sdb1 | /sdb1 | xfs | defaults | 0 | 0 |
After configuration, restart the computer for testing
10. Mount using uuid
View uuid
[root@qianshuiliyu ~]# blkid /dev/sda1: UUID="f42a5b4c-66be-4b26-9866-47fb67bb911d" TYPE="xfs" /dev/sda2: UUID="FdT2Nu-X53I-ur1e-Nenx-CR7O-F6EI-gX5ocS" TYPE="LVM2_member" /dev/sdb1: UUID="6f904616-4a53-4282-9804-32afaa975c9f" TYPE="xfs" /dev/sr0: UUID="2020-11-02-15-15-23-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" /dev/mapper/centos-root: UUID="7891a781-6e28-4362-8e37-c58252c3f9ad" TYPE="xfs"
Just change the device name to uuid
[root@qianshuiliyu ~]# vim /etc/fstab UUID="6f904616-4a53-4282-9804-32afaa975c9f" /sdb1 xfs defaults 0 0
Configuration of mount 3
Partition device to mount | Mount point | file system type | Mount options | Backup | Whether to detect sectors |
---|---|---|---|---|---|
/dev/sdb1 | /sdb1 | xfs | defaults | 0 | 0 |
Column 1: equipment to be mounted
Column 2: mount point
Column 3: file system type
Column 4: Mount options
Column 5: backup or not
Column 6: whether to check the sector. During startup, the system will check whether our system is complete with fsck by default
Fourth column | effect |
---|---|
Async/sync | Set whether to run in synchronous mode. The default is async |
auto/noauto | Whether the file system is actively mounted when the command of mount -a is executed. The default is auto |
rw/ro | Mount in read-only or read-write mode |
exec/noexe | Limits whether "execute" operations can be performed within this file system |
user/nouser | Allow users to mount using mount command |
suid/nosuid | Allow SUID to exist |
Usrquota | The boot file system supports disk quota mode |
Grpquota | Start file system support for group disk quota mode |
Defaults | At the same time, it has the settings of default parameters such as rw,suid,dev,exec,auto,nouser,async and samba nfs |
Fifth column | effect |
---|---|
0 | On behalf of not doing backup |
1 | The representative shall operate every day |
2 | Operation on behalf of indefinite date |
Sixth column | effect |
---|---|
0 | Don't test |
1 | Earliest inspection (usually selected by the root directory) |
2 | Inspection shall be conducted after level 1 inspection is completed |
4. How to deal with the failure of unloading
Uninstall:
umount Mount point umount Device path
[root@qianshuiliyu ~]# umount /sdb1 umount: /sdb1: Target busy. (In some cases lsof(8) or fuser(1) sure Find useful information about the processes that use this device) [root@qianshuiliyu ~]# lsof /sdb1/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sftp-serv 3771 root 5r DIR 8,17 20 64 /sdb1 [root@qianshuiliyu ~]# kill -9 3771
5 partition using gdisk tool
gdisk is mainly used to divide hard disks with a capacity of more than 2T (4T is generally used for hard disks with a capacity of more than 2t). Fdisk with a capacity of more than 2T cannot be determined
Two types of partition tables: GPT and MBR; MBR does not support more than 4T
GPT partition: GPT, global unique identifier partition table, which uses 128 bit GUID to uniquely identify each disk and partition. Unlike MBR with a single fault point, GPT provides redundancy of partition table information, one at the head of the disk and one at the tail of the disk; It detects errors and damages in GPT header and partition table through CRC checksum; By default, a hard disk supports 128 partitions
1. gdisk partition
[root@qianshuiliyu ~]# gdisk /dev/sdb GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present *************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format! *************************************************************** Command (? for help): ? view help#? b back up GPT data to a file c change a partition's name d delete a partition #delete a partition i show detailed information on a partition l list known partition types n add a new partition# Add a partition o create a new empty GUID partition table (GPT) p print the partition table# Print partition table q quit without saving changes# Exit without saving r recovery and transformation options (experts only) s sort partitions t change a partition's type code v verify disk w write table to disk and exit# Write partition table and exit x extra functionality (experts only) ? print this menu
2. Add partition
Command (? for help): n#Add partition Partition number (2-128, default 2): 2#By default, 2,1 above has been used First sector (34-20971486, default = 10487808) or {+-}size{KMGTP}: #Enter directly and start from scratch Last sector (10487808-20971486, default = 20971486) or {+-}size{KMGTP}: +3G#Partition to 3G size Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): L#Partition type, which can be viewed through L, is 8300 Linux filesystem by default 0700 Microsoft basic data 0c01 Microsoft reserved 2700 Windows RE 3000 ONIE boot 3001 ONIE config 4100 PowerPC PReP boot 4200 Windows LDM data 4201 Windows LDM metadata 7501 IBM GPFS 7f00 ChromeOS kernel 7f01 ChromeOS root 7f02 ChromeOS reserved 8200 Linux swap 8300 Linux filesystem 8301 Linux reserved 8302 Linux /home 8400 Intel Rapid Start 8e00 Linux LVM a500 FreeBSD disklabel a501 FreeBSD boot a502 FreeBSD swap a503 FreeBSD UFS a504 FreeBSD ZFS a505 FreeBSD Vinum/RAID a580 Midnight BSD data a581 Midnight BSD boot a582 Midnight BSD swap a583 Midnight BSD UFS a584 Midnight BSD ZFS a585 Midnight BSD Vinum a800 Apple UFS a901 NetBSD swap a902 NetBSD FFS a903 NetBSD LFS a904 NetBSD concatenated a905 NetBSD encrypted a906 NetBSD RAID ab00 Apple boot af00 Apple HFS/HFS+ af01 Apple RAID af02 Apple RAID offline af03 Apple label af04 AppleTV recovery af05 Apple Core Storage be00 Solaris boot bf00 Solaris root bf01 Solaris /usr & Mac Z bf02 Solaris swap bf03 Solaris backup bf04 Solaris /var bf05 Solaris /home bf06 Solaris alternate se bf07 Solaris Reserved 1 bf08 Solaris Reserved 2 bf09 Solaris Reserved 3 bf0a Solaris Reserved 4 bf0b Solaris Reserved 5 c001 HP-UX data c002 HP-UX service ea00 Freedesktop $BOOT eb00 Haiku BFS ed00 Sony system partitio ed01 Lenovo system partit Hex code or GUID (L to show codes, Enter = 8300): #Just enter by default Changed type of partition to 'Linux filesystem' Command (? for help): p#View partition Disk /dev/sdb: 20971520 sectors, 10.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 7766A8BC-C7E1-486E-B3A1-ED70B5B0C0EE Partition table holds up to 128 entries First usable sector is 34, last usable sector is 20971486 Partitions will be aligned on 2048-sector boundaries Total free space is 4194237 sectors (2.0 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 10487807 5.0 GiB 8300 Linux filesystem 2 10487808 16779263 3.0 GiB 8300 Linux filesystem Command (? for help): w#preservation Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): y#Are you sure you want to write OK; writing new GUID partition table (GPT) to /dev/sdb. Warning: The kernel is still using the old partition table. The new table will be used at the next reboot. The operation has completed successfully.
3. Make partition effective
reboot restart perhaps partx -a /dev/sdb
4. Format
[root@qianshuiliyu ~]# mkfs.xfs /dev/sdb sdb sdb1 sdb2 [root@qianshuiliyu ~]# mkfs.xfs /dev/sdb2 meta-data=/dev/sdb2 isize=512 agcount=4, agsize=196608 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=786432, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
5. Mount use (configure automatic mount after startup)
The operation is the same as that of fdisk
6 add startup error
When the hard disk mounting information is set to boot, the automatic mounting error is reported
1. Mistake
2. Log in to the system
3. Modify the information of fstable
Correct the information or delete the configuration
4. reboot is normal
7swap expand partition to increase space
1. Current extended partition size
[root@qianshuiliyu ~]# free -m total used free shared buff/cache available Mem: 972 396 233 14 342 422 Swap: 2047 0 2047
2. Add partition
[root@qianshuiliyu ~]# fdisk /dev/sdb WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Welcome fdisk (util-linux 2.23.2). The changes remain in memory until you decide to write the changes to disk. Think twice before using the write command. command(input m get help): n Partition number (3-128,Default 3): First sector (34-20971486,Default 16779264): Last sector, +sectors or +size{K,M,G,T,P} (16779264-20971486,Default 20971486): +1G Created partition 3 command(input m get help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Synchronizing disks.
3. Partition effective
[root@qianshuiliyu ~]# partx -a /dev/sdb
4. Format as swap partition
[root@qianshuiliyu ~]# mkswap /dev/sdb3 Setting swap space version 1, size = 1048572 KiB No label, UUID=ff3b77f8-baf0-4805-a3e7-9fc186372d23
5. Add to swap partition
[root@qianshuiliyu ~]# swapon /dev/sdb3 #swapoff off
6. Check
[root@qianshuiliyu ~]# free -m total used free shared buff/cache available Mem: 972 395 233 14 344 423 Swap: 3071 0 3071