挂载磁盘
fdisk挂载磁盘方法
[root@WY-MIMO-SVR-3 ~]# df -h #查看当前使用磁盘情况
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 36G 1.3G 34G 4% /
devtmpfs 126G 0 126G 0% /dev
tmpfs 126G 0 126G 0% /dev/shm
tmpfs 126G 8.5M 126G 1% /run
tmpfs 126G 0 126G 0% /sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14% /boot
tmpfs 26G 0 26G 0% /run/user/0
[root@WY-MIMO-SVR-3 ~]# fdisk -l #查看所有磁盘信息 可以看/dev/sdb 未挂载磁盘
Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes, 2147483648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b0227
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 83886079 40893440 8e Linux LVM
Disk /dev/mapper/cl-root: 37.7 GB, 37706792960 bytes, 73646080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/cl-swap: 4160 MB, 4160749568 bytes, 8126464 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
#开始硬盘创建分区
[root@WY-MIMO-SVR-3 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x202ce99f.
Command (m for help): n #n表示创建一个新分区
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p #p表示主分区,e表示扩展分区
Partition number (1-4, default 1): 1 #1表示分区编号是1,多个分区时需1-4不同数值
First sector (2048-2147483647, default 2048): #起始值,可直接回车
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2147483647, default 2147483647): #结束值,可直接回车表示全盘分区
Using default value 2147483647
Partition 1 of type Linux and of size 1024 GiB is set
Command (m for help): w #保存,退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@WY-MIMO-SVR-3 ~]# mkfs.ext4 /dev/sdb1 #格式化分区,1表示分区编号
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
67108864 inodes, 268435200 blocks
13421760 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2415919104
8192 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@WY-MIMO-SVR-3 ~]# mkdir /data #创建目录
[root@WY-MIMO-SVR-3 ~]# mount /dev/sdb1 /data #将磁盘挂载到目录下
[root@WY-MIMO-SVR-3 ~]# df -h #查看挂载情况,当前挂载为临时
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 36G 1.3G 34G 4% /
devtmpfs 126G 0 126G 0% /dev
tmpfs 126G 0 126G 0% /dev/shm
tmpfs 126G 8.5M 126G 1% /run
tmpfs 126G 0 126G 0% /sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14% /boot
tmpfs 26G 0 26G 0% /run/user/0
/dev/sdb1 1008G 77M 957G 1% /data
[root@WY-MIMO-SVR-3 ~]# vi /etc/fstab # 设置自动挂载
[root@WY-MIMO-SVR-3 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Dec 8 16:01:00 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0 0
UUID=1382b13d-ffd4-4ea3-82c8-bfc010c460d9 /boot xfs defaults 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
/dev/sdb1 /data ext4 defaults 0 0 #在文件中增加该行信息,磁盘/目录
[root@WY-MIMO-SVR-3 ~]#