linux自动跑批,在linux中添加硬盘并在系统启动时自动挂载

前言

最近搞Linux时,当初没有考虑完善,只分配了10GB的空间,启动mongodb时直接给我报了一个错误:可用空间太少,虽说加一个参数—smallfiles就可以解决问题,但这治标不治本。所以我参考Adding a New Disk Drive to an RHEL 6 System,记录下来,以供以后参考。

环境

Oracle VM VirtualBox搭建的虚拟机,主机cpu intel i5-4590,8G内存,系统win7 64位,Linux虚拟机的环境是centos6.5

在Linux中找到新硬盘

前提是你已经为虚拟机添加了一个新的硬盘。

切换root用户

[spider140@spider140 ~]$ ls /dev/sd*

/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb

在这里/dev/sda表示的硬盘被分成两个分区,由/dev/sda1, /dev/sda2表示。咱们新加的硬盘已经指派给/dev/sdb,现在没有为这个硬盘分配任何分区。

添加一个linux分区

[root@spider140 spider140]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x3590b300.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help):

通过键入c和u来关闭DOS适配模式和改变单元为扇区

Command (m for help): c

DOS Compatibility flag is not set

Command (m for help): u

Changing display/entry units to sectors

键入p查看当前分区数:

Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x3590b300

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 sector (2048-16777215, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215):

Using default value 16777215

键入p查看当前分区

Disk /dev/sdb: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x3590b300

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048    16777215     8387584   83  Linux

键入w保存分区信息并退出

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值