Liunx添加新硬盘其实和Windows的操作一样,但一个是图形化操作,另一个是命令行操作,不过步骤是一样,下面就动手演示和讲解
Linux挂载新硬盘
1、查看硬盘信息
命令:fdisk -l
[root@center ~]# fdisk -l
Disk /dev/vda: 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: 0x0003a7b4
Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20970496 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes #第二块硬盘的信息和分区信息
16 heads, 63 sectors/track, 208050 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
2、创建新硬盘分区
命令:fdisk /dev/vdb
[root@center ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1e694286.
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 #e为创建扩展分区
p primary partition (1-4) #p为创建逻辑分区
p
Partition number (1-4): 1 #在这里输入1,就进入划分逻辑分区阶段了;
First cylinder (1-208050, default 1): 1 #分区的Start 值,这里最好直接按回车,否则可能会造成空间浪费;
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-208050, default 208050): 208050 #分区的Over值,我就分一个区
Using default value 208050
Command (m for help): w #最后输入w回车保存退出。
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
fdisk可以用m命令来看fdisk命令的内部命令;
a:命令指定启动分区;
d:命令删除一个存在的分区;
l:命令显示分区ID号的列表;
m:查看fdisk命令帮助;
n:命令创建一个新分区;
p:命令显示分区列表;
t:命令修改分区的类型ID号;
w:命令是将对分区表的修改存盘让它发生作用;
3、确认新分区信息
命令:fdisk -l
[root@center ~]# fdisk -l
Disk /dev/vda: 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: 0x0003a7b4
Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20970496 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes
16 heads, 63 sectors/track, 208050 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1e694286
Device Boot Start End Blocks Id System
/dev/vdb1 1 208050 104857168+ 83 Linux #刚创建好的分区信息
4、格式化分区
命令:mkfs.ext4 /dev/vdb1
[root@center ~]# mkfs.ext4 /dev/vdb1
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
6553600 inodes, 26214292 blocks
1310714 blocks (5.00%) reserved for the super user
First data block=0 #第一个数据块
Maximum filesystem blocks=4294967296
800 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, 20480000, 23887872