linux uuid挂载磁盘_磁盘挂载,磁盘格式化,获取磁盘挂载的UUID,光驱挂载与卸载...

主分区加扩展分区最多4个

逻辑分区任意多个

fdisk -l

列出系统中所有的可用设备,及使用状况

#start 格式化操作

fdisk /dev/sda

#命令选项

-a 制定启动分区 -m 帮助菜单 -n 添加新的分区 -d 删除分区

-p 打印分区表 -q 退出不保存 -w 保持并退出

磁盘管理步骤:

添加设备  分区  格式化(创建文件系统)  创建挂载点   挂载    修改配置文件

[root@localhost ~]#fdisk -l                                  #查看设备使用状况

[root@localhost ~]#fdisk /dev/sda

Command (m for help): m

Command action

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   adda 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)

Command (m for help): n#创建一个新的分区

Partition type:

p  primary (2 primary, 0 extended, 2 free)                           #创建一个主分区

e  extended                                                                  #创建一个扩展分区

Select (default p): e

Partition number (3,4,default 3):                                        #指定分区号

First sector(26208256-41943039, default 26208256):            #指定开始柱面,默认回车就可以

Using default value26208256

Last sector, +sectorsor +size{K,M,G} (26208256-41943039, default 41943039): +5G         #指定结束柱面,默认不指定的话是把剩下的所有空间分配给分区,等于说指定分区大小

Partition 3 of typeExtended and of size 5 GiB is set

Command (m for help): p#打印分区表

Disk /dev/sda: 21.5 GB,21474836480 bytes, 41943040 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:0x000a705c

Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *       2048     1026047      512000  83  Linux

/dev/sda2         1026048    26208255   12591104   8e  Linux LVM

/dev/sda3        26208256    36694015    5242880    5 Extended      #表明是扩展 分区

Command (m for help): n

Partition type:

p  primary (2 primary, 1 extended, 1 free)

l  logical (numbered from 5)                                               #创建一个逻辑分区

Select (default p): l

Adding logicalpartition 5

First sector(26210304-36694015, default 26210304):

Using default value26210304

Last sector, +sectorsor +size{K,M,G} (26210304-36694015, default 36694015): +1G

Partition 5 of typeLinux and of size 1 GiB is set

Command (m for help): p

Disk /dev/sda: 21.5 GB,21474836480 bytes, 41943040 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:0x000a705c

Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *       2048     1026047      512000  83  Linux

/dev/sda2         1026048    26208255   12591104   8e  Linux LVM

/dev/sda3        26208256    36694015    5242880    5  Extended

/dev/sda5        26210304    28307455    1048576   83  Linux

#逻辑分区的分区号从5开始,不管之前有没有第四或者第三个分区

Command (m for help): w                                            #保存

The partition table hasbeen altered!

Calling ioctl() tore-read partition table.

WARNING: Re-reading thepartition table failed with error 16: Device or resource busy.

The kernelstill uses the old table. The new table will be used at            #提示重新读取分区表

the nextreboot or after you run partprobe(8) or kpartx(8)

Syncingdisks.

[root@localhost ~]# ls /dev/sda*

/dev/sda  /dev/sda1 /dev/sda2

重新获取分区表

[root@localhost ~]#partprobe /dev/sda

[root@localhost ~]# ls /dev/sda*

/dev/sda  /dev/sda1 /dev/sda2  /dev/sda3  /dev/sda5

注:如果是RHEL6操作系统的话,使用partx  -a /dev/sda 重新获取分区表

格式化:

#mkfs.ext3 /dev/sdb1或mkfs -t ext3 /dev/sdb1                        #RHEL5 格式化

#mkfs.ext4 /dev/sdb1或mkfs -t ext4 /dev/sdb1                         #RHEL6 格式化

mkfs.xfs  /dev/sda5或mkfs -t xfs /dev/sda5                          #RHEL7 格式化

#end 格式化操作

RHEL7

blkid

获取磁盘挂载的UUID

RHEL6

tune2fs -l /dev/sda5 | grep UUID

获取磁盘挂载的UUID

mount -t xfs /dev/sda5 /sda5/

-t 挂载时指定文件类型

mount -o loop rhel-server-7.1-x86_64-dvd /media/

挂载光盘镜像文件

mount -o remount,ro  /sda5/

以只读方式重新挂载,设备已经挂载才能重新挂载

vim /etc/fstab

编辑配置文件

mount -a

重读配置文件

umount /dev/sda5

当卸载提示设备正忙时

lsof /dev/sda5      #找到占用设备的进程

使用lsof找到当前使用该设备的进程号

kill -9 PID

使用kill关闭进程号为PID(3967)的进程

fuser -m -u -v /sda5/  #fuser 同样可以找到占用设备的进程

-m 显示进程ID -u 显示执行该进程的用户名 -v 显示详细信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值