宇宙主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

欧基零壹微头条IP归属甄别会员请立即修改密码
查看: 1719|回复: 5

Linux加硬盘建分区

[复制链接]
发表于 2011-11-10 19:23:03 | 显示全部楼层 |阅读模式
1.先用Fdisk -l 来查看当前状态下磁盘情况
  1. [root@linux1 ~]# fdisk -lDisk /dev/hda: 5368 MB, 5368709120 bytes

  2. 255 heads, 63 sectors/track, 652 cylinders

  3. Units = cylinders of 16065 * 512 = 8225280 bytes

  4. Device Boot      Start         End      Blocks   Id  System

  5. /dev/hda1   *           1          13      104391   83  Linux

  6. /dev/hda2              14         652     5132767+  8e  Linux LVM

  7. Disk /dev/hdb: 2147 MB, 2147483648 bytes

  8. 16 heads, 63 sectors/track, 4161 cylinders

  9. Units = cylinders of 1008 * 512 = 516096 bytes

  10. Disk /dev/hdb doesn't contain a valid partition table
复制代码
硬盘/dev/hdb,大小为2G,未分区格式化状态。

2.用Fdisk /dev/hdb来进行分区操作。
  1. [root@linux1 ~]# fdisk /dev/hdb
  2. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  3. Building a new DOS disklabel. Changes will remain in memory only,
  4. until you decide to write them. After that, of course, the previous
  5. content won't be recoverable.

  6. The number of cylinders for this disk is set to 4161.
  7. There is nothing wrong with that, but this is larger than 1024,
  8. and could in certain setups cause problems with:
  9. 1) software that runs at boot time (e.g., old versions of LILO)
  10. 2) booting and partitioning software from other OSs
  11.    (e.g., DOS FDISK, OS/2 FDISK)
  12. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

  13. Command (m for help): n   //输入N表示新建一个分区
  14. Command action
  15.    e   extended
  16.    p   primary partition (1-4)
  17. p  //p 表示建立一个原始分区
  18. Partition number (1-4): 1   //1 表示此分区编号为1.
  19. First cylinder (1-4161, default 1): 1 //1表示使用默认起始柱面号.如果要分多个区的话,先盘算好要多大,再输入数字
  20. Last cylinder or +size or +sizeM or +sizeK (1-4161, default 4161): // 输入: 回车 表示使用默认结束柱面号.即此分区使用整个硬盘空间

  21. Using default value 4161

  22. Command (m for help): w //保存分区

  23. The partition table has been altered!

  24. Calling ioctl() to re-read partition table.
  25. Syncing disks.
复制代码
3.再次查看当前分区状态:
  1. [root@linux1 ~]# fdisk -l

  2. Disk /dev/hda: 5368 MB, 5368709120 bytes
  3. 255 heads, 63 sectors/track, 652 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes

  5.    Device Boot      Start         End      Blocks   Id  System
  6. /dev/hda1   *           1          13      104391   83  Linux
  7. /dev/hda2              14         652     5132767+  8e  Linux LVM

  8. Disk /dev/hdb: 2147 MB, 2147483648 bytes
  9. 16 heads, 63 sectors/track, 4161 cylinders
  10. Units = cylinders of 1008 * 512 = 516096 bytes

  11.    Device Boot      Start         End      Blocks   Id  System
  12. /dev/hdb1               1        4161     2097112+  83  Linux
复制代码
可以看出,已经出来了一个/dev/hdb1的新分区。下一步将其格式化,再使用

4.用mkfs.ext3格式化新分区
  1. [root@linux1 ~]# mkfs.ext3 /dev/hdb1
  2. mke2fs 1.39 (29-May-2006)
  3. Filesystem label=
  4. OS type: Linux
  5. Block size=4096 (log=2)
  6. Fragment size=4096 (log=2)
  7. 262144 inodes, 524278 blocks
  8. 26213 blocks (5.00%) reserved for the super user
  9. First data block=0
  10. Maximum filesystem blocks=536870912
  11. 16 block groups
  12. 32768 blocks per group, 32768 fragments per group
  13. 16384 inodes per group
  14. Superblock backups stored on blocks:
  15.         32768, 98304, 163840, 229376, 294912

  16. Writing inode tables: done
  17. Writing superblocks and filesystem accounting information: done

  18. This filesystem will be automatically checked every 32 mounts or
  19. 180 days, whichever comes first.  Use tune2fs -c or -i to override.
复制代码
5.挂载使用。
  1. [root@linux1 ~]# mkdir /mnt/hdb1   //新建一个挂载点。
  2. [root@linux1 ~]# mount /dev/hdb1 /mnt/hdb1 //挂载。
  3. [root@linux1 ~]# df -h
  4. 文件系统              容量  已用 可用 已用% 挂载点
  5. /dev/mapper/VolGroup00-LogVol00
  6.                       4.3G  3.6G  487M  89% /
  7. /dev/hda1              99M   12M   82M  13% /boot
  8. tmpfs                 125M     0  125M   0% /dev/shm
  9. /dev/hdb1             2.0G  3.0M  1.9G   1% /mnt/hdb1
复制代码
6 .开机自动挂载
三.设置新硬盘开机自动挂载

在/etc/fstab中添加新硬盘的挂载信息.添加下面一行:

/dev/hdb1 /mnt/hdb1 ext3 defaults 1 2(如果还有一个分区就是1 3,以此类推)

每次开机后,系统会自动将/dev/hdb1挂载到/mnt/hdb1上

评分

参与人数 2威望 +40 收起 理由
cnx + 20 精品文章
Captain + 20 精品文章

查看全部评分

发表于 2011-11-10 19:26:08 | 显示全部楼层
你的硬盘模式选的是ide吗?怎么是/dev/hda?
 楼主| 发表于 2011-11-10 19:26:54 | 显示全部楼层

回复 2# themyth 的帖子

那个不重要
发表于 2011-11-10 19:28:52 | 显示全部楼层

回复 1# Abuse 的帖子

支持技术贴。
发表于 2011-11-10 19:30:27 | 显示全部楼层
原帖由 cnx 于 2011-11-10 19:28 发表
支持技术贴。
 楼主| 发表于 2011-11-10 19:48:00 | 显示全部楼层

回复 4# cnx 的帖子

cnx你的私藏品不少哈
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|FastFib VPS论坛

GMT+8, 2024-9-20 19:58 , Processed in 0.068149 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表