红联Linux门户
Linux帮助

Linux技能添加硬盘的方法

发布时间:2007-02-25 15:47:35来源:红联作者:Dream
本人linux菜鸟.请大家多多切磋.增长见识,技术.

[root@localhost root]# fdisk -l 显示所有分区信息

Disk /dev/sda: 8589 MB, 8589934592 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 1012 8024467+ 83 Linux
/dev/sda3 1013 1044 257040 82 Linux swap

Disk /dev/hda: 8589 MB, 8589934592 bytes ---->找到新的设备
15 heads, 63 sectors/track, 17753 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

Disk /dev/hda doesn't contain a valid partition table
[root@localhost root]# 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 17753.
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 ---->通过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)

Command (m for help):

Command (m for help): n ----->添加新的分区
Command action
e extended 扩展
p primary partition (1-4) 主
p
Partition number (1-4): 1 第一个主分区
First cylinder (1-17753, default 1): 默认从第一柱面开始
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-17753, default 17753): +2048M 大小为2G

Command (m for help): p 显示分区表以及分区信息

Disk /dev/hda: 8589 MB, 8589934592 bytes
15 heads, 63 sectors/track, 17753 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 4234 2000533+ 83 Linux

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e 扩展
Partition number (1-4): 2 添加第二个分区
First cylinder (4235-17753, default 4235):
Using default value 4235
Last cylinder or +size or +sizeM or +sizeK (4235-17753, default 17753): 使用全部空间
Using default value 17753

Command (m for help): p 显示分区表

Disk /dev/hda: 8589 MB, 8589934592 bytes
15 heads, 63 sectors/track, 17753 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 4234 2000533+ 83 Linux
/dev/hda2 4235 17753 6387727+ 5 Extended

Command (m for help): n 添加第三个分区
Command action
l logical (5 or over) 逻辑
p primary partition (1-4) 主
l
First cylinder (4235-17753, default 4235):
Using default value 4235
Last cylinder or +size or +sizeM or +sizeK (4235-17753, default 17753): +3072M

Command (m for help): p

Disk /dev/hda: 8589 MB, 8589934592 bytes
15 heads, 63 sectors/track, 17753 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 4234 2000533+ 83 Linux
/dev/hda2 4235 17753 6387727+ 5 Extended
/dev/hda5 4235 10584 3000343+ 83 Linux

Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (10585-17753, default 10585):
Using default value 10585
Last cylinder or +size or +sizeM or +sizeK (10585-17753, default 17753):
Using default value 17753

Command (m for help): p

Disk /dev/hda: 8589 MB, 8589934592 bytes
15 heads, 63 sectors/track, 17753 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 4234 2000533+ 83 Linux
/dev/hda2 4235 17753 6387727+ 5 Extended
/dev/hda5 4235 10584 3000343+ 83 Linux
/dev/hda6 10585 17753 3387321 83 Linux

Command (m for help): w 将所有操作写入分区表,分区完成
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost root]#

[root@localhost root]# fdisk -l 列出新的分区情况

Disk /dev/sda: 8589 MB, 8589934592 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 1012 8024467+ 83 Linux
/dev/sda3 1013 1044 257040 82 Linux swap

Disk /dev/hda: 8589 MB, 8589934592 bytes
15 heads, 63 sectors/track, 17753 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 4234 2000533+ 83 Linux 主1
/dev/hda2 4235 17753 6387727+ 5 Extended 扩展1
/dev/hda5 4235 10584 3000343+ 83 Linux 逻辑1
/dev/hda6 10585 17753 3387321 83 Linux 逻辑2
[root@localhost root]#

[root@localhost root]# mkfs.ext3 /dev/hda1 对分区hda1进行格式化,使用ext3文件系统
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
250368 inodes, 500133 blocks
25006 blocks (5.00%) reserved for the super user
First data block=0
16 block groups
32768 blocks per group, 32768 fragments per group
15648 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost root]#




[root@localhost root]# mkfs -t ext3 /dev/hda5 对逻辑分区/dev/hda5和/dev/hda6进行ext3格式化
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
375360 inodes, 750085 blocks
37504 blocks (5.00%) reserved for the super user
First data block=0
23 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost root]# mkfs -t ext3 /dev/hda6
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
423488 inodes, 846830 blocks
42341 blocks (5.00%) reserved for the super user
First data block=0
26 block groups
32768 blocks per group, 32768 fragments per group
16288 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost root]#

[root@localhost root]# mkdir /newdisk1 /newdisk2 /newdisk3 建立挂载点
[root@localhost root]# mount /dev/hda1 /newdisk1 将/dev/hda1 挂到/newdisk1
[root@localhost root]# mount /dev/hda5 /newdisk2 将/dev/hda5 挂到/newdisk2
[root@localhost root]# mount /dev/hda6 /newdisk3 将/dev/hda6 挂到/newdisk3
[root@localhost root]# df -hl 显示挂载情况
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 7.6G 436M 6.8G 6% /
/dev/sda1 99M 9.2M 85M 10% /boot
none 62M 0 62M 0% /dev/shm
/dev/hda1 1.9G 33M 1.8G 2% /newdisk1
/dev/hda5 2.9G 33M 2.7G 2% /newdisk2
/dev/hda6 3.2G 33M 3.0G 2% /newdisk3
[root@localhost root]#
为了使当前的挂载在每次开机之后都生效,那么需要改写配置文件
改写之后的效果:
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/sda3 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
/dev/hda1 /newdisk1 ext3 defaults 1 1
/dev/hda5 /newdisk2 ext3 defaults 0 0
/dev/hda6 /newdisk3 ext3 defaults
文章评论

共有 1 条评论

  1. dinfli 于 2007-02-26 11:31:54发表:

    不错啊,支持啊!