linux 扩展挂载盘大小_在Linux中扩展磁盘容量(1)

对于linux系统管理员来说,随着业务的发展,磁盘容量不足是需要面对的一个难题。这里通过两种方式来说明如果添加新的磁盘到linux 系统当中去。一是连接新的disk,对disk分区和格式化,然后合并以存在的filesystem和新增加的disk的filesystem。二是通过 linux logical volumn manager 来管理磁盘。

添加新的disk到linux当中来

[完成的任务]将新增加的disk做出一个parition,然后将linux上已有磁盘上数据全部或部分迁移到新的磁盘上来

假设现在linux system中的filesystem的使用情况大致是: [root@bigboy tmp]# df -k

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/hda3 505636 118224 361307 25% /

/dev/hda1 101089 14281 81589 15% /boot

none 63028 0 63028 0% /dev/shm

/dev/hda5 248895 6613 229432 3% /tmp

/dev/hda7 3304768 2720332 416560 87% /usr

/dev/hda2 3304768 3300536 4232 99% /var

可以看到/var挂载点挂载的/dev/hda2 partition已经使用了99%。需要增加新的磁盘容量。

通过查看/proc/partitions proc 文件,可以查看当前linux系统中所有已知的partitions

[root@bigboy tmp]# cat /proc/partitions

major minor #blocks name

3 0 7334145 hda

3 1 104391 hda1

3 2 1052257 hda2

3 3 2040255 hda3

3 4 1 hda4

3 5 3582463 hda5

3 6 554211 hda6

22 0 78150744 hdb

[root@bigboy tmp]#

可以看到minor 值为0表示是整块磁盘, 磁盘上的分区的major同一样,minor是根据parition的增加而增加,这里hda1 hda2 … hda6的minor分别为1,2,…,6

Linux系统中hard disk命名规则, scsi磁盘以sd开头,ide磁盘以hd开头,scsi的第一个磁盘为sda, 依次其它的为sdb,sdc,sdd, IDE同样如此,hda, hdb.

sda上第一个parition为sda1,剩余的以此类推。

接下来,为新增加的disk hdb建立分区。

[root@bigboy tmp]# fdisk /dev/hdb

The number of cylinders for this disk is set to 9729.

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)

Command (m for help):

============================================================

Command (m for help): p

Disk /dev/hdb: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help):

可以看到目前hdb 上没有建立parition。

Command (m for help): n

Command action

e extended

p primary partition (1-4)

Partition number (1-4): 1

First cylinder (1-9729, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-9729, default 9729):

Command (m for help): p

Disk /dev/hdb: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hdb1 1 9726 78148161 83 Linux

Command (m for help):

如果你在新建partition的时候出错,则你可以使用d命令来删除该parition,然后重新来过。 另外,linux最多允许四个primary partition, 如果你需要建立更多的分区,使用建立extended partition. 建立完extended partition之后,可以在extended partition上建立新的logical partition。

Command (m for help): p

Disk /dev/hda: 7510 MB, 7510164480 bytes

255 heads, 63 sectors/track, 913 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hda1 * 1 13 104391 83 Linux

/dev/hda2 14 144 1052257+ 83 Linux

/dev/hda3 145 398 2040255 82 Linux swap

/dev/hda4 399 913 4136737+ 5 Extended

/dev/hda5 399 844 3582463+ 83 Linux #logical parition on extended parition

/dev/hda6 845 913 554211 83 Linux # ditto

当你完成对hdb分区后, 查看下分区表分区是否正确 : 通过cat /proc/partitions 或 fdisk -l

接下来就需要对新增的disk hdb进行格式化,为其建立新的目录结构。

mkfs –t ext3 /dev/hdb1

然后为/dev/hdb1 建立挂载点,这里是/mnt/hdb1

修改/etc/fstab 将/dev/hdb1 挂载到/mnt/hdb1

#

# File: /etc/fstab

#

/dev/hdb1 /mnt/hdb1 ext3 defaults 1 2

最后别忘记挂载,挂载完成后就可以使用新增的disk了。

小结:新增disk基本需要:连接好disk,对disk分区, 格式化,最后建立挂载点,挂载

关于LVM,在Linux中扩展磁盘容量(2)—LVM 中总结。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值