现在需要把一块1T的硬盘挂载在一台正在跑业务的机器上:
先用fdisk -l 看看新的硬盘认出来没有:
[root@localhost ~]# fdisk -l Disk /dev/sda: 146.8 GB, 146815733760 bytes 255 heads, 63 sectors/track, 17849 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1543 12289725 82 Linux swap / Solaris /dev/sda3 1544 17849 130977945 83 Linux Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table
我的1T硬盘服务器已经识别出来,不过现在处于空闲状态
下面开始给新硬盘分区
[root@localhost ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain inmemoryonly,until you decidetowrite them.Afterthat,ofcourse, the previouscontent won't be recoverable.The numberofcylindersforthis diskissetto121601.Thereisnothing wrongwiththat, but thisislarger than 1024,andcouldincertain setups cause problemswith:1) software that runsatboottime(e.g., old versionsofLILO)2) bootingandpartitioning softwarefromother OSs(e.g., DOS FDISK, OS/2 FDISK)Warning: invalid flag 0x0000ofpartitiontable4 will be correctedbyw(rite)Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes255 heads, 63 sectors/track, 121601 cylindersUnits = cylindersof16065 * 512 = 8225280 bytesDevice Boot StartEndBlocks Id SystemCommand (mforhelp): nCommandactione extendedpprimarypartition (1-4)pPartition number (1-4): 1Firstcylinder (1-121601,default1):Usingdefaultvalue 1LastcylinderorsizeorsizeMorsizeK (1-121601,default121601):Usingdefaultvalue 121601Command (mforhelp): wThe partitiontablehas been altered!Calling ioctl()tore-readpartitiontable.Syncing disks.
Command (m for help):p //查看新硬盘的分区
Command (m for help):n //创建新分区
可以用m命令来看fdisk命令的内部命令;n命令创建一个新分区;d命令删除一个存在的分区;p命令显示分区列表;t命令修改分区的类型ID号;l命令显示分区ID号的列表;a命令指定启动分区;w命令是将对分区表的修改存盘让它发生作用.
Command action
e extended //输入e为创建扩展分区
p primary partition (1-4) //输入p为创建主分区,这里我们选择p
Partion number(1-4):1 //第一个扩展分区,按你需求可以最多分4个主分区
First Cylinder(1-1014,default 1): 1 //第一个主分区起始的磁盘块数
Last cylinder or size or sizeM or sizeK (1-121601, default 121601): //第一个主分区结束的磁盘块数
Command (m for help): w //创建完后用w保存分区
接下来给新硬盘格式化:
mkfs -t ext3 -c /dev/sdb1
格式化完后我们需要进行挂载分区:
mount /dev/sdb1 /www
修改/etc/fstab文件来进行自动挂载:
/dev/sdb1 /www ext3 defaults 1 2
到此我们添加新硬盘的工作结束了.