码迷,mamicode.com
首页 > 系统相关 > 详细

linux挂载新硬盘

时间:2014-09-03 16:36:26      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:des   style   color   os   io   使用   strong   ar   for   

  注:红色部分表示相关命令
1、查看数据盘
  在没有分区和格式化数据盘之前,使用 “df –h”命令,是无法看到数据盘的,可以使用“fdisk -l”命令查看
  #df -h
     Filesystem Size Used Avail Use% Mounted on
    /dev/xvda1 20G 1.4G 18G 8% /
      tmpfs 498M 0 498M 0% /dev/shm
     #fdisk -l

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00060953

Device Boot Start End Blocks Id System
/dev/xvda1 * 1 2611 20970496 83 Linux

Disk /dev/xvdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

如果没有就不用挂载了。

2、 对数据盘进行分区
执行“fdisk -S 56 /dev/xvdb”命令,对数据盘进行分区;
根据提示,依次输入“n”,“p”“1”,两次回车,“wq”,分区就开始了,很快就会完成。

#fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb419e799.
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)

WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to
switch off the mode (command ‘c‘) and change display units to
sectors (command ‘u‘).

Command (m for help):    n

Command action

  e extended

  p primary partition (1-4)

p

Partition number(1-4): 1 //这里说明下,这里真写的是分区号,默认直接按1 Enter

First cylinder(1-6527,default 1):  //Enter

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} {1-6527, default 6527): //Enter

Using default value 6527

Command (m for help):  wq

3、 查看新的分区
使用“fdisk -l”命令可以看到,新的分区xvdb1已经建立完成了。
#fdisk -l

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00060953

Device Boot Start End Blocks Id System
/dev/xvda1 * 1 2611 20970496 83 Linux

Disk /dev/xvdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x85df9f2e

Device Boot Start End Blocks Id System
/dev/xvdb1 1 6527 52428096 83 Linux

4、格式化新分区

使用“mkfs.ext3 /dev/xvdb1”命令对新分区进行格式化,格式化的时间根据硬盘大小有所不同。
#mkfs.ext3 /dev/xvdb1

mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

5、添加分区信息
 
#echo ‘/dev/xvdb1  /mnt ext3    defaults    0  0‘ >> /etc/fstab
然后查看写入是否成功。
#cat /etc/fstab


#
# /etc/fstab
# Created by anaconda on Thu Jul 3 10:43:14 2014
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=2a348234-4a73-491c-98e9-47900d88697b / ext4 defaults,barrier=0 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
none /proc/xen xenfs defaults 0 0
/dev/xvdb1 /mnt ext3 defaults 0 0

6、挂载新分区
使用“mount -a”命令挂载新分区
#mount -a     
然后查看是否挂载成功
#df -h

Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 1.7G 18G 9% /
tmpfs 498M 0 498M 0% /dev/shm
/dev/xvdb1 50G 180M 47G 1% /mnt

完成。

linux挂载新硬盘

标签:des   style   color   os   io   使用   strong   ar   for   

原文地址:http://www.cnblogs.com/yxc6123/p/3953777.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!