linux-centos挂载新硬盘操作

类似的文章网上已经有很多,这里是记录重要操作的命令,精简流程

精简后的命令:

fdisk -l
df -h
fdisk /dev/vdb
fdisk -l /dev/vdb
mkfs -t ext4 /dev/vdb
mkdir /alidata
echo "/dev/vdb /alidata ext4 defaults 0 0" >> /etc/fstab
mount -a

以下内容也是来自网络,经本人测试可行

流程如下链接:

http://www.centoscn.com/CentOS/config/2014/0318/2591.html

查看数据盘分区是否成功
命令:fdisk -l
若有出现红色部分,则说明成功

数据盘分区
命令:fdisk /dev/sdb
依次输入n,p,1,w

fdisk -l /dev/sdb

格式化mkfs -t ext4 /dev/xvdb
添加该分区信息
首先创建分区即将挂载点.我创建 alidata目录作为我的分区挂载点
命令:mkdir /alidata
添加该分区信息命令:echo "/dev/xvdb /alidata ext3 defaults 0 0" >> /etc/fstab
查看是否添加成功命令:cat /etc/fstab

挂载该数据盘
命令:mount -a
查看挂载是否成功
命令:df -h

添加分区信息中的命令 echo "/dev/sdb1 /alidata ext3 defaults 0 0" >> /etc/fstab.这里的是defaults而不是default,否则挂载不成功

查看当前目录下的文件大小    du -sh

[root@DB-ONE-SERVER~]# 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 2610.
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): p
 
 
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Dvice Boot      Start         End      Blocks   Id  System
 
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): 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): 
Using default value 2610
 
Command (m for help): p
 Disk /dev/sdb: 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/sdb1               1        2610    20964793+  83  Linux
 Command (m for help): w
The partition table has been altered!

fdisk -l /dev/sdb
mkfs.ext4 /dev/sdb1
原文地址:https://www.cnblogs.com/fangyuan303687320/p/5063773.html