现在需要把一块1T的硬盘挂载在一台正在跑业务的机器上:
先用fdisk -l 看看新的硬盘认出来没有:
[root@localhost ~]# fdisk -l
Disk /dev/sda: 146.8 GB, 146815733760 bytes
255 heads, 63 sectors/track, 17849 cylinders
Units = cylinders of16065 * 512 = 8225280 bytes
Device Boot Start EndBlocks 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 of16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
我的1T硬盘服务器已经识别出来,不过现在处于空闲状态
下面开始给新硬盘分区
[root@localhost ~]# fdisk /dev/sdb
Device containsneither a valid DOS partitiontable, nor Sun, SGIorOSF disklabel
Building a new DOS disklabel. Changes will remain inmemoryonly,
until you decide towrite them.Afterthat,ofcourse, the previous
content won't be recoverable.
The number ofcylindersforthis diskissetto121601.
There isnothing wrongwiththat, but thisislarger than 1024,
andcouldincertain setups cause problemswith:
1) software that runs atboottime(e.g., old versionsofLILO)
2) booting andpartitioning softwarefromother OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 ofpartitiontable4 will be correctedbyw(rite)
Command (m forhelp): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of16065 * 512 = 8225280 bytes
Device Boot Start EndBlocks Id System
Command (m forhelp): n
Command action
e extended
p primarypartition (1-4)
p
Partition number (1-4): 1
Firstcylinder (1-121601,default1):
Using defaultvalue 1
Lastcylinderor+sizeor+sizeMor+sizeK (1-121601,default121601):
Using defaultvalue 121601
Command (m forhelp): w
The partition tablehas 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
到此我们添加新硬盘的工作结束了。
本文介绍如何将一块1TB的硬盘挂载到正在运行的服务器上,并完成分区及格式化工作。通过使用fdisk命令进行硬盘分区,利用mkfs命令进行格式化,并最终将新硬盘挂载至指定目录。

7439