标签:one 两种 back rop filesyste 方法 管理磁盘 run 挂载分区
parted DEVICES_NAME
即可。CentOS 7.5
parted命令后跟上欲操作磁盘的名字即可选择此设备进行操作。
[root@kvm ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
因为parted命令只能针对gpt格式的磁盘进行操作,所以这里必须将新建的磁盘标签格式设为gpt。
(parted) mklabel gpt
mkpart PART-TYPE [FS-TYPE] START END
(parted) mkpart primary 0 -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) p
Model: AVAGO AVAGO (scsi)
Disk /dev/sdb: 18.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 18.0TB 18.0TB primary
(parted) q
Information: You may need to update /etc/fstab.
因为整个/dev/sdb只分了一个区,则这个分区名默认会分配为/dev/sdb1;使用mkfs命令将/dev/sdb1分区格式化为ext4。
[root@kvm ~]# mkfs -t ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdb1 alignment is offset by 244736 bytes.
This may result in very poor performance, (re)-partitioning suggested.
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=64 blocks, Stripe width=64 blocks
274659328 inodes, 4394530311 blocks
219726515 blocks (5.00%) reserved for the super user
First data block=0
134111 block groups
32768 blocks per group, 32768 fragments per group
2048 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, 1934917632,
2560000000, 3855122432
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@kvm ~]# e2label /dev/sdb1 /gfsdata01
[root@kvm ~]# mkdir /gfsdata01
[root@kvm ~]# mount /dev/sdb1 /gfsdata01
[root@kvm ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/root_vg-lv_root 89G 2.6G 82G 4% /
devtmpfs 126G 0 126G 0% /dev
tmpfs 126G 0 126G 0% /dev/shm
tmpfs 126G 2.0M 126G 1% /run
tmpfs 126G 0 126G 0% /sys/fs/cgroup
/dev/sda1 976M 216M 694M 24% /boot
/dev/sda7 99G 61M 94G 1% /home
/dev/sda8 62G 53M 59G 1% /tmp
/dev/sda6 99G 61M 94G 1% /app
tmpfs 26G 0 26G 0% /run/user/1014
tmpfs 26G 0 26G 0% /run/user/0
/dev/sdb1 17T 20K 16T 1% /gfsdata01
即修改/etc/fstab文件。
echo '/dev/sdb1 /gfsdata01 ext4 defaults 0 0' >>/etc/fstab
适用于需要在多台主机上进行同样的分区操作,可以通过ansible工具调用脚本实现批量分区配置挂载等操作。
[root@kvm ~]# cat ./auto_partition.sh
#!/bin/bash
# 新建/dev/sdb的磁盘标签类型为GPT
parted /dev/sdb mklabel gpt
# 将/dev/sdb整个空间分给同一个分区
parted /dev/sdb mkpart primary 0 -1
# 格式化分区
mkfs -t ext4 /dev/sdb1
# 设定分区label(非必要)
e2label /dev/sdb1 /gfsdata01
# 创建挂载目录
mkdir /gfsdata01
# 临时挂载
mount /dev/sdb1 /gfsdata01
# 开机自动挂载(永久挂载)
echo '/dev/sdb1 /gfsdata01 ext4 defaults 0 0'>>/etc/fstab
[root@kvm ~]#
rm NUMBER:NUMBER即为parted子命令p回显的Number对应的数字;
此命令慎用!!!如果要删除的分区内已有数据,那么此命令会删除其中的所有数据,并且是不可逆的。
(parted) p
Model: AVAGO AVAGO (scsi)
Disk /dev/sdb: 18.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 4096GB 4096GB primary
(parted) rm 1
(parted) p
Model: AVAGO AVAGO (scsi)
Disk /dev/sdb: 18.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted)
标签:one 两种 back rop filesyste 方法 管理磁盘 run 挂载分区
原文地址:https://www.cnblogs.com/wholj/p/10924129.html