适用范围
linux服务器挂载磁盘
阿里云买的服务器如果有附加数据盘
如果是分区好的
直接
mkdir -pv /data1
mount /dev/vdb1 /data1
然后vi /etc/fstab最后插入一行
/dev/vdb1 /data1 ext4 defaults 0 0
附录相关信息
[root@iZuf65azaofq24ykirelviZ ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 40G 0 disk
└─vda1 253:1 0 40G 0 part /
vdb 253:16 0 200G 0 disk
└─vdb1 253:17 0 200G 0 part
[root@iZuf65azaofq24ykirelviZ ~]# fdisk -l
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: dos
Disk identifier: 0x000c2760
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886046 41941999+ 83 Linux
Disk /dev/vdb: 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: 0x46b7969f
Device Boot Start End Blocks Id System
/dev/vdb1 63 419429807 209714872+ 83 Linux
[root@iZuf65azaofq24ykirelviZ ~]# mount /dev/vdb1 /data1
[root@iZuf65azaofq24ykirelviZ ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 524K 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/vda1 40G 2.2G 36G 6% /
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/vdb1 197G 60M 187G 1% /data1
[root@iZuf65azaofq24ykirelviZ ~]# vim /etc/fstab
如果是没分区好的
分区挂载命令提取
#fdisk -l确认Disk /dev/vdb未分区没有 Device Boot Start End Blocks Id System这一行
fdisk -l
#分区fdisk /dev/vdb 如果只分一个区 依次输入 n 、 p、 1 、 默认起始扇区回车、 默认结束扇区回车、 w
fdisk /dev/vdb
#确认已分区
fdisk -l
#格式化成ext4
mkfs.ext4 /dev/vdb1
#创建目录 挂载
mkdir -pv /gldata1
mount /dev/vdb1 /gldata1
#设置开机挂载
echo "/dev/vdb1 /gldata1 ext4 defaults 0 0" >>/etc/fstab
具体返回
[root@iZuf640n84k63292r8o6x7Z ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.5G 0 7.5G 0% /dev
tmpfs 7.6G 0 7.6G 0% /dev/shm
tmpfs 7.6G 620K 7.6G 1% /run
tmpfs 7.6G 0 7.6G 0% /sys/fs/cgroup
/dev/vda1 40G 4.1G 34G 11% /
tmpfs 1.6G 0 1.6G 0% /run/user/0
[root@iZuf640n84k63292r8o6x7Z ~]# mkdir -pv /gldata1
[root@iZuf640n84k63292r8o6x7Z ~]# mount /dev/vdb1 /gldata1
mount: special device /dev/vdb1 does not exist
[root@iZuf640n84k63292r8o6x7Z ~]# fdisk -l
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: dos
Disk identifier: 0x000c2760
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886046 41941999+ 83 Linux
Disk /dev/vdb: 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
[root@iZuf640n84k63292r8o6x7Z ~]# fdisk /dev/vdb
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 0x0f599be5.
Command (m for help): m
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-419430399, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):
Using default value 419430399
Partition 1 of type Linux and of size 200 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@iZuf640n84k63292r8o6x7Z ~]# fdisk -l
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: dos
Disk identifier: 0x000c2760
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886046 41941999+ 83 Linux
Disk /dev/vdb: 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: 0x0f599be5
Device Boot Start End Blocks Id System
/dev/vdb1 2048 419430399 209714176 83 Linux
[root@iZuf640n84k63292r8o6x7Z ~]# mkfs.ext4 /dev/vdb1
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
13107200 inodes, 52428544 blocks
2621427 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2199912448
1600 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@iZuf640n84k63292r8o6x7Z ~]# ^C
[root@iZuf640n84k63292r8o6x7Z ~]# mkdir -pv /gldata1
[root@iZuf640n84k63292r8o6x7Z ~]# mount /dev/vdb1 /gldata1
[root@iZuf640n84k63292r8o6x7Z ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.5G 0 7.5G 0% /dev
tmpfs 7.6G 0 7.6G 0% /dev/shm
tmpfs 7.6G 624K 7.6G 1% /run
tmpfs 7.6G 0 7.6G 0% /sys/fs/cgroup
/dev/vda1 40G 4.1G 34G 11% /
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/vdb1 197G 61M 187G 1% /gldata1
[root@iZuf640n84k63292r8o6x7Z ~]# echo "/dev/vdb1 /gldata1 ext4 defaults 0 0" >>/etc/fstab
[root@iZuf640n84k63292r8o6x7Z ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Oct 19 03:29:13 2023
#
# 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=43799a01-3b60-49ff-b5d3-8714ae48b386 / ext4 defaults 1 1
/dev/vdb1 /gldata1 ext4 defaults 0 0
未挂载磁盘超过2T
例如我的 /dev/sda 磁盘为8T
lsblk显示还未分区
sda 8:0 0 7.3T 0 disk
[root@192 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 3.7T 0 disk
├─sdb1 8:17 0 500M 0 part /boot
└─sdb2 8:18 0 3.7T 0 part
├─VolGroup-lv_root (dm-0) 253:0 0 850G 0 lvm /
├─VolGroup-lv_swap (dm-1) 253:1 0 15.7G 0 lvm [SWAP]
└─VolGroup-home (dm-2) 253:2 0 2.5T 0 lvm /media
sda 8:0 0 7.3T 0 disk
sr0 11:0 1 1024M 0 rom
[root@192 ~]# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x4fdea8f8.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: The size of this disk is 8.0 TB (8001563222016 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).
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
这段消息是关于磁盘分区表的警告和建议。让我逐一解释:
-
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel:
这意味着系统检测到磁盘上既没有有效的 DOS 分区表,也没有 Sun、SGI 或 OSF 的磁盘标签。这表明磁盘当前没有分区或分区表已损坏。 -
Building a new DOS disklabel with disk identifier 0x4fdea8f8:
系统正在创建一个新的 DOS 分区表,用于重新定义磁盘的分区结构。新的分区表将使用磁盘标识符 0x4fdea8f8。 -
WARNING: invalid flag 0x0000 of partition table 4 will be corrected by w(rite):
系统发现了一个无效的分区标志,即分区表中的标志位被设置为了 0x0000,这可能是一个错误。系统将会在写入新的分区表时对其进行更正。 -
WARNING: The size of this disk is 8.0 TB (8001563222016 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):
这是一个警告,指出磁盘的大小为 8.0 TB,超过了 DOS 分区表格式所支持的最大磁盘容量(2 TB)。因此,建议使用 GUID 分区表格式(GPT)来对这样大的磁盘进行分区。 -
The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted:
这是一个建议,指出磁盘的逻辑扇区大小小于物理扇区大小。建议对分区进行优化,使其与物理扇区大小对齐,以获得更好的性能。
综上所述,您可以使用 GPT 分区表格式来对磁盘进行分区,以适应其大于 2 TB 的容量,并且可以考虑对分区进行优化,以获得更好的性能。
parte创建GPT动态分区
yum install parted
parted /dev/sda
#进入交互模式
#在 parted 的交互模式下,使用 mklabel 命令创建 GPT 分区表:
(parted) mklabel gpt
#如果要分多个盘 (parted) mkpart primary ext4 1MiB 100GiB 设定大小多次执行或者 0 20%
(parted) mkpart primary ext4 0% 100%
(parted) quit
格式化挂载
mkfs.ext4 /dev/sda1
mkdir /8t
echo "/dev/sda1 /8t ext4 defaults 0 0" >>/etc/fstab
mount -a:q
:q
近期评论