小紀的程序員生活!

          Linux 添加新硬盤

          在Linux中添加新的硬盤,并自動掛載。測試環境CentOS5.4

          1、檢查所有硬盤
          # fdisk -l
          Disk /dev/sda: 21.4 GB, 21474836480 bytes
          255 heads, 63 sectors/track, 2610 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        2610    20860402+  8e  Linux LVM

          Disk /dev/sdb: 274.8 GB, 274877906944 bytes
          255 heads, 63 sectors/track, 33418 cylinders
          Units = cylinders of 16065 * 512 = 8225280 bytes

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

          2、為硬盤分區
          #fdisk /dev/sdb
          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 33418.
          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   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):

          3、創建分區
          Command (m for help): n
          Command action
             e   extended
             p   primary partition (1-4)
          p     //輸入p選擇為主分區
          Partition number (1-4): 1  //主分區號
          First cylinder (1-33418, default 1):   //開始
          Using default value 1
          Last cylinder or +size or +sizeM or +sizeK (1-33418, default 33418): //結束
          Using default value 33418

          4、查看
          Command (m for help): p

          Disk /dev/sdb: 274.8 GB, 274877906944 bytes
          255 heads, 63 sectors/track, 33418 cylinders
          Units = cylinders of 16065 * 512 = 8225280 bytes

             Device Boot      Start         End      Blocks   Id  System
          /dev/sdb1               1       33418   268430053+  83  Linux

          5、保存
          Command (m for help): w
          The partition table has been altered!

          Calling ioctl() to re-read partition table.
          Syncing disks.

          保存之后,需要將新分區格式劃,命令如下:
          6、格式劃
          #mkfs.ext3 /dev/sdb1
          這樣,便可格式化完成,下面可以掛載測試
          #mount /dev/sdb1 /mnt

          7、開機自動掛載
          修改/etc/fstab文件在最后一行添加:
          硬盤        掛載點  分區類型            
          /dev/sdb1    /mnt      ext3       default     0 0



          posted on 2010-04-29 10:14 紀敏強 閱讀(224) 評論(0)  編輯  收藏 所屬分類: Linux服務器設置

          My Links

          Blog Stats

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          文章分類

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 安义县| 汉阴县| 玉屏| 隆化县| 都江堰市| 寿宁县| 宁明县| 鄂托克前旗| 邵阳县| 安塞县| 通河县| 定陶县| 甘泉县| 永宁县| 同德县| 定兴县| 长治县| 鄯善县| 乌兰县| 瓮安县| 濮阳县| 罗源县| 甘孜| 华蓥市| 石台县| 云林县| 南江县| 和顺县| 奇台县| 绵阳市| 长岭县| 湘潭市| 鞍山市| 浦江县| 丹凤县| 辽阳市| 江都市| 福安市| 金溪县| 来安县| 罗源县|