[root@localhost ~]# parted 硬盘设备文件名
#之后就会进入交互模式
例如:
[root@localhost ~]# parted /dev/sda
[root@a1 ~]# parted /dev/sda
GNU Parted 3.1
使用 /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) #进入了交互模式,需要输入交互命令
常见了创建分区挂载的步骤:
[root@184-8 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 893.8G 0 disk
├─sda1 8:1 0 512M 0 part /boot
├─sda2 8:2 0 65G 0 part /
├─sda3 8:3 0 8G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 820.3G 0 part /home
sdb 8:16 0 1.8T 0 disk
[root@184-8 ~]# echo -e "mklabel gpt\nmkpart primary 1 100%\nquit\n" | parted /dev/sdb
#注释:————————————————————————————————
这段命令前面的echo是作为输入的,也就是在输入parted命令后和系统进行交互的命令,中间有换行符,作为交互命令输入是这样的
mklabel gpt #创建一个新的磁盘卷标gpt
mkpart primary 1 100% #创建一个分区,容量给100%,默认是创建1
quit #退出
————————————————————————————————————
[root@184-8 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 893.8G 0 disk
├─sda1 8:1 0 512M 0 part /boot
├─sda2 8:2 0 65G 0 part /
├─sda3 8:3 0 8G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 820.3G 0 part /home
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part
[root@184-8 ~]# mkfs.ext4 /dev/sdb1
[root@184-8 ~]# mount /dev/sdb1 /disk1/
[root@184-8 ~]# blkid
/dev/sda1: UUID="46e19b44-67ee-4aa5-9251-540bfe66a280" TYPE="xfs"
/dev/sda2: UUID="b7c41386-7cba-43ce-bac5-c2a65f9026fd" TYPE="xfs"
/dev/sda3: UUID="86df7f15-8813-4e5b-be2b-6f4493a34f03" TYPE="swap"
/dev/sda5: UUID="473fb6a5-bf51-4027-b099-48c39e7fd549" TYPE="xfs"
/dev/sdb1: UUID="01c8de08-059f-414a-b005-d8700eb67084" TYPE="ext4" PARTLABEL="primary" PARTUUID="db1d94c5-6f5c-442b-8c87-c892fb194ae8"
[root@184-8 ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Jan 10 07:05:59 2022
#
# 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=b7c41386-7cba-43ce-bac5-c2a65f9026fd / xfs defaults 0 0
UUID=46e19b44-67ee-4aa5-9251-540bfe66a280 /boot xfs defaults 0 0
UUID=86df7f15-8813-4e5b-be2b-6f4493a34f03 swap swap pri=0,defaults 0 0
UUID=473fb6a5-bf51-4027-b099-48c39e7fd549 /home xfs defaults,noatime,nobarrier 0 0
UUID=01c8de08-059f-414a-b005-d8700eb67084 /disk1 xfs defaults 0 0 #添加
#保存退出
[root@184-8 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 16G 0 16G 0% /dev
tmpfs tmpfs 16G 0 16G 0% /dev/shm
tmpfs tmpfs 16G 25M 16G 1% /run
tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda2 xfs 65G 2.3G 63G 4% /
/dev/sda1 xfs 506M 136M 371M 27% /boot
/dev/sda5 xfs 820G 560M 820G 1% /home
tmpfs tmpfs 3.2G 0 3.2G 0% /run/user/0
/dev/sdb1 ext4 1.8T 77M 1.7T 1% /disk1