LINUX下添加磁盘空间的方法详解

时间:2023-12-04 11:47:08

给Linux系统添加磁盘空间在工作会经常遇到。

在添加第二块磁盘一般系统默认为hdb(IDE硬盘)sdb(SCSI 硬盘),以hdb为例。

linux-isep:~ # fdisk /dev/hdb

The number of cylinders for this disk is set to 8322.
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): m //先帮助一下。避免误操作。
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
选择n

Command action
l logical (5 or over)
p primary partition (1-4)
如果想建立逻辑分区就选l,主分区就选p.

接下来是输入大小,这个大小是整个扩展分区的大小,强烈建议默认。
然后建立逻辑分区的时候才会让你选择建立的数量,以及每个分区的大小。

最后w保存退出。

格式化刚刚建立的分区,先查看一下。

linux-isep:~ # fdisk -l

Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 1 8322 4194256+ 5 Extended
/dev/hdb5 1 8322 4194225 83 Linux

注意:

/dev/hdb1是扩展分区,并不是逻辑分区.(一般情况下,1-4为主分区.5以后是逻辑分区.逻辑分区都包括在扩展分区里面,这个和WIN的道理是一样的)我们要格式化的是逻辑分区.使用命令

mkfs -t ext3 /dev/hdb5

如果使用hdb1的话,会有如下错误提示

linux-isep:~ # mkfs -t ext3 /dev/hdb1
mke2fs 1.39 (29-May-2006)
/dev/hdb1: Invalid argument passed to ext2 library while setting up superblock

本文出处参考:http://happy-xp.blog.163.com/blog/static/2324170201063101745392/