[root@localhost media]# rpm -qf `which parted`
parted-3.1-23.el7.x86_64
#查看
[root@localhost ~]# parted -l
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 316MB 315MB primary xfs boot
2 316MB 2464MB 2149MB primary linux-swap(v1)
3 2464MB 107GB 105GB primary xfs
[root@localhost ~]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x000c2f37
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 4812799 2098176 82 Linux swap / Solaris
/dev/sda3 4812800 209715199 102451200 83 Linux
[root@localhost ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: /dev/sdb: unrecognised disk label
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
(parted) mklabel
New disk label type? gpt
(parted) mkpart
Partition name? []? mydisk1
File system type? [ext2]?
Start? 1
End? 100M
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 99.6MB 98.6MB mydisk1
(parted) mkpart
Partition name? []? 2
File system type? [ext2]?
Start? 100M
End? 200M
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 99.6MB 98.6MB mydisk1
2 99.6MB 200MB 101MB 2
(parted) quit
Information: You may need to update /etc/fstab.
[root@localhost ~]# ls /dev/sdb* #查看结果
/dev/sdb /dev/sdb1 /dev/sdb2
[root@localhost ~]# mkfs.ext4 /dev/sdb1 #格式化
#格式化完了正常使用
#删除
[root@localhost ~]# 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, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 99.6MB 98.6MB ext4 mydisk1
2 99.6MB 200MB 101MB 2
(parted) rm 2
(parted) quit
Information: You may need to update /etc/fstab.
[root@localhost ~]# ls /dev/sdb*
/dev/sdb /dev/sdb1
-----------------------------------------------------------------------------------------------
命令 lsof (list open files)
作用 查看哪些命令打开了当前系统哪个文件
语法 lsof 文件系统挂载点
[root@localhost ~]# lsof /opt/ #重点看后三列内容
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
vim 2411 root 3u REG 8,17 12288 13 /opt/test/a.txt.swap
命令 fuser
-m 显示进程ID -v 详细信息 -u 显示执行这个进程的用户名