LINUX下新硬盘挂载

来源:互联网 发布:手机预约挂号软件 编辑:程序博客网 时间:2024/05/01 15:18

关于新硬盘的挂载主要有几个步奏:(我用的是Ubuntu9.10)
一.首先查看自己的设备,用命令 fdisk -l
   youlong@ubuntu:~$ sudo fdisk -l
   Disk /dev/sda: 10.7 GB, 10737418240 bytes
   255 heads, 63 sectors/track, 1305 cylinders
   Units = cylinders of 16065 * 512 = 8225280 bytes
   Disk identifier: 0x000c4e91

   Device Boot      Start         End      Blocks   Id  System
  /dev/sda1   *           1        1243     9984366   83  Linux
  /dev/sda2            1244        1305      498015    5  Extended
  /dev/sda5            1244        1305      497983+  82  Linux swap / Solaris

  Disk /dev/sdb: 5368 MB, 5368709120 bytes
  255 heads, 63 sectors/track, 652 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Disk identifier: 0x00000000
  (其中sdb是新添硬盘)

二.对新硬盘进行分区,用命令fdisk /dec/sdb
   eg:
   [root@linux ~] sudo fdisk /dev/sdb             "sdb为新添硬盘"
   youlong@ubuntu:~$ sudo fdisk /dev/sdb
   Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
   Building a new DOS disklabel with disk identifier 0x784f9b03.
   Changes will remain in memory only, until you decide to write them.
   After that, of course, the previous content won't be recoverable.
   Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):                            "进入fdisk程序界面"               
  输入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)
 从上述参数中选择适当参数进行磁盘分区:
 几个重要的参数:
 d-删除一个分区,n- 新增一个分区,p-列出当前分区,q-不存储离开,w-存储离开
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): +1G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (133-652, default 133):
Using default value 133
Last cylinder, +cylinders or +size{K,M,G} (133-652, default 652): +1G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (265-652, default 265):
Using default value 265
Last cylinder, +cylinders or +size{K,M,G} (265-652, default 652): +1g
Unsupported suffix: 'g'.
Supported: 10^N: KB (KiloByte), MB (MegaByte), GB (GigaByte)
            2^N: K  (KibiByte), M  (MebiByte), G  (GibiByte)
Last cylinder, +cylinders or +size{K,M,G} (265-652, default 652): +1G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (397-652, default 397): 4
Value out of range.
First cylinder (397-652, default 397):
Using default value 397
Last cylinder, +cylinders or +size{K,M,G} (397-652, default 652): +1G

Command (m for help): P

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x784f9b03

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  83  Linux
/dev/sdb2             133         264     1060290   83  Linux
/dev/sdb3             265         396     1060290   83  Linux
/dev/sdb4             397         528     1060290   83  Linux
Command (m for help): w
The partition table has been altered!

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

三.对分区好的磁盘进行格式化
   使用命令mke2fs 加上形参(关于各项形参可以man一下),对于采用的格式可以参考主硬盘sda,使用命令fsck
youlong@ubuntu:~$ sudo mke2fs -j -b 4096 -L "label1" /dev/sdb1
[sudo] password for youlong:
mke2fs 1.41.9 (22-Aug-2009)
文件系统标签=label1
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
66384 inodes, 265064 blocks
13253 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=272629760
9 block groups
32768 blocks per group, 32768 fragments per group
7376 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376

正在写入inode表: 完成                           
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 39 mounts or
1te
其他分区同理格式化为ext3格式

四.将各新添分区添加到LINUX系统下
   磁盘的载入跟卸载分别使用命令mount 跟umount
   youlong@ubuntu:~$ sudo mount -t ext3 /dev/sdb1   /home/
   youlong@ubuntu:~$
五.重启
   命令reboot一下就可以,同时可以在/home目录下添加的硬盘了