【CentOS】CentOS7 添加新硬盘

参考文章:  https://www.it610.com/article/520586.htm(亲测可用,因没有及时存档,故用该文章调整作为记录)

1、查看硬盘

# fdisk -l
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

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): #从第一个扇区开始(使用默认)
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.

  

3、再次查看

# fdisk -l 
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分区,还需要格式化才能使用)

4、格式化分区

# 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.

  

5、挂载

# 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

  

6、开机自动挂载

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

  

猜你喜欢

转载自www.cnblogs.com/lanse1993/p/12815514.html