Linux:开机硬盘自动挂载
查看Linux硬盘信息
只显示已挂载的磁盘
[root@ambari01 ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: gpt
Disk identifier: FA5D4CB9-C419-4DBE-AFBE-BFC942811628# Start End Size Type Name
1 2048 2099199 1G EFI System EFI System Partition
2 2099200 83884031 39G Microsoft basicDisk /dev/vdb: 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 label type: dos
Disk identifier: 0x56cdb75bDevice Boot Start End Blocks Id System
/dev/vdb1 2048 1048578047 524288000 83 Linux
/dev/vdb2 1048578048 2097154047 524288000 83 LinuxDisk /dev/vdc: 42.9 GB, 42949672960 bytes, 83886080 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
查看磁盘分区UUID
[root@ambari01 ~]# blkid
/dev/vda1: UUID=”23B4-3A70″ TYPE=”vfat” PARTLABEL=”EFI System Partition” PARTUUID=”efac7f8d-85b1-48c1-babb-1bea174dbfce”
/dev/vda2: UUID=”ff97999c-00a4-4eeb-857c-90aac853140d” TYPE=”ext4″ PARTUUID=”033f0e3e-db0e-4d0a-8f98-ec8307912a5d”
/dev/vdb1: UUID=”1965a889-a9f4-4314-8f24-61049f63c14b” TYPE=”xfs”
/dev/vdb2: UUID=”7b0e65bc-4597-4ca1-b7db-b19f11c932a9″ TYPE=”ext2″
/dev/vdc: UUID=”13b2377e-13a4-464d-a854-9f55cc41a116″ TYPE=”ext4″
配置开机硬盘自动挂载
mount命令在服务器重启后会失效,所以需要将分区信息写入/etc/fstab,实现永久挂载:
[root@ambari01 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu May 30 16:20:17 2019
#
# 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
#
UUID=ff97999c-00a4-4eeb-857c-90aac853140d / ext4 defaults 1 1
UUID=23B4-3A70 /boot/efi vfat umask=0077,shortname=winnt 0 0
UUID=13b2377e-13a4-464d-a854-9f55cc41a116 /obs ext4 defaults 0 1
在末尾添加:
UUID=13b2377e-13a4-464d-a854-9f55cc41a116 /obs ext4 defaults 0 1
参数说明:
[fs spec] [fs file] [fs vfstype] [fs mntops] [fs freq [fs passno]
具体说明,以挂载/dev/sdb1为例:
[fs spec]:分区定位,可以给UUID或LABEL,例如:UUID=6E9ADAC29ADA85CD或LABEL=software
[fs file]:具体挂载点的位置,例如:/data
[ fs vfstype]:挂载磁盘类型,linux分区一般为ext4,windows分区一般为ntfs
[fs mntops]:挂载参数,一般为defaults
[fs freq]:磁盘检查,默认为0
[fs passno]:磁盘检查,默认为0,不需要检查
验证
修改完成后,运行下述指令检查配置是否正确(配置失败将会导致系统无法正常启动):
mount -a