挂载存储
- 用df-h命令查看挂接盘,存储盘dev/sda不在列表中
[root@host-10-110-0-84 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 36G 1.5G 35G 5% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 8.0K 16G 1% /dev/shm
tmpfs 16G 17M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/vda1 1014M 143M 872M 15% /boot
/dev/mapper/centos-home 18G 33M 18G 1% /home
tmpfs 3.2G 0 3.2G 0% /run/user/0
- 输入
fdisk -l
找到未挂载的存储,dev/sda
,在列表最后,可以看到有20T
[root@host-10-110-0-84 ~]# fdisk -l
Disk /dev/vda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x0009594b
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 2099199 1048576 83 Linux
/dev/vda2 2099200 125829119 61864960 8e Linux LVM
Disk /dev/mapper/centos-root: 38.2 GB, 38235275264 bytes, 74678272 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/centos-swap: 6442 MB, 6442450944 bytes, 12582912 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/centos-home: 18.7 GB, 18668847104 bytes, 36462592 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: 21990.2 GB, 21990232555520 bytes, 42949672960 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4210688 bytes / 1048576 bytes
- 输入
fdisk /dev/vdb
命令进行分区
依次输入n、p、1、回车键、回车键、w
,如下所示:
参数解释:
m:可以查看可以用哪些参数,
n:是划分一块新的盘符,p是主分区/e是扩展分区,一块硬盘最多可以有3个主分区,我们这是第一次划分分区,所以选p;
1:第一个分区
w:写入磁盘
[root@host-10-110-0-84 ~]# fdisk /dev/sda
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 0xe9610501.
WARNING: The size of this disk is 22.0 TB (21990232555520 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).
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-4294967295, default 4096):
Using default value 4096
Last sector, +sectors or +size{K,M,G} (4096-4294967294, default 4294967294):
Using default value 4294967294
Partition 1 of type Linux and of size 2 TiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
- 使用命令
mkfs -t ext4 /dev/sda
进行格式化分区:
[root@host-10-110-0-84 ~]# mkfs -t ext4 /dev/sda
mke2fs 1.42.9 (28-Dec-2013)
/dev/sda is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=4 blocks, Stripe width=256 blocks
335544320 inodes, 5368709120 blocks
268435456 blocks (5.00%) reserved for the super user
First data block=0
163840 block groups
32768 blocks per group, 32768 fragments per group
2048 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, 512000000, 550731776, 644972544, 1934917632,
2560000000, 3855122432
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
- 新建挂载路径,并挂载
[root@host-10-110-0-84 ~]# mkdir /starsino --新建挂载点
[root@host-10-110-0-84 ~]# mount /dev/sda /starsino --挂载命令
[root@host-10-110-0-84 ~]#chmod -R 777 /starsino --赋予文件目录可操作权限
df -h
命令查看挂载结果,存储dev/sda
已挂载,路径为/starsino
[root@host-10-110-0-84 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 36G 1.5G 35G 5% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 8.0K 16G 1% /dev/shm
tmpfs 16G 17M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/vda1 1014M 143M 872M 15% /boot
/dev/mapper/centos-home 18G 33M 18G 1% /home
tmpfs 3.2G 0 3.2G 0% /run/user/0
/dev/sda 20T 20K 19T 1% /starsino
- 配置开机自动挂载,需要在文件
/etc/fstab
中加入配置
- 使用
blkid
命令 查看dev/sda
的uuid
[root@host-10-110-0-84 ~]# blkid
/dev/vda1: UUID="43d4c2b4-185f-4586-aeb7-1db762ee1b5c" TYPE="xfs"
/dev/vda2: UUID="X0YHZ0-de91-VEms-KKV9-6ho7-HdWp-HngyTA" TYPE="LVM2_member"
/dev/mapper/centos-root: UUID="81d12ba2-3e28-4a2c-8b60-5ef6728fa206" TYPE="xfs"
/dev/mapper/centos-swap: UUID="8b31cdb5-96ac-46e8-95d2-8ec1db9ddb89" TYPE="swap"
/dev/mapper/centos-home: UUID="020bfcbe-e33e-4cbe-82bb-92d4232e916f" TYPE="xfs"
/dev/sda: UUID="2678abcb-638c-4019-99c4-57712e5ebdf3" TYPE="ext4"
- 在
/etc/fstab
文件的最后加入一段
UUID=2678abcb-638c-4019-99c4-57712e5ebdf3 /data ext4 defaults 0 1
reboot
重启服务器,验证自动识别存储
[root@host-10-110-0-84 ~]# reboot
[USM] Connection closed by foreign host '数字档案室系统-应用服务器-1_10.110.0.84:22'
Connection closed.
Disconnected from remote host(10.110.0.84:22) at 16:45:59.
Type `help' to learn how to use Xshell prompt.
[C:\~]$
Connecting to 221.2.222.214:50022...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
connecting 数字档案室系统-应用服务器-1_10.110.0.84:22 ...
Last login: Tue Aug 9 04:43:31 2022 from 10.10.3.239
[root@host-10-110-0-84 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 36G 1.5G 35G 5% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 8.0K 16G 1% /dev/shm
tmpfs 16G 8.4M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/vda1 1014M 143M 872M 15% /boot
/dev/sda 20T 6.2G 19T 1% /starsino
/dev/mapper/centos-home 18G 33M 18G 1% /home
tmpfs 3.2G 0 3.2G 0% /run/user/0
相关命令
输入mount -a
命令,可以刷新该配置记录;
输入umount /dev/sda
命令,可以卸掉磁盘(即去掉挂载信息);
提示input/output error
损坏;
输入fsck -t ext4 -y /dev/sda
修复硬盘,需要先卸载,修复完,再挂载。