https://blog.csdn.net/weixin_41607523/article/details/131470538?spm=1001.2014.3001.5501
上次文章叙述了对于一块新挂的磁盘进行分区挂载,但其中有一个特殊情况,就是当新挂的磁盘大于2T的时候只有GPT才支持大于2T的分区
[root@XXJSB-NHRCS-05 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 512M 0 part /boot
└─sda2 8:2 0 199.5G 0 part
├─rhel-root 253:0 0 192G 0 lvm /
└─rhel-swap 253:1 0 7.5G 0 lvm [SWAP]
sdb 8:16 0 4T 0 disk
sr0 11:0 1 1024M 0 rom
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# 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 0x61964bf9.
WARNING: The size of this disk is 4.4 TB (4398046511104 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): 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):
First sector (2048-4294967295, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-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.
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 512M 0 part /boot
└─sda2 8:2 0 199.5G 0 part
├─rhel-root 253:0 0 192G 0 lvm /
└─rhel-swap 253:1 0 7.5G 0 lvm [SWAP]
sdb 8:16 0 4T 0 disk
└─sdb1 8:17 0 2T 0 part
sr0 11:0 1 1024M 0 rom
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 1 2 0 wz--n- <199.50g 0
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
如上所示,使用fdisk命令分区完成后,sdb1只有2T大小,不满足我们分区要求。
[root@XXJSB-NHRCS-05 ~]# fdisk /dev/sdb
WARNING: The size of this disk is 4.4 TB (4398046511104 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).
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.
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): d
Selected partition 1
Partition 1 is deleted
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 512M 0 part /boot
└─sda2 8:2 0 199.5G 0 part
├─rhel-root 253:0 0 192G 0 lvm /
└─rhel-swap 253:1 0 7.5G 0 lvm [SWAP]
sdb 8:16 0 4T 0 disk
sr0 11:0 1 1024M 0 rom
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 4398GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
(parted)
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted)
(parted)
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 4398GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted)
(parted)
(parted) mkpart primary 0% 100%
(parted)
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 4398GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 4398GB 4398GB primary
(parted) q
Information: You may need to update /etc/fstab.
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 512M 0 part /boot
└─sda2 8:2 0 199.5G 0 part
├─rhel-root 253:0 0 192G 0 lvm /
└─rhel-swap 253:1 0 7.5G 0 lvm [SWAP]
sdb 8:16 0 4T 0 disk
└─sdb1 8:17 0 4T 0 part
sr0 11:0 1 1024M 0 rom
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# mkfs.ext4 -T largefile /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
4194304 inodes, 1073741312 blocks
53687065 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3221225472
32768 block groups
32768 blocks per group, 32768 fragments per group
128 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# mkdir /u01
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# mount /dev/sdb1 /u01/
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 32G 0 32G 0% /dev
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 32G 13M 32G 1% /run
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/rhel-root 192G 5.8G 187G 3% /
/dev/sda1 509M 164M 346M 33% /boot
tmpfs 6.3G 24K 6.3G 1% /run/user/0
/dev/sdb1 4.0T 89M 3.8T 1% /u01
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Jun 27 20:33:57 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
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=5ae9a26f-dcc5-4463-85cd-1b4e90ef2313 /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]#
[root@XXJSB-NHRCS-05 ~]# vi /etc/fstab