教下我&叫下我

教下我&叫下我

我不会,教下我 有福利,叫下我 致终身学习者! https://jiaoxiawo.com
tg_channel
twitter

Common Linux Hard Disk Operation Commands

df -l command to view disk#

  1. The system disk is like the C drive in Windows. In Linux, it usually has a partition called "a". You can use df -l to view it.
    image
    You can see that the root path "/" is located on the system disk. And /root, /home, /usr are like directories under the C drive, such as c:\windows, c:\usr.

  2. If there is a separate data disk and the data disk is not partitioned or mounted, you cannot see it using the df -l command.

fdisk -l command to view disk#

Using fdisk -l, you can see which disks are available.
image

Disk /dev/vda and Disk /dev/vdb represent two disks.
/dev/vda - System disk (built-in disk), with a partition vda1 (usually the first disk is the system disk)
/dev/vdb - Data disk (usually a virtual disk), with two partitions vdb1, vdb2

lsblk command to view disk#

In the image, sda is the system disk, and sdb is the mounted data disk.
image

du -h command to check disk usage of a specific directory#

Command: du [options] /directory (check the disk usage of a specific directory, default is the current directory)

Options Meaning
-s Summarize the sizes of directories
-h Human-readable format
-a Include files
--max-depth=1 Depth of subdirectories
-c List the details and add a total value

Options can be used in combination

Example: Check the disk usage of the /opt directory, with a depth of 1
image

  1. Use the lsblk command to check if there is sdb
    image
  2. Virtual machine disk partition

fdisk /dev/sdb partition command#

Start partitioning sdb

m Display command list

p Display disk partition same as fdisk -l

n Create a new partition

d Delete a partition

w Write and exit

Note: After starting the partition, enter n to create a new partition, then select p for the partition type as primary partition. Press Enter twice to use the remaining space by default, and finally enter w to write the partition and exit. If you don't want to save and exit, enter q.

image

mkfs -t ext4 /dev/sdb1 partition formatting command#

image

mount command for mounting#

For example, mount the disk to the newdisk directory under the root directory
Mounting via command line (mount /dev...), it will be ineffective after restarting, meaning the mount point will disappear after restarting
image

Modify /etc/fstab to achieve permanent mounting#

[root@kongchao03 /]# vim /etc/fstab 
[root@kongchao03 /]# mount -a

image
After adding, execute mount -a or reboot to take effect

umount command to unmount#

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.