parted 磁盘分区工具 (随带lsof fuser)

parted 磁盘分区工具


[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 显示执行这个进程的用户名


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值