linux新增磁盘命令,给linux添加新硬盘

现在需要把一块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

到此我们添加新硬盘的工作结束了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值