Fdisk-l # # Here is a look at the current system with a few hard drives
disk/dev/sda:36.4 GB, 36401479680 bytes
255 heads, Sectors/track, 4425 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 255 2048256 Linux
/dev/sda2 1530 10241437+ Linux
/dev/sda3 4296 4425 1044225, Linux swap
/DEV/SDA4 1531 4295 22209862+ f Win95 Ext ' d (LBA)
/dev/sda5 1531 2805 10241406-up Linux
/dev/sda6 2806 4295 11968393+-up Linux
Partition table entries is not in disk order
disk/dev/sdb:36.7 GB, 36703918080 bytes # # found here/dev/sdb, capacity 36.7G, and not partitioned
255 heads, Sectors/track, 4462 cylinders
Units = Cylinders of 16065 * 8225280 bytes
DISK/DEV/SDC doesn ' t contain a valid partition table
Connect the hard drive on the server, start Linux, and log in as root.
For example, if I add a new SCSI drive, I need to divide it into three zones:
#fdisk/dev/sdb
Enter Fdisk mode:
Command (M for help):p//View the partition of the new hard disk
Command (M for help): N//Create new partition
You can use the M command to see the internal command of the FDISK command; n command to create a new partition; d command to delete an existing partition; The P command to display the partition list; the T command to modify the type ID number of the partition, the command to display a list of partition ID numbers; a command to specify the boot partition The W command is to save changes to the partition table to make it work.
Command Action
E Extended//Enter E to create an extended partition
P primary partition (1-4)//input p to create the primary partition, here we select P
Partion Number (1-4): 1//First extended partition, up to 4 primary partitions according to your requirements
First Cylinder (1-1014,default 1): 1//number of disk blocks starting with the primary partition
Last Cylindet or +siza or +sizem or +sizek: +1024MB//Can be a number in megabytes or
Number of disk blocks, here we enter +1024MB to indicate a partition size of 1G.
This way we create a partition, and if you want to create more partitions, you can continue with the steps above.
Save the partition with W when you are finished creating it.
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
So we're going to have to format the partition.
#mkfs-T Ext3-c/dev/sdb1//If there are multiple partitions, the partition is modified to SDB2 so
We need to mount the partition after the format is finished,
#mkdir www//Create/www directory, we will hook up the new partition to www
#mount/dev/sdb1/www//Mount/DEV/SDB1 to/www
# DF//view with df command
Filesystem 1k-blocks used Available use% mounted on
/dev/sda2 3771316 1388956 2190788 39%/
/DEV/SDA1 101089 9463 86407 10%/boot
None 62988 0 62988 0%/dev/shm
/DEV/SDB1 485906 8239 452580 2%/www//See, that's what we just
Only newly mounted partitions
We are nearing the end of our work here, but if we end it, we'll have to do it every time we restart the server.
It is cumbersome to mount manually, and we need to modify the/etc/fstab file to automatically mount it.
#vi/etc/fstab
At the end of the file, add the following:
/dev/sdb1/www ext3 Defaults 1 2
If you have more than one partition to modify SDB1 and/www, save after modifying and restart the server.
This is the end of our work to add a new hard drive.
CentOS Add hard Drive