linux挂载硬盘

1、添加新硬盘并查看添加硬盘信息

1)、关闭服务器加上新硬盘,或者支持热拔插添加新硬盘,新硬盘没有分区信息,只显示硬盘大小信息。

2)、启动服务器,以root用户登录

3)、查看硬盘状态信息

fdisk -l

[root@caisongliang ~]# fdisk -l


Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x000aecba

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3917    30944256   8e  Linux LVM


Disk /dev/sdb: 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: 0x00000000

2、创建新硬盘分区

进入磁盘,对磁盘进行分区,直接跟硬盘名。

fdisk /dev/sdb

[root@caisongliang ~]# 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 0x6ab30155.
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
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610

Command (m for help): w
The partition table has been altered!

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

3、查看分区是否成功

[root@caisongliang ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x000aecba

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3917    30944256   8e  Linux LVM

Disk /dev/sdb: 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: 0x6ab30155

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+  83  Linux

Disk /dev/mapper/vg_caisongliang-lv_root: 29.6 GB, 29603397632 bytes
255 heads, 63 sectors/track, 3599 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

PS:如果创建完之后,cat /proc/partitions 查看不到对应的分区,使用parprobe /dev/sdb 命令刷新一下就可以了
[root@caisongliang ~]# partprobe /dev/sdb
[root@caisongliang ~]#

[root@caisongliang ~]# cat /proc/partitions
major minor  #blocks  name

   8        0   31457280 sda
   8        1     512000 sda1
   8        2   30944256 sda2
   8       16   20971520 sdb
   8       17   20964793 sdb1
 253        0   28909568 dm-0
 253        1    2031616 dm-1

4、格式化分区
mkfs -t ext3 /dev/sdb1

[root@caisongliang ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
160 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

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

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

5、创建目录 并将 /dev/sdb1 挂在到该目录下

[root@caisongliang ~]# mkdir /usr/local/c01
[root@caisongliang ~]# mount /dev/sdb1 /usr/local/c01/
[root@caisongliang ~]# 

6、验证挂载是否成功

df -h

[root@caisongliang ~]# df -h
文件系统          容量  已用  可用 已用%% 挂载点
/dev/mapper/vg_caisongliang-lv_root
                       28G  7.7G   19G  30% /
tmpfs                 495M  100K  495M   1% /dev/shm
/dev/sda1             485M   33M  427M   8% /boot
/dev/sr0              4.0G  4.0G     0 100% /media/CentOS_6.3_Final
/dev/sdb1              20G  173M   19G   1% /usr/local/c01

7、设置开机自动挂载

vi /etc/fstab

[root@caisongliang ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Dec 12 18:27:20 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
#
/dev/mapper/vg_caisongliang-lv_root /                       ext4    defaults        1 1
UUID=5fcdbea7-8d19-47ac-bf97-8e2130981162 /boot                   ext4    defaults        1 2
/dev/mapper/vg_caisongliang-lv_swap swap                    swap    defaults        0 0
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
/dev/sdb1            /usr/local/c01            ext3           defaults          0 0

外部设备                挂载点               文件系统         默认权限       是否备份   是否自检(0表示不,1表示是)

8、重启
reboot

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值