`

Centos 增加新硬盘

 
阅读更多
  • 环境介绍
  • 增加步骤

一、环境介绍

 

原主机有500G硬盘,现在新增一颗2T硬盘。

 

 

二、增加步骤

 

  1. 查看硬盘
  2. 新建分区
  3. 格式化
  4. 挂载使用
  5. 设置开机自动挂载 

 

1.查看硬盘

# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0xba24d924

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         287     2097152   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             287       60802   486083584   83  Linux

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x97d16691

   Device Boot      Start         End      Blocks   Id  System

可见一颗sdb硬盘2T存在系统中,但未被格式化。

 

 

2.新建分区

使用fdisk命令对新增的sdb硬盘进行操作

# fdisk /dev/sdb

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

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): p #查看此颗硬盘分区状况

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x97d16691

   Device 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-243201, default 1): 1#从第一个扇区开始
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201): #直接回车使用所有空间
Using default value 243201

Command (m for help): p#再次查看分区情况
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x97d16691

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      243201  1953512001   83  Linux
Partition 1 does not start on physical sector boundary.

Command (m for help): w#保存分区
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

 

 

再次使用fdisk命令查看服务器硬盘情况

# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0xba24d924

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         287     2097152   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             287       60802   486083584   83  Linux

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x97d16691

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      243201  1953512001   83  Linux
Partition 1 does not start on physical sector boundary.

此时可以看见新建的sdb1分区,还需要格式化才能使用。

 

 

3.格式化

使用mkfs命令将新增硬盘格式化为ext3格式

# mkfs.ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
/dev/sdb1 alignment is offset by 512 bytes.
This may result in very poor performance, (re)-partitioning suggested.
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
122101760 inodes, 488378000 blocks
24418900 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
14905 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, 71663616, 78675968,
        102400000, 214990848

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

 

4.挂载使用

# mkdir /eda_bak #建立新挂载点
# mount /dev/sdb1 /eda_bak #挂载使用此硬盘
# mount  #查看系统挂载情况
/dev/sda3 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sdb1 on /eda_bak type ext3 (rw)

# df -h #查看使用空间
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             457G  3.0G  431G   1% /
tmpfs                 995M  260K  994M   1% /dev/shm
/dev/sda1             194M   26M  158M  15% /boot
/dev/sdb1             1.8T  196M  1.7T   1% /eda_bak

 

 

5.设置开机自动挂载

# vi /etc/fstab
增加
/dev/sdb1               /eda_bak                ext3    defaults        1 2

 

 

至此、完成。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics