[Linux] Linux practical operation --- disk partitioning and mounting


(1) Basic knowledge of partition

① The way of partition

Insert picture description here


② Disk partition under windows

Insert picture description here


(2) Linux partition

① Principle introduction

Insert picture description here
Insert picture description here


② Hard disk description

Insert picture description here


③ View the mounting status of all devices

Insert picture description here


指令:lsblk -f

Insert picture description here


指令:lsblk

Insert picture description here


(3) Classic case of mounting

① Description

Insert picture description here


② How to add a hard disk

Insert picture description here


③ Step 1 of adding hard disk to virtual machine (add hard disk to virtual machine)

Insert picture description here


After restarting the system:
Insert picture description here


④ Step 2 of adding hard disk to the virtual machine (partition)

Insert picture description here

说明: 开始分区后输入n,新增分区,然后选择p ,分区类型为主分区。
两次回车默认剩余全部空间。最后输入w写入分区并退出,若不保存退出输入q。

Step diagram:
Insert picture description here
Insert picture description here
Insert picture description here


⑤ Step 3 of adding hard disk to the virtual machine (formatting)

Insert picture description hereInsert picture description here

(You can use lsblk -f to check, that is, success)
Insert picture description here



⑥ Step 4 of adding a hard disk to the virtual machine (mounting)

Insert picture description here


Insert picture description here

ps: mount on the command line, it will be invalid after restart
Insert picture description here


⑦ Step 5 of adding a hard disk to the virtual machine (permanently mount)

Insert picture description here


Modify /etc/fstab to realize the mount and
Insert picture description here
add content
Insert picture description here
added, execute mount -a to take effect

Insert picture description here


(4) Disk condition query

① Query the overall disk usage of the system

Insert picture description here


Insert picture description here


② Query the disk occupancy of the specified directory

Insert picture description here


Insert picture description here


(5) Disk situation-practical instructions for work

Insert picture description here

① Count the number of files in the /home folder

wc -l  :统计行

|  :管道符,将前面的结果交给后面处理

grep “^-” :筛选,只保留一般的文件

grep "^d" :筛选,只保留目录

-R :递归统计子文件夹下的文件或目录

Insert picture description here


② Count the number of directories in the /home folder

Insert picture description here


③ Count the number of files in the /home folder, including those in subfolders

Insert picture description here


④ Count the number of directories under the folder, including those in subfolders

Insert picture description here


⑤ Display the directory structure in a tree

Install tree first

Insert picture description here
Insert picture description here
Insert picture description here


Guess you like

Origin blog.csdn.net/weixin_45260385/article/details/114462116