Linux 添加新硬盘

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



你可能感兴趣的:(Linux 添加新硬盘)