现在需要把一块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 in memory only,
- until you decide to write them. After that, of course, the previous
- content won't be recoverable.
- The number of cylinders for this disk is set to 121601.
- There is nothing wrong with that, but this is larger than 1024,
- and could in certain setups cause problems with:
- 1) software that runs at boot time (e.g., old versions of LILO)
- 2) booting and partitioning software from other OSs
- (e.g., DOS FDISK, OS/2 FDISK)
- Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
- Command (m for help): p
- Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
- 255 heads, 63 sectors/track, 121601 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Device Boot Start End Blocks Id System
- Command (m for help): n
- Command action
- e extended
- p primary partition (1-4)
- p
- Partition number (1-4): 1
- First cylinder (1-121601, default 1):
- Using default value 1
- Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601):
- Using default value 121601
- Command (m for help): w
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- 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
到此我们添加新硬盘的工作结束了。
本文转自运维笔记博客51CTO博客,原文链接http://blog.51cto.com/lihuipeng/836033如需转载请自行联系原作者
lihuipeng