linux系统中的磁盘管理

本文详细介绍了Linux系统中的磁盘管理,包括查看本地存储设备、设备挂载与卸载、磁盘分区、分区步骤、文件系统安装、swap分区管理和配额设置。通过示例演示了如何操作和配置这些功能。
摘要由CSDN通过智能技术生成

linux系统中的磁盘管理

看到的不一定可以使用
可以被用,不一定在用

1.本地存储的设备

fdisk -l #真实存在的设备
在这里插入图片描述
cat /proc/partitions #系统识别的设备
在这里插入图片描述
blkid #系统可使用的设备
在这里插入图片描述
df #系统正在挂载的设备
在这里插入图片描述

2.设备的挂载与卸载

1).设备名称
/dev/xdx #/dev/hd0 /dev/hd1 /dev/sda /dev/sda1 /dev/sdb /dev/sdb1
/dev/sr0 #光驱
/dev/mapper/*虚拟设备
2).设备的挂载

mount    设备     挂载点
mount  /dev/sdb1   /mnt

将/dev/sdb1挂载到 /mnt下,用df查看是否已经挂载成功:
在这里插入图片描述
正常卸载:
在这里插入图片描述

有时候会出现busy情况,无法正常将挂载点卸载

3).解决设备正忙情况
解决方法1:

[root@foundation14 mnt]# umount /mnt
umount: /mnt: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@foundation14 mnt]# fuser -kvm /mnt
                     USER        PID ACCESS COMMAND
/mnt:                root     kernel mount /run/media/kiosk/KINGSTON
                     root       3024 ..c.. bash
                     kiosk      4388 ..c.. bash
                     root       4475 ..c.. bash
Killed
Killed
Killed
[root@foundation14 mnt]# umount /mnt

在这里插入图片描述

解决方法2:

[root@foundation14 mnt]# umount /mnt
[root@foundation14 mnt]# lsof /mnt/
lsof:WARNING:information may be incomplate。
COMMAND    PID USER  FD TYPE DEVICE SIZE/OFF NODE NAME
bash        4626   root  cwd DIR  8,17   4096     2   /mnt

[root@foundation14 mnt]# kill -9 4626
[root@foundation14 mnt]# umount /mnt

在这里插入图片描述

3.磁盘分区

1.硬盘0磁道1扇区的512个字节中记录的信息如下

512=446        +            64         +                2
       ^                     ^                          ^
     mbr(主引导记录)          mpt(主分区标)              55aa(硬盘的有效标示)

硬盘分区标
64
一个分区占16个字节
硬盘上最多可以划分4个主分区

4.分区步骤

1).查看真实存在的设备

[root@server-sshd ~]# fdisk -l

Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 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: 0x00013f3e

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    20970332    10484142+  83  Linux

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 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: 0x45d1ee73

   Device Boot      Start         End      Blocks   Id  System

2).分区的管理

[root@server-sshd ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

在这里插入图片描述

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   add a 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   #修改分区id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit      #保存分区标信息到硬盘
   x   extra functionality (experts only)

在这里插入图片描述
3).查看分区信息
在这里插入图片描述
4).新建分区
在这里插入图片描述

在这里插入图片描述
建立三个分区
在这里插入图片描述

5).如果已经建立了三个分区,那么新建第四个分区将会默认为扩展分区
在这里插入图片描述
6).这时就可以在扩展分区里再建立分区,只要分区的存储足够大

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值