fdisk -l
[root@E0-9D-31-A3-0B-10 ~]# fdisk -l
磁盘 /dev/sdb:1000.2 GB, 1000204886016 字节,1953525168 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节
磁盘标签类型:dos
磁盘标识符:0x33f12d5c
设备 Boot Start End Blocks Id System
/dev/sdb1 63 1953520064 976760001 f W95 Ext'd (LBA)
Partition 1 does not start on physical sector boundary.
/dev/sdb5 126 1953520064 976759969+ 83 Linux
Partition 5 does not start on physical sector boundary.
也可以通过以下命令查看
lsblk
[root@E0-9D-31-A3-0B-10 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119.2G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 118G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 7.8G 0 lvm [SWAP]
└─centos-home 253:2 0 60.3G 0 lvm /home
sdb 8:16 0 931.5G 0 disk
├─sdb1 8:17 0 1K 0 part
└─sdb5 8:21 0 931.5G 0 part
我需要对sdb这个新加的硬盘进行分区
[root@E0-9D-31-A3-0B-10 ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x491f2ee6 创建新的 DOS 磁盘标签。
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.
命令(输入 m 获取帮助):m
命令操作
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)
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):
起始 扇区 (2048-1953525167,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-1953525167,默认为 1953525167):
将使用默认值 1953525167
分区 1 已设置为 Linux 类型,大小设为 931.5 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@E0-9D-31-A3-0B-10 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119.2G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 118G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 7.8G 0 lvm [SWAP]
└─centos-home 253:2 0 60.3G 0 lvm /home
sdb 8:16 0 931.5G 0 disk
└─sdb1 8:17 0 931.5G 0 part
输入n
选择新增硬盘,输入p
选择primary (0 primary, 0 extended, 4 free)格式,输入w
进行保存
[root@E0-9D-31-A3-0B-10 ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb isize=512 agcount=4, agsize=61047662 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=244190646, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=119233, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
把我的新硬盘/dev/sdb
格式化为xfs文件系统
我需要挂载新硬盘到/data
目录下
[root@E0-9D-31-A3-0B-10 ~]# mkdir /data
[root@E0-9D-31-A3-0B-10 data]# mount /dev/sdb1 /data
[root@E0-9D-31-A3-0B-10 data]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs 3.8G 9.7M 3.8G 1% /run
tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 6.4G 44G 13% /
/dev/sda2 1014M 171M 844M 17% /boot
/dev/sda1 200M 12M 189M 6% /boot/efi
/dev/mapper/centos-home 61G 112M 61G 1% /home
tmpfs 772M 12K 772M 1% /run/user/42
tmpfs 772M 0 772M 0% /run/user/0
/dev/sdb1 932G 33M 932G 1% /data
[root@E0-9D-31-A3-0B-10 data]# blkid
/dev/sda1: SEC_TYPE="msdos" UUID="9979-F891" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="7c133e8e-53c0-43ce-940d-df7a3bc0af0e"
/dev/sda2: UUID="edddff9f-1f07-4b79-88ba-8b12c1a55cb9" TYPE="xfs" PARTUUID="6c69b89f-7578-406d-b633-1f6815b6a045"
/dev/sda3: UUID="7By5vV-aDef-YGgC-GuWT-84hc-knwN-NFv7M3" TYPE="LVM2_member" PARTUUID="2658e75c-e251-4f30-b38a-6ae0a842f202"
/dev/mapper/centos-root: UUID="906ab4d5-d8c5-4e7a-929e-c09d4749e67b" TYPE="xfs"
/dev/mapper/centos-swap: UUID="5a1e7ceb-8a13-435f-ac27-ee282a017e3c" TYPE="swap"
/dev/mapper/centos-home: UUID="8de75882-51b7-4e11-8159-be588911d7f9" TYPE="xfs"
/dev/sdb1: UUID="8cf752cc-9585-43d8-a300-4e127d045a87" TYPE="xfs"
[root@E0-9D-31-A3-0B-10 data]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Nov 12 01:27:53 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/centos-root / xfs defaults 0 0
UUID=edddff9f-1f07-4b79-88ba-8b12c1a55cb9 /boot xfs defaults 0 0
UUID=9979-F891 /boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
[root@E0-9D-31-A3-0B-10 data]# echo "UUID=8cf752cc-9585-43d8-a300-4e127d045a87 /data xfs defaults 0 0" >> /etc/fstab
[root@E0-9D-31-A3-0B-10 data]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Nov 12 01:27:53 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/centos-root / xfs defaults 0 0
UUID=edddff9f-1f07-4b79-88ba-8b12c1a55cb9 /boot xfs defaults 0 0
UUID=9979-F891 /boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
UUID=8cf752cc-9585-43d8-a300-4e127d045a87 /data xfs defaults 0 0
[root@E0-9D-31-A3-0B-10 data]# mount -a
mount -a
立即挂载