您是系统管理员吗,那么您应该了解这些工具来管理磁盘空间。本文介绍了有关如何在Linux中检查Linux磁盘分区和使用情况的信息。
Fdisk是基于文本的实用程序。通过使用fdisk,您可以创建一个全新的分区,删除当前分区或交换现有分区。
要获取有关fdisk的更多信息,请使用以下命令–
$ fdisk
样本应该是这样的–
Usage: fdisk [options] change partition table fdisk [options] -l [] list partition table(s) Display or manipulate a disk partition table. Options: -b, --sector-size physical and logical sector size -B, --protect-boot don't erase bootbits when create a new label -c, --compatibility[=] mode is 'dos' or 'nondos' (default) -L, --color[=] colorize output (auto, always or colors are enabled by default -l, --list display partitions end exit -o, --output output columns -t, --type recognize specified partition table type only -u, --units[=] display units: 'cylinders' or 'sectors' (default) -s, --getsz display device size in 512-byte sectors [DEPRECATED] --bytes print SIZE in bytes rather than in human readable format -C, --cylinders specify the number of cylinders -H, --heads specify the number of heads -S, --sectors specify the number of sectors per track -h, --help display this help and exit -V, --version output version information and exit Available columns (for -o): gpt: Device Start End Sectors Size Type Type-UUID Attrs Name UUID dos: Device Start End Sectors Cylinders Size Type Id Attrs Boot End-C/H/S Start-C/H/S bsd: Slice Start End Sectors Cylinders Size Type Bsize Cpg Fsize sgi: Device Start End Sectors Cylinders Size Type Id Attrs sun: Device Start End Sectors Cylinders Size Type Id Flags ..........................................................................................
要获取设备列表,请使用以下命令–
$ sudo fdisk -l
样本输出应如下所示–
Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram1: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram2: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes
sfdisk是基于脚本的工具,用于显示或操作磁盘分区表。
要获取有关sfdisk的更多信息,请使用以下命令–
$ man sfdisk
样本输出应如下所示–
SFDISK(8) System Administration SFDISK(8) NAME sfdisk - display or manipulate a disk partition table SYNOPSIS sfdisk [options] device [-N partition-number] sfdisk [options] command DESCRIPTION sfdisk is a script-oriented tool for partitioning any block device. Since version 2.26 sfdisk supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any tionality for CHS (Cylinder-Head-Sector) addressing. CHS has never been important for Linux, and this addressing concept does not make any sense for new devices. sfdisk (since version 2.26) aligns the start and end of partitions to block-device I/O limits when relative sizes are specified, or when the default values are used. sfdisk does not create the standard system partitions for SGI and SUN disk labels like fdisk(8) does. It necessary to explicitly create all partitions including whole-disk system partitions. ........................................................................................
要获取设备列表,请使用以下命令–
$ sfdisk -l
样本输出应如下所示–
Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram1: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram2: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes
lsblk提供有关所有或特定块设备的信息。要获取有关lsblk的更多信息,请使用以下命令–
$ man lsblk
样本输出应如下所示–
LSBLK(8) System Administration LSBLK(8) NAME lsblk - list block devices SYNOPSIS lsblk [options] [device...] DESCRIPTION lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information. The command prints all block devices (except RAM disks) in a tree-like format by default. Use lsblk --help to get a list of all available columns. The default output, as well as the default output from options like --fs and --topology, is subject to change. So whenever pos‐sible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using --output col‐umns-list in environments where a stable output is required. Note that lsblk might be executed in time when udev does not have all information about recently added or modified devices yet. In this case it is recommended to use udevadm settle before lsblk to synchronize with udev. .................................................................................................
要获取设备列表,请使用以下命令–
$ lsblk
样本输出应如下所示–
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 462.3G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 3.4G 0 part [SWAP] sr0 11:0 1 1024M 0 rom
它提供有关当前连接到系统的SCSI设备(或主机)列表的信息。要获取有关lsscsi的更多信息,请使用以下命令–
$ man lsscsi
样本输出应如下所示–
NAME lsscsi - list SCSI devices (or hosts) and their attributes SYNOPSIS lsscsi [--classic] [--device] [--generic] [--help] [--hosts] [--kname] [--list] [--lunhex] [--long] [-- protection] [--protmode] [--scsi_id] [--size] [--sysfsroot=PATH] [--transport] [--verbose] [--version] [--wwn] [H:C:T:L] DESCRIPTION Uses information in sysfs (Linux kernel series 2.6 and later) to list SCSI devices (or hosts) currently attached to the system.Options can be used to control the amount and form of information provided for each device. If a H:C:T:L argument is given then it acts as a filter and only devices that match it are listed. The colons don't have to be present, and '-', '*', '?' or missing arguments at the end are interpreted as wildcards. The default is '*:*:*:*' which means to match everything. Any filter string using '*' of '?' should be surrounded by single or double quotes to stop shell expansions. If '-' is used as a wildcard then the whole filter argument should be prefixed by '-- ' to tell this utility there are no more options on the command line to be interpreted. A leading '[' and trailing ']' are permitted (e.g. '[1:0:0]' matches all LUNs on 1:0:0). May also be used to filter --hosts in which case only the H is active and may be either a number or in the form "host" where is a host number. ............................................................................................
要获取当前连接的SCSI设备(或主机)的列表,请使用以下命令-
$ lsscsi
样本输出应如下所示–
[0:0:0:0] disk ATA WDC WD5000LPVX-7 1A01 /dev/sda [1:0:0:0] cd/dvd TSSTcorp DVD+-RW SU-208FB D200 /dev/sr0
在本文中,我们学习了一些非常有用的工具-“检查Linux磁盘分区和Linux中的使用情况”。在我们的下一篇文章中,我们将提出更多基于Linux的技巧。继续阅读!
我们已经知道 Linux 系统分区的设备文件名的命名是有严格规范的,类似于 /dev/sda1 代表第一块 SCSI 硬盘的第一个主分区。但是在 GRUB 中分区的表示方法却完全不同,采用了类似 hd(0,0) 的方式来表示分区。 其实也很好理解,其中: hd 代表硬盘,不再区分是 SCSI 接口硬盘,还是 IDE 接口硬盘,都用 hd 代表; 第一个 0 代表 Linux 系统查找到的第一块硬盘
本文向大家介绍Linux中在不破坏磁盘的情况下使用dd命令,包括了Linux中在不破坏磁盘的情况下使用dd命令的使用技巧和注意事项,需要的朋友参考一下 无论你试图从即将坏掉的存储驱动器抢救数据,将归档备份到远程存储,还是在别处对活动分区制作一份完美副本,都要知道如何安全可靠地复制驱动器和文件系统。幸好,有dd这款简单而强大的镜像复制工具,而且历史悠久。在这方面没有比它更出色的工具了。 dd命令的解
cPanel磁盘使用情况是监控可用帐户和使用磁盘空间的一种非常有效的方法。 此功能会扫描磁盘,为您提供磁盘使用情况的图形概览。 它显示目录使用的磁盘空间,但不显示单个文件占用的空间。 它还显示MySQL数据库,隐藏目录和电子邮件使用的磁盘配额信息。 它有助于管理磁盘配额,因为一旦知道哪个目录具有最大的文件,就可以使用文件管理器导航到该目录并删除不必要的文件。 要访问此功能,请单击cPanel的“文
【查看磁盘或者目录的容量 df 和 du】 df 查看已挂载磁盘的总容量、使用容量、剩余容量等,可以不加任何参数,默认是按k为单位显示的 df常用参数有 –i -h -k –m等 -i 使用inodes 显示结果 -h 使用合适的单位显示,例如G -k -m 分别为使用K,M为单位显示 简单介绍一下,你看到的相关数据。Filesystem 表示扇区,也就是你划分磁盘时所分的区;1K-blocks/
主要内容:quota 命令查询用户或用户组配额,repquota命令查询文件系统配额对于建立好的磁盘配额,还需要有效的查询配额的手段,这样才能知道系统中到底有哪些分区设定了哪些配额。 查询磁盘配额有两种方法: 使用 quota 命令查询用户或用户组的配额; 使用 repquota 命令查询整个分区的配额情况。 quota 命令查询用户或用户组配额 [root@localhost~] # quota [选项] [用户名或组名] 选项: -u 用户名:查询用户配额; -g 组名:查询
问题内容: 我可以看到Docker占用了12GB的文件系统: 但是,我怎么知道它如何分布在容器上? 我试图通过运行附加到容器(新的v1.3命令) 然后运行“ df -h”以分析磁盘使用情况。它似乎正在工作,但不适用于使用“ volumes-from”的容器。 例如,我为MongoDB使用了仅数据容器,称为“ mongo-data”。 当我运行,然后在容器中运行时,它表示安装在(我的“ mongo-