挂载磁盘 您所在的位置:网站首页 centos挂载大于2t的硬盘 挂载磁盘

挂载磁盘

2023-04-20 04:22| 来源: 网络整理| 查看: 265

挂在磁盘

step1:虚拟机新加一块磁盘 要重启 [root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 40G 0 disk ├─sda1 8:1 0 2G 0 part /boot └─sda2 8:2 0 37G 0 part ├─centos-root 253:0 0 35G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 2G 0 disk sr0 11:0 1 1024M 0 rom step2 :对sdb进行分区

fdisk命令

fdisk /dev/sdb Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-4194303, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): Using default value 4194303 Partition 1 of type Linux and of size 2 GiB is set Command (m for help): w

最后一定要记得写入 即最后的w

Select (default p): p这询问是新增还是追加

Partition number (1-4, default 1): 1询问是分几个区

[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 40G 0 disk ├─sda1 8:1 0 2G 0 part /boot └─sda2 8:2 0 37G 0 part ├─centos-root 253:0 0 35G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 2G 0 disk └─sdb1 8:17 0 2G 0 part sr0 11:0 1 1024M 0 rom step3 格式化磁盘

还未对sdb2格式化为制定分区的文件系统类型

未分配uuid

[root@localhost ~]# lsblk -f NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 xfs fa4b9dff-310e-48f5-9e1d-5fbc1992a5c9 /boot └─sda2 LVM2_member 23Urtu-nIfh-JbNi-FdxJ-3FKY-8Jeo-spI7gF ├─centos-root xfs b9690362-5b0a-4664-8608-a2a537aa1aa5 / └─centos-swap swap be997a84-255d-49f1-8bbb-58bff5a9b1c8 [SWAP] sdb └─sdb1 sr0

格式化

mkfs指令语

MKFS(8) System Administration MKFS(8) NAME mkfs - build a Linux filesystem SYNOPSIS mkfs [options] [-t type] [fs-options] device [siz

参数

-t, --type type Specify the type of filesystem to be built. If not specified, the default filesystem type (currently ext2) is used. fs-options Filesystem-specific options to be passed to the real filesystem builder. Although not guaranteed, the following options are supported by most filesystem builders. -V, --verbose Produce verbose output, including all filesystem-specific commands that are executed. Specifying this option more than once inhibits execution of any filesystem-specific commands. This is really only useful for testing. -V, --version Display version information and exit. (Option -V will display version information only when it is the only parameter, otherwise it will work

格式化

mkfs -t ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131072 inodes, 524032 blocks 26201 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912

格式化完成

[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 40G 0 disk ├─sda1 8:1 0 2G 0 part /boot └─sda2 8:2 0 37G 0 part ├─centos-root 253:0 0 35G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 2G 0 disk └─sdb1 8:17 0 2G 0 part sr0 11:0 1 1024M 0 rom [root@localhost ~]# lsblk -f NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 xfs fa4b9dff-310e-48f5-9e1d-5fbc1992a5c9 /boot └─sda2 LVM2_member 23Urtu-nIfh-JbNi-FdxJ-3FKY-8Jeo-spI7gF ├─centos-root xfs b9690362-5b0a-4664-8608-a2a537aa1aa5 / └─centos-swap swap be997a84-255d-49f1-8bbb-58bff5a9b1c8 [SWAP] sdb └─sdb1 ext4 6dcdfddb-38b5-4e1c-9251-8e6c7ef6c964 step4 挂载

挂载的概念就是 把分区和文件目录建立联系因为linux一切皆文件

tip 没有进入跟目录

[root@localhost ~]# mount /dev/sdb1 /newdisk mount: mount point /newdisk does not exist [root@localhost ~]# pwd /root

指令mount

[root@localhost ~]# cd / [root@localhost /]# mkdir newdisk [root@localhost /]# mount /dev/sdb1 /newdisk

用法

Usage: mount [-lhV] mount -a [options] mount [options] [--source] | [--target] mount [options] mount []

挂载成功 已经可以看到、newdisk

lsblk -f NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 xfs fa4b9dff-310e-48f5-9e1d-5fbc1992a5c9 /boot └─sda2 LVM2_member 23Urtu-nIfh-JbNi-FdxJ-3FKY-8Jeo-spI7gF ├─centos-root xfs b9690362-5b0a-4664-8608-a2a537aa1aa5 / └─centos-swap swap be997a84-255d-49f1-8bbb-58bff5a9b1c8 [SWAP] sdb └─sdb1 ext4 6dcdfddb-38b5-4e1c-9251-8e6c7ef6c964 /newdisk

命令挂载之后重启以后会失效

step5写入文件永久生效 /etc/fstab [root@localhost /]# vim /etc/fstab [root@localhost /]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat Dec 12 11:19:46 2020 # # 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/centos-root / xfs defaults 0 0 UUID=fa4b9dff-310e-48f5-9e1d-5fbc1992a5c9 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 UUID=6dcdfddb-38b5-4e1c-9251-8e6c7ef6c964 /newdisk ext4 defaults 0 0


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有