1.识别分区和硬盘

在 /dev/ 目录下找到新的硬盘,sda 为本地硬盘,sda1、sda2.. 为分区,sdb 就是新添加的硬盘,如:

[root@wusuyuan ~]# ls -ltr /dev/sd*
brw-rw----. 1 root disk 8,  0 11月 14 14:12 /dev/sda
brw-rw----. 1 root disk 8,  3 11月 14 14:12 /dev/sda3
brw-rw----. 1 root disk 8,  2 11月 14 14:12 /dev/sda2
brw-rw----. 1 root disk 8,  1 11月 14 14:12 /dev/sda1
brw-rw----. 1 root disk 8, 16 11月 14 14:12 /dev/sdb

学习的机器为虚拟机,与真实的物理机器略有不同,真实的物理机器根据硬盘接口类型(IDE、SATA、SCSI、光纤通道和SAS)可能为hda、sda或其它的名称。

2.新硬盘分区

使用管理员权限对新的硬盘 /dev/sdb 分区:

[root@wusuyuan ~]# 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 0xb7ee5a9d.
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): 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): n   ####创建新的分区
Command action
   e   extended
   p   primary partition (1-4)
e   ####选择分区类型(扩展分区、主分区)
Partition number (1-4): 1  ####分区数,这里分1个区
First cylinder (1-2610, default 1): 2610  ####这里输入分区大小,默认单位为mb
Command (m for help): p ####查看分区表信息
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: 0x35b64cad
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2610        2610        8032+   5  Extended
Command (m for help): w ####写入分区信息,如果未确定或想取消,输入q退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

在写入分区信息时要仔细核对和确认,写入分区信息后不可再更改。 分区完成后,新的硬盘还是不能使用的,需要进行格式化。

3.使用mkfs进行格式化硬盘分区

[sywu@wusuyuan ~]$ mkfs
Usage: mkfs [-V] [-t fstype] [fs-options] device [size]
 #-t 格式化分区类型,如 ext3、ext4
[root@wusuyuan ~]# mkfs -t ext4 /dev/sdb  #对分区进行格式化,类型为ext4
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
无论如何也要继续? (y,n) y
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 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 35 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

分区格式化完成后使用mount 命令装载新的分区:

[root@wusuyuan ~]# mount /dev/sdb /disk2 #装载分区
[root@wusuyuan ~]# df -h  #查询分区
文件系统              容量  已用  可用 已用%% 挂载点
/dev/sda2              97G  9.9G   82G  11% /
tmpfs                 1.9G  200M  1.7G  11% /dev/shm
/dev/sda1             194M   52M  133M  28% /boot
/dev/sdb               20G  1.9G   17G  11% /disk2

4.配置新的分区自动装载

在/etc/fstab 中配置分区自动装载
[root@wusuyuan ~]# vim /etc/fstab #
# /etc/fstab
# Created by anaconda on Sun Jan  5 08:17:56 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=9c738ca5-810a-46ec-b896-57fc8286b2a5 /                       ext4    defaults        1 1
UUID=05b44d26-bd3a-4688-81e1-c83da70512a7 /boot                   ext4    defaults        1 2
UUID=7146f132-f77b-4a17-8686-d7c9c9be10ad 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/sdb                /disk2                 ext4     defaults        1 2 #加入新的分区信息

Linux 添加新硬盘的更多相关文章

  1. Linux添加新硬盘自动挂载硬盘

    Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204 ...

  2. linux 添加新硬盘的方法

    在服务器上把硬盘接好,启动linux,以root登陆. 比如我新加一块SCSI硬盘,需要将其分成三个区: #fdisk /dev/sdb 进入fdisk模式: Command (m for help) ...

  3. linux添加新硬盘不需要重启识盘,及查看uuid

     添加新物理硬盘 用ssh工具连接到服务器,执行:fdisk -l 查看磁盘,并没有新加的硬盘 fdisk -l查看硬盘及分区状态     查看主机总线号,命令:ls /sys/class/scsi_ ...

  4. linux添加新硬盘

    1.添加新磁盘 2.fdisk -l查看磁盘被识别的名称 3.如果输入fdisk -l命令没有找到新的磁盘,按下面步骤操作 1)进入到cd /sys/class/scsi_host/ 2)echo & ...

  5. Linux 添加新硬盘 LVM操作(作用:新增硬盘的卷管理)

    1 查看当前系统硬盘及分区情况 (注:linux中SCSI的第1个硬盘/dev/sda,第2个硬盘/dev/sdb依此类推) 2 初始化分区sdb为物理卷pv pvcreate /dev/sdb  / ...

  6. linux添加新硬盘并格式化

    1.查看当前系统硬盘及分区情况 (注:Linux中SCSI的第1个硬盘/dev/sda,第2个硬盘/dev/sdb依此类推) 2. 初始化分区sdb为物理卷pv pvcreate /dev/sdb   ...

  7. Linux添加新硬盘及分区,格式化,挂载

    1.查看分区信息: [root@localhost /]# fdisk -l Disk /dev/vdb: 209.7 GB, 209715200000 bytes16 heads, 63 secto ...

  8. Linux添加新硬盘,设置分区和开机自动挂载之图文教程!

    虚拟机添加硬盘的步骤就不多废话了,主要列出添加硬盘后要进行设置的几个详细步骤: 1.查看磁盘信息:fdisk -ls 添加前如下图所示: 添加后如下图: 也可以用:ls /dev/sd*查看,如下图: ...

  9. linux挂载新硬盘

    Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204 ...

随机推荐

  1. dubbo相关的知识点总结

    dubbo最近提交到了apache,成为了apache的孵化项目,又开始活跃起来了.就官方在git上面的说明文档和其他资料,学习总结以下dubbo的一些知识点. .The dubbo protocol ...

  2. flv 解封装

    #include <stdio.h> #include <stdlib.h> #include <string.h> #define DEBUG_INFO type ...

  3. POJ 2785 4 Values whose Sum is 0(折半枚举+二分)

    4 Values whose Sum is 0 Time Limit: 15000MS   Memory Limit: 228000K Total Submissions: 25675   Accep ...

  4. Java 中的instanceof 运算符

    Java 中的instanceof 运算符是用来在运行时指出对象是否是特定类的一个实例.instanceof通过返回一个布尔值来指出,这个对象是否是这个特定类或者是它的子类的一个实例. 用法:resu ...

  5. node中转换URL字符串与查询字符串

    一个完整的URL字符串中,从"?"(不包括?)到"#"(如果存在#)或者到该URL字符串结束(如果不存在#)的这一部分称为查询字符串. 可以使用Query St ...

  6. 【BZOJ】1823: [JSOI2010]满汉全席(2-sat)

    题目 传送门:QWQ 分析 2-sat模板(然而辣鸡如我还是调了好久) 代码 //bzoj 1823 2-sat #include <bits/stdc++.h> using namesp ...

  7. activity与service进程内通信

    package com.example.binbin.testbinder; import android.app.Service; import android.content.Intent; im ...

  8. mongodb分片(七)

    1.插入负载技术分片架构图 2.片键的概念和用处 看下面这个普通的集合和分片后的结果 3.什么时候用到分片呢? 3.1机器的磁盘空间不足 3.2单个的mongoDB服务器已经不能满足大量的插入操作 3 ...

  9. Android apk couldn't install

    an existing package with the same name and signature is already installed

  10. WPF 绑定以基础数据类型为集合的无字段名的数据源

    WPF 绑定以基础数据类型为集合的无字段名的数据源 运行环境:Window7 64bit,.NetFramework4.61,C# 6.0: 编者:乌龙哈里 2017-02-21 我们在控件的数据绑定 ...