服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Centos - CentOS下添加新硬盘并分区格式化的详细步骤

CentOS下添加新硬盘并分区格式化的详细步骤

2019-10-06 20:54CentOS教程网 Centos

Linux磁带备份,所以我先添加一块硬盘,并相应的建立分区,格式化,然后挂载使用

下面看我操作的步骤:
1.先用Fdisk -l 来查看当前状态下磁盘情况
 
[root@linux1 ~]# fdisk -l
Disk /dev/hda: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 652 5132767 8e Linux LVM
Disk /dev/hdb: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Disk /dev/hdb doesn't contain a valid partition table
上面红色标识行可以看出,我添加了一块新硬盘/dev/hdb,大小为2G,未分区格式化状态。
  
2.用Fdisk /dev/hdb来进行分区操作。 
 
[root@linux1 ~]# fdisk /dev/hdb
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 4161.
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): n //输入N表示新建一个分区
Command action
e extended
p primary partition (1-4)
p //p 表示建立一个原始分区
Partition number (1-4): 1 //1 表示此分区编号为1.
First cylinder (1-4161, default 1): 1 //1表示使用默认起始柱面号.如果要分多个区的话,先盘算好要多大,再输入数字
Last cylinder or size or sizeM or sizeK (1-4161, default 4161): // 输入: 回车 表示使用默认结束柱面号.即此分区使用整个硬盘空间
 
Using default value 4161
 
Command (m for help): w //保存分区
 
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks. 
 
3.再次查看当前分区状态:
[root@linux1 ~]# fdisk -l
 
Disk /dev/hda: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 652 5132767 8e Linux LVM
 
Disk /dev/hdb: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
 
Device Boot Start End Blocks Id System
/dev/hdb1 1 4161 2097112 83 Linux
可以看出,已经出来了一个/dev/hdb1的新分区。下一步将其格式化,再使用
 
4.用mkfs.ext3格式化新分区
[root@linux1 ~]# mkfs.ext3 /dev/hdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524278 blocks
26213 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
 
Writing inode tables: 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.挂载使用。
[root@linux1 ~]# mkdir /mnt/hdb1 //新建一个挂载点。
[root@linux1 ~]# mount /dev/hdb1 /mnt/hdb1 //挂载。
[root@linux1 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
4.3G 3.6G 487M 89% /
/dev/hda1 99M 12M 82M 13% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/hdb1 2.0G 3.0M 1.9G 1% /mnt/hdb1 
 
6 .开机自动挂载
三.设置新硬盘开机自动挂载
在vi /etc/fstab中添加新硬盘的挂载信息.添加下面一行:
/dev/hdb1 /mnt/hdb1 ext3 defaults 1 2(如果还有一个分区就是1 3,以此类推)
这样,每次开机后,系统会自动将/dev/hdb1挂载到/mnt/hdb1

延伸 · 阅读

精彩推荐
  • Centoscentos 7中添加一个新用户并授权的步骤详解

    centos 7中添加一个新用户并授权的步骤详解

    这篇文章主要给大家介绍了关于在centos 7中添加一个新用户并授权的步骤,文中将实现的步骤介绍的非常详细,通过文中介绍的步骤可以轻松的创建一个新...

    Ryan.Miao9832022-02-12
  • CentosCentOS7 阿里云的yum源使用详解

    CentOS7 阿里云的yum源使用详解

    这篇文章主要介绍了CentOS7 阿里云的yum源使用详解的相关资料,这里对备份yum源,添加EPEL源,和缓存清理,进行了介绍,需要的朋友可以参考下...

    天王9312020-12-28
  • CentosCentOS上SVN服务器端程序的安装与使用教程

    CentOS上SVN服务器端程序的安装与使用教程

    SVN是一款高人气的软件项目版本控制系统,由于其在Windows的客户端的简易操作,在Git的浪潮中仍然保有很多的用户数量,这里我们就来看一下CentOS上SVN服务器端...

    cnblogs3902019-07-16
  • Centos使用Xshell连接Centos 6.6服务器操作图文教程

    使用Xshell连接Centos 6.6服务器操作图文教程

    这篇文章主要介绍了使用Xshell连接Centos 6.6服务器操作图文教程,本文用详细的操作步骤讲解了如何使用Xshell连接Centos服务器,需要的朋友可以参考下 ...

    脚本之家4032019-09-18
  • CentosCentOS系统下软件包的制作方法和过程详解

    CentOS系统下软件包的制作方法和过程详解

    今天小编将为大家带来的是CentOS系统下软件包的制作方法和过程详解;希望对大家会有帮助,有需要的朋友一起去看看吧...

    CentOS之家4802019-05-30
  • CentosCentOS6.2网卡设置

    CentOS6.2网卡设置

    如果你想让服务器可以更新、让网友访问你的LINUX服务器,那一定要设置LINUX网上给网卡绑定一个IP,下面我们就介绍CentOS6.2网卡设置IP的方法。...

    CentOS教程网10092021-10-03
  • CentosCentOS 最新版本git的安装教程

    CentOS 最新版本git的安装教程

    本文主要给大家介绍了CentOS 最新版本git的安装教程,非常不错,具有参考借鉴价值,感兴趣的朋友一起看看吧...

    CentOS教程网9252021-11-29
  • Centos在CentOS系统上安装Docker的教程

    在CentOS系统上安装Docker的教程

    这篇文章主要介绍了在CentOS系统上安装Docker的教程,Docker是当下人气最为火热的容器类虚拟软件,需要的朋友可以参考下 ...

    开源中文社区3952019-09-17