视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
在Linux系统中添加新硬盘
2025-10-03 14:40:38 责编:小OO
文档
在Linux系统中添加新硬盘(以Vmware中FC4系统为例)

编辑虚拟机设置,在对话框中添加一个硬盘,我选择的是IDE接口(默认的是SCSI,但对于操作没有什么影响,只是在以后的显示中会不同)。

启动Vmware中的FC4,用root用户登录系统。操作有一定的危险性,每次的操作都要仔细确认。

使用fdisk –l 命令显示硬盘分区的情况。

[root@fc4 ~]# fdisk -l

Disk /dev/hda: 536 MB, 536870912 bytes

16 heads, 63 sectors/track, 1040 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Disk /dev/hda doesn't contain a valid partition table

Disk /dev/sda: 85 MB, 85934592 bytes

255 heads, 63 sectors/track, 1044 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 1044 8281507+ 8e Linux LVM

以上标示蓝色的部分表示这个硬盘没有格式化,并且没有分区。使用命令来给它添加分区。

fdisk /dev/had

这个命令可以来分区,按照提示按M键来查看帮助,可以知道N键是用来创建新的分区。

它会提示创建一个主分区,还是一个逻辑分区,在这里我选择P创建一个主分区,输入一个分区号,这个号用来标记分区。然后它提示输入起始的cylinders(柱面),回车输入结束柱面。在这个地方我选择全部的容量,你也可以让它分成几个分区,比如这个是1-1040,那么你输入第一个结束的是521,那么没有用完的还可以接着分区。重复用N来创建。(附:在有些书上看到说从1开始不安全,在网上也有看到,可以从2柱面开始)

完成的时候,在提示输入的时候,输入W。写入就可以了。分区完成。

这时候对于这个分区还不能使用,也不能mount到系统中,因为它没有文件系统。要格式化下。

用命令mkfs –t ext3 –c /dev/hda1格式化成ext3格式。

mount到系统中就行了。可以修改/etc/fstab来让系统每次启动的时候自动挂接,添加硬盘就算完成了。

操作过程显示:

login as: root

root@192.168.238.129's password:

Last login: Fri Mar 28 12:00:18 2008 from 192.168.238.1

[root@fc4 ~]# fdisk -lDisk /dev/hda: 536 MB, 536870912 bytes

[如果在添加硬盘时用的是SCSI的接口,在会显示成sdb,因为系统中已经有一个SCSI的硬盘了。第二块会显示成sdb,详细可查阅Linux下硬盘分区的资料]

16 heads, 63 sectors/track, 1040 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Disk /dev/hda doesn't contain a valid partition table

Disk /dev/sda: 85 MB, 85934592 bytes

255 heads, 63 sectors/track, 1044 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 1044 8281507+ 8e Linux LVM

[root@fc4 ~]# fdisk /dev/hda

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 1040.

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): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delet

e 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 disklabelt 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)

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

[此处的1,也可以换成其它的1-4之间的数,但在下边格式化时要使用/dev/hda1。] First cylinder (1-1040, default 1):

Using default value 1

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

[此处我没有输入,使用默认值1040,占用整个硬盘。]

Using default value 1040

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@fc4 ~]# mkfs -t ext2 -c /dev/hda1

[此处的/dev/hda1由上面的输入决定]

mke2fs 1.37 (21-Mar-2005)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

131072 inodes, 524128 blocks

26206 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67633152

block groups

8192 blocks per group, 8192 fragments per group

2048 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Checking for bad blocks (read-only test): done 128

Writing inode tables: done

Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 33 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@fc4 ~]# fdisk -l

Disk /dev/hda: 536 MB, 536870912 bytes

16 heads, 63 sectors/track, 1040 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System

/dev/hda1 1 1040 524128+ 83 Linux

Disk /dev/sda: 85 MB, 85934592 bytes

255 heads, 63 sectors/track, 1044 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 1044 8281507+ 8e Linux LVM [root@fc4 ~]#mount /dev/hda1 /media/hda1

[root@fc4 ~]#下载本文

显示全文
专题