免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1293 | 回复: 0
打印 上一主题 下一主题

[系统管理] Linux上添加新硬盘 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-06-28 06:42 |只看该作者 |倒序浏览
系统:Redhat AS3 UP3
硬盘:scsi
注意:# 表示是root用户执行的命令

  1. [root@cncmail data1]# fdisk -l ## 这里是查看目前系统上有几块硬盘

  2. Disk /dev/sda: 36.4 GB, 36401479680 bytes
  3. 255 heads, 63 sectors/track, 4425 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes

  5. Device Boot Start End Blocks Id System
  6. /dev/sda1 * 1 255 2048256 83 Linux
  7. /dev/sda2 256 1530 10241437+ 83 Linux
  8. /dev/sda3 4296 4425 1044225 82 Linux swap
  9. /dev/sda4 1531 4295 22209862+ f Win95 Ext'd (LBA)
  10. /dev/sda5 1531 2805 10241406 83 Linux
  11. /dev/sda6 2806 4295 11968393+ 83 Linux

  12. Partition table entries are not in disk order

  13. Disk /dev/sdb: 36.7 GB, 36703918080 bytes ## 这里发现/dev/sdb,容量36.7G,切未被分区
  14. 255 heads, 63 sectors/track, 4462 cylinders
  15. Units = cylinders of 16065 * 512 = 8225280 bytes

  16. Disk /dev/sdc doesn't contain a valid partition table
  17. [root@linux root]# fdisk /dev/sdb ## 接下去就对/dev/sdb分区进行分区

  18. The number of cylinders for this disk is set to 4462.
  19. There is nothing wrong with that, but this is larger than 1024,
  20. and could in certain setups cause problems with:
  21. 1) software that runs at boot time (e.g., old versions of LILO)
  22. 2) booting and partitioning software from other OSs
  23. (e.g., DOS FDISK, OS/2 FDISK)

  24. Command (m for help): m
  25. Command action
  26. a toggle a bootable flag
  27. b edit bsd disklabel
  28. c toggle the dos compatibility flag
  29. d delete a partition
  30. l list known partition types
  31. m print this menu
  32. n add a new partition
  33. o create a new empty DOS partition table
  34. p print the partition table
  35. q quit without saving changes
  36. s create a new empty Sun disklabel
  37. t change a partition's system id
  38. u change display/entry units
  39. v verify the partition table
  40. w write table to disk and exit
  41. x extra functionality (experts only)

  42. Command (m for help): p ## 打印出目前该硬盘下的分区列表

  43. Disk /dev/sdb: 36.7 GB, 36703918080 bytes
  44. 255 heads, 63 sectors/track, 4462 cylinders
  45. Units = cylinders of 16065 * 512 = 8225280 bytes

  46. Device Boot Start End Blocks Id System

  47. Command (m for help): n ## 增加一个分区
  48. Command action
  49. e extended
  50. p primary partition (1-4)
  51. ## 因为通常选择主分区,所以这里打一个p
  52. p
  53. Partition number (1-4): 1 ## 这里因为是第一个分却,所以只选择1,如果是第二个分区,则选择2,依次类推
  54. First cylinder (1-4462, default 1): ## 新分区起始的磁盘块数
  55. Using default value 1
  56. Last cylinder or +size or +sizeM or +sizeK (1-4462, default 4462):
  57. 如果要分区10G,这里可以直接输入:+10240M,因为这里要全部使用硬盘空间,则用默认
  58. Using default value 4462

  59. Command (m for help): p

  60. Disk /dev/sdb: 36.7 GB, 36703918080 bytes
  61. 255 heads, 63 sectors/track, 4462 cylinders
  62. Units = cylinders of 16065 * 512 = 8225280 bytes

  63. Device Boot Start End Blocks Id System
  64. /dev/sdb1 1 4462 35840983+ 83 Linux
  65. ## 这里第一个分区已经分好了,接下去得把这个分区写入硬盘,用w
  66. Command (m for help): w
  67. The partition table has been altered!

  68. Calling ioctl() to re-read partition table.
  69. Syncing disks.
复制代码
下面的工作就是对该硬盘进行格式,我这里是格式化成ext3
  1. [root@linux root]# mke2fs -j /dev/sdb1
  2. mke2fs 1.32 (09-Nov-2002)
  3. Filesystem label=
  4. OS type: Linux
  5. Block size=4096 (log=2)
  6. Fragment size=4096 (log=2)
  7. 4480448 inodes, 8960245 blocks
  8. 448012 blocks (5.00%) reserved for the super user
  9. First data block=0
  10. 274 block groups
  11. 32768 blocks per group, 32768 fragments per group
  12. 16352 inodes per group
  13. Superblock backups stored on blocks:
  14. 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
  15. 4096000, 7962624

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

  19. This filesystem will be automatically checked every 23 mounts or
  20. 180 days, whichever comes first. Use tune2fs -c or -i to override.
复制代码
检查一下,是否已经格式话好
  1. [root@linux root]# fdisk -l

  2. Disk /dev/sda: 36.4 GB, 36401479680 bytes
  3. 255 heads, 63 sectors/track, 4425 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes

  5. Device Boot Start End Blocks Id System
  6. /dev/sda1 * 1 255 2048256 83 Linux
  7. /dev/sda2 256 1530 10241437+ 83 Linux
  8. /dev/sda3 4296 4425 1044225 82 Linux swap
  9. /dev/sda4 1531 4295 22209862+ f Win95 Ext'd (LBA)
  10. /dev/sda5 1531 2805 10241406 83 Linux
  11. /dev/sda6 2806 4295 11968393+ 83 Linux

  12. Partition table entries are not in disk order

  13. Disk /dev/sdb: 36.7 GB, 36703918080 bytes
  14. 255 heads, 63 sectors/track, 4462 cylinders
  15. Units = cylinders of 16065 * 512 = 8225280 bytes

  16. Device Boot Start End Blocks Id System
  17. /dev/sdb1 1 4462 35840983+ 83 Linux
复制代码
分区分好,也格式化好了,下面就是挂载
我把/dev/sdb1挂载到/data1下
  1. [root@linux root]# mkdir /data1 ## 首先建立挂载的目录data1
  2. [root@linux root]# vi /etc/fstab ##
复制代码
修改/etc/fstab,使系统启动就可以自动挂载,当然也可以用mount命令,这里我习惯用这个!
  1. LABEL=/ / ext3 defaults 1 1
  2. LABEL=/bak /bak ext3 defaults,quota 1 2
  3. /dev/sdb1 /data1 ext3 defaults 1 2
  4. none /dev/pts devpts gid=5,mode=620 0 0
  5. none /proc proc defaults 0 0
  6. none /dev/shm tmpfs defaults 0 0
  7. LABEL=/usr /usr ext3 defaults 1 2
  8. LABEL=/var /var ext3 defaults 1 2
  9. /dev/sda3 swap swap defaults 0 0
  10. /dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
  11. /dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
复制代码
重起后,把系统重起一下,查看是否挂载成功:
  1. [root@linux data1]# df -h
复制代码
文件系统 容量 已用 可用 已用% 挂载点
  1. /dev/sda1 2.0G 454M 1.4G 25% /
  2. /dev/sda6 12G 53M 11G 1% /bak
  3. /dev/sdb1 34G 33M 32G 1% /data1
  4. none 250M 0 250M 0% /dev/shm
  5. /dev/sda2 9.7G 1.5G 7.7G 17% /usr
  6. /dev/sda5 9.7G 8.6G 559M 95% /var
复制代码
这里看到/dev/sda6 12G 53M 11G 1% /bak
说明已经挂载成功。
本文原始链接:http://www.jbxue.com/linuxjishu/4935.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP