How to add a new hard disk to linux
On the server to take a good hard drive,Boot linux,Log in as root。
For example, I added a new SCSI hard disk,It needs to be divided into three zones:
#fdisk /dev/sdb 进入fdisk模式: Command (m for help):p //查看新硬盘的分区 Command (m for help):n //创建新分区 可以用m命令来看fdisk命令的内部命令;n command to create a new partition;d command to delete an existing partition;p command to display partition list;t command to change the partition type ID number;l command displays a list partition ID numbers;a command to specify the boot partition;w command to modify the partition table will save it to play a role。 Command action e extended //输入e为创建扩展分区 p primary partition (1-4) //Enter p to create a primary partition,这里我们选择p Partion number(1-4):1 //The first extended partition,按你需求可以最多分4个主分区 First Cylinder(1-1014,default 1): 1 //第一个主分区起始的磁盘块数 Last cylindet or +siza or +sizeM or +sizeK: +1024MB //可以是以MB为单位的数字或者以 磁盘块数,Here we enter + 1024MB partition size expressed as 1G。
So we have created a partition,If you want to create more partitions can be created according to the above steps to continue。
After the partition is created with the Save w。
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
This partition End,We would also like to format
#mkfs -t ext3 -c / dev / sdb1 // If you have multiple partitions,Modify the zoning so sdb2
After the format we need to mount the partition,
#mkdir www // Create / www directory,我们将把新的分区挂到www下 #mount /dev/sdb1 /www //将/dev/sdb1挂载到/www # df //用df命令进行查看 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% /see www //,这就是我们刚 才新挂载的分区
Here we are nearing completion of,But if we are to end this case,We have to restart the server after each
Manually mount,This is very troublesome,We need to modify / etc / fstab file to automatically mount。
#vi / etc / fstab
At the end of the file add the following to fill:
/dev/sdb1 /www ext3 defaults 1 2
If more than one partition can be modified sdb1 and / www,After modification save,Restart server。
This work we add a new hard disk is over。
mkfs.ext4