详解linux添加硬盘分区挂载教程

2019-10-10 12:47:29王振洲

Command (m for help): n

Command action

  e  extended                                  ···扩展分区

  p  primary partition (1-4)                          ···主分区

p

Partition number (1-4): 1

First cylinder (1-2610, default 1): 

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): 

Using default value 2610 

4、输入p查看分区情况——输入w保存退出(一定要w保存不然无效)

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: 0x09f38795

 

  Device Boot   Start     End   Blocks  Id System

/dev/sdb1        1    2610  20964793+ 83 Linux

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks. 

5、mkfs命令格式化磁盘

[root@oracle ~]# mkfs.ext4 /dev/sdb

mkfs.ext4: invalid fragment size - /dev/sdb 

6、mount命令挂载分区

[root@oracle ~]# mount /dev/sdb /oracle/

You have new mail in /var/spool/mail/root

[root@oracle ~]# df -TH

Filesystem   Type  Size Used Avail Use% Mounted on

/dev/sda2   ext4  19G  11G 7.3G 60% /

tmpfs     tmpfs 2.1G  74k 2.1G  1% /dev/shm

/dev/sda1   ext4  297M  29M 253M 11% /boot

/dev/sdb    ext4  22G  47M  20G  1% /oracle 

7、添加到/etc/fstab文件下保存退出否则重启后硬盘消失

/dev/sdb    /oracle     ext4  defaults,noatime    0 0 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易采站长站。