Add a new hard disk to CentOS
Connect the hard disk to the server, start linux, and log on as root.
For example, if I add a new SCSI hard disk, We need to divide it into three areas:
# Fdisk/dev/sdb enters the fdisk mode: Command (mforhelp): p // view the partition Command of the new hard disk (mforhelp ): n // run the m command to create a new partition. Run the n command to create a new partition. Run the d command to delete an existing partition. Run the p command to display the partition list; the t command modifies the ID of the partition type. The l command displays the list of the partition ID numbers. The a command specifies that the partition is started. The w command is used to modify the storage disk of the partition table. Commandactioneextended // input e to create an extended partition pprimarypartition (1-4) // input p to create a primary partition. Here we select pPartionnumber (1-4 ): 1 // The first extended partition, which can be divided into up to four primary partitions FirstCylinder (1-1014, default1) as required ): 1 // Number of disk blocks starting from the first primary partition Lastcylindetor + sizaor + sizeMor + sizeK: + 1024 MB // It Can Be A number in MB or the number of disk blocks, here, we enter + MB to indicate that the partition size is 1 GB.
In this way, we have created a partition. If you want to create more partitions, you can continue to create the partition according to the above steps.
After the partition is created, use w to save the partition.
Command(mforhelp):wThepartitiontablehasbeenaltered!Callingioctl()tore-readpartitiontable.Syncingdisks.
In this way, the partition is complete and we need to format it.
# Mkfs-text3-c/dev/sdb1 // If there are multiple partitions, then the partition is changed to sdb2 like this
After formatting, we need to mount the partition,
# Mkdirwww // create/www directory, we will mount the new partition under www # mount/dev/sdb1/www // mount/dev/sdb1 to/www # df // run df command to view Filesystem1K-blocksUsedAvailableUse % Mountedon /dev/clusters % // dev/sda110108994636940710 %/bootnone629880629880 %/dev/shm/dev/sdb148590682394525802 %/www, this is the partition we just mounted.
At this point, our work is coming to an end, but if this is the case, we need
Manual mounting is very troublesome. We need to modify the/etc/fstab file for automatic mounting.
#vi/etc/fstab
Add the following content at the end of the file:
/dev/sdb1/wwwext3defaults12
Modify sdb1 and/www if there are multiple partitions. Save the modification and restart the server.
Now we have finished adding a new hard disk.