关于服务器:如何实现CentOS服务器的扩容

33次阅读

共计 2402 个字符,预计需要花费 7 分钟才能阅读完成。

Linux 的硬盘辨认:

个别应用”fdisk -l”命令能够列出零碎中以后连贯的硬盘

设施和分区信息. 新硬盘没有分区信息, 则只显示硬盘大小信息.

1. 敞开服务器加上新硬盘

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

3. 查看硬盘信息

#fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x0004406e
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          39      307200   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              39        2589    20480000   83  Linux
/dev/sda3            2589        2850     2097152   82  Linux swap / Solaris
/dev/sda4            2850        5222    19057664    5  Extended
/dev/sda5            2850        5222    19056640   83  Linux
 
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x14b52796
   Device Boot      Start         End      Blocks   Id  System

4. 创立新硬盘分区命令参数:

fdisk 能够用 m 命令来看 fdisk 命令的外部命令;
a:命令指定启动分区;
d:命令删除一个存在的分区;
l:命令显示分区 ID 号的列表;
m:查看 fdisk 命令帮忙;
n:命令创立一个新分区;
p:命令显示分区列表;
t:命令批改分区的类型 ID 号;
w:命令是将对分区表的批改存盘让它产生作用

5. 进入磁盘,对磁盘进行分区,留神红色局部。

#fdisk /dev/sdb
Command (m for help):n
Command action
     e    extended                  // 输出 e 为创立扩大分区
     p    primary partition (1-4)      // 输出 p 为创立逻辑分区
p
Partion number(1-4):1      // 在这里输出 l,就进入划分逻辑分区阶段了;First cylinder (51-125, default 51):   // 注:这个就是分区的 Start 值;这里最好间接按回车,如果您输出了一个非默认的数字,会造成空间节约;Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:这个是定义分区大小的,+200M 就是大小为 200M;当然您也能够依据 p 提醒的单位 cylinder 的大小来算,而后来指定 End 的数值。回头看看是怎么算的;还是用 +200M 这个方法来增加,这样能直观一点。如果您想增加一个 10G 左右大小的分区,请输出 +10000M;Command (m for help): w                     // 最初输出 w 回车保留。

查看一下:

#fdisk -l

能够看到 /dev/sdb1 分区, 我就省略截图咯。

6. 格式化分区:

#mkfs.ext3 /dev/sdb1           // 注:将 /dev/sdb1 格式化为 ext3 类型
mke2fs 1.41.12 (17-May-2010)
文件系统标签 =
操作系统:Linux
块大小 =4096 (log=2)
分块大小 =4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
640848 inodes, 2562359 blocks
128117 blocks (5.00%) reserved for the super user
第一个数据块 =0
Maximum filesystem blocks=2625634304
79 block groups
32768 blocks per group, 32768 fragments per group
8112 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
 
正在写入 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 加载这个分区,而后应用这个文件系统;

7. 创立 /data1 目录:

#mkdir /data1

8. 开始挂载分区:

#mount /dev/sdb1 /data1

9. 查看硬盘大小以及挂载分区:

#df -h

10. 配置开机主动挂载

因为 mount 挂载在重启服务器后会生效,所以须要将分区信息写到 /etc/fstab 文件中让它永恒挂载:

#vim /etc/fstab

退出:

/dev/sdb1(磁盘分区) /data1(挂载目录)ext3(文件格式)defaults 0 0 

11. 重启零碎

正文完
 0