View existing partitions
[[email protected] ~]# fdisk -lDisk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0008d932 Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 1332 10485760 83 Linux/dev/sda3 1332 1462 1048576 82 Linux swap / Solaris/dev/sda4 1462 2611 9231360 5 Extended/dev/sda5 1462 2611 9230336 83 Linux[[email protected] ~]#
Start adding new Hard Disk
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/47/85/wKioL1P79TeBwOdjAALNc3GlEAE762.jpg "style =" float: none; "Title =" 1.png" alt = "wkiol1p79tebwodjaalnc3gleae762.jpg"/>
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/47/85/wKioL1P79TeRyI9YAAFP9KW0tn4446.jpg "style =" float: none; "Title =" 2.png" alt = "wkiol1p79teryi9yaafp9kw0tn4446.jpg"/>
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/47/83/wKiom1P79B_AhmoiAAGHVJjz4GA792.jpg "style =" float: none; "Title =" 3.png" alt = "wkiom1p79b_ahmoiaaghvjjz4ga792.jpg"/>
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/47/85/wKioL1P79TeRnBmIAAJH0P8AUbU232.jpg "style =" float: none; "Title =" 4.png" alt = "wkiol1p79ternbmiaajh0p8aubu232.jpg"/>
Use fdisk-L to view the information after restarting the server.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/47/85/wKioL1P79WeTKWeQAAMSqtPKNDQ840.jpg "Title =" 5.png" alt = "wkiol1p79wetkweqaamsqtpkndq840.jpg"/>
Now we can see the new hard disk, but it is not in use. We need to format it before use.
Now let's partition the hard disk SDB and use the fdisk command.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/47/84/wKiom1P79LnAHNPMAAU5iZSRpLc595.jpg "Title =" 6.png" alt = "wkiom1p79lnahnpmaau5izsrplc595.jpg"/>
Parameter description
Several of the fdisk commands are frequently used,
M Displays all commands
N create a partition. after entering the option using this command, e Indicates creating a new extended partition, and P indicates creating a new primary partition.
P display Partition
Q: Do not save the modification and exit
W Save the modification and exit
After the above partitions are completed, we will use the fdsik command again to view
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/47/84/wKiom1P79QeDiGYSAAMmvGH3ntM242.jpg "Title =" 7.png" alt = "wkiom1p79qedigysaammvgh3ntm242.jpg"/>
We can see that the hard disk SDB has been divided into. Dev/sdb1 partitions. This operation is equivalent to creating a partition in the Windows system. At this time, the partition is not formatted.
Next we will perform the formatting operation, because the Linux system has different file systems. For example, ext2, ext3, and ext4. Each file system is different, while centos6.4 uses the ext4 File System by default. This is equivalent to the fat file format and NTFS file format in windows. Therefore, we need to format the new partition into the ext4 format. We can use the mkfs. ext4 command. If it is set to the ext3 format, we can use mkfs. ext3. For example:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/47/85/wKioL1P79mqz-H02AAI8dlTEZzA990.jpg "Title =" 8.png" alt = "wKioL1P79mqz-H02AAI8dlTEZzA990.jpg"/>
After formatting, We can mount partitions. This part is equivalent to assigning a drive letter to the partition in windows. Partition mounting can be divided into two parts: Temporary mounting and permanent mounting. Temporary mounting: After the system is restarted, the mounting will disappear. Permanent mounting writes the partition to be mounted to the/etc/fstab file. The System reads the content of the file when it starts.
We will first perform temporary mounting and create a directory to mount the partition. For example
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/47/84/wKiom1P79YHiCH1PAAH3IkDC2w4526.jpg "Title =" 9.png" alt = "wkiom1p79yhich1paah3ikdc2w4526.jpg"/>
View mounting result
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/47/84/wKiom1P79bvCTJFmAAD9H8fou9s959.jpg "Title =" 10.png" alt = "wkiom1p79bvctjfmaad9h8fou9s959.jpg"/>
The above is a temporary mount. Next we will set a permanent mount. Before setting a permanent mount, we need to first detach the mounted file that has just been mounted and use the umount command, such:
Umount/data2/
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/47/85/wKioL1P79xXQbFb-AADIUXn-vdw712.jpg "Title =" 11.png" alt = "wKioL1P79xXQbFb-AADIUXn-vdw712.jpg"/>
After uninstalling the file, edit the/etc/fstab file and add the following content:
/Dev/sdb1/Data ext4 defaults 0 0
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/47/85/wKioL1P798TwEEYwAAHKOJG6HLs274.jpg "Title =" 12.png" alt = "wkiol1p798tweeywaahkojg6hls274.jpg"/>
Use Mount-a to mount all the disks and view the results.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/47/86/wKioL1P79-mTNyp5AAD3Z_47p5Y666.jpg "Title =" 13.png" alt = "wKioL1P79-mTNyp5AAD3Z_47p5Y666.jpg"/>
Now the mounting of the new hard disk is complete ~~
Small Advertisement
Http://shop62632578.taobao.com/
This article is from the "always_yunwei" blog, please be sure to keep this http://alwaysyunwei.blog.51cto.com/3224143/1545057
Attach a new disk to centos6.2 under a VM