当前位置:网站首页>04 disk space management
04 disk space management
2022-06-25 21:00:00 【Zhushuaijie 1】
—— Identify the hard disk
Real machine windows VMware
[[email protected] ~]# lsblk # List the current system distinguish Of Hard disk
[[email protected] ~]# ls /dev/sda #
[[email protected] ~]# ls /dev/sdb #
Real machine Linux-------KM
[[email protected] ~]# lsblk # List the hard disks recognized by the current system
[[email protected] ~]# ls /dev/vda #
[[email protected] ~]# ls /dev/vdb #
—— Zoning planning and use
One 、 Partition management
1. Disk structure and concept

2. A hard disk “ art ” The journey

3. Zoning
Partition plan ( Partition mode ): MBR And GPT
MBR/msdos Partition mode
— Partition type : Primary partition 、 Extended partitions ( Take up all the remaining space )、 A logical partition
— At best 4 Primary partitions
— The extended partition may not have , At most one
— 1~4 Primary partitions , perhaps 3 Primary partitions +1 Extended partitions (n Logical partitions )
— The maximum support capacity is 2.2TB Of disks
— Extended partition cannot be formatted , Space cannot store data directly
— Partitions that can be used to store data : Primary partition 、 A logical partition
4. Use fdisk Partitioning tool
fdisk -l /dev/vda # View partition table
fdisk Hardware device # Modify the partition table of the hard disk

Comprehensive zoning :
[[email protected] ~]# fdisk /dev/vdb ----vda,cdb,vdc,vdd---- This is the hard disk name
n create primary partition 1-----> Partition type enter -----> Partition number enter -----> starting sector enter -----> stay last At the end +2G
p View partition table
n create primary partition 2-----> Partition type enter -----> Partition number enter -----> starting sector enter -----> stay last At the end +2G
p View partition table
n create primary partition 3-----> Partition type enter -----> Partition number enter -----> starting sector enter -----> stay last At the end +2G
p View partition table
n create extended 4-----> Partition type enter -----> Partition number enter -----> starting sector enter -----> stay last At the end enter - Allocate all remaining space to the extended partition
p View partition table
n Create logical partitions 5-----> start enter -----> At the end +2G
n Create logical partitions 6-----> start enter -----> At the end +2G
p View partition table
w Save and exit
[[email protected] ~]# lsblk
[[email protected] ~]# partprobe # Refresh the partition table --- Unrecognized partition table , When the partition cannot be completed , Refresh try
5. Identify new partition
Use partprobe command
— When the partition table of the hard disk is changed , The change of partition table shall be notified in time Linux kernel , best reboot once
— Otherwise, the exact device may not be found when accessing the partition
[[email protected]localhost ~]# partprobe /dev/vdb
## perhaps
[[email protected] ~]#reboot
Two 、 format partition
format : The process of giving a spatial file system
file system : Rules for storing data in space
windows Common file systems : NTFS FAT( Strong compatibility )
Linux Common file systems :ext4(RHEL6) xfs(RHEL7) FAT
1. Common formatting tools
mkfs Toolset
[[email protected] ~]# mkfs.<Tab><Tab> # Press twice in a row tab key
mkfs.btrfs mkfs.ext3 mkfs.minix mkfs.xfs
mkfs.cramfs mkfs.ext4 mkfs.msdos
mkfs.ext2 mkfs.fat mkfs.vfat
[[email protected] ~]# mkfs.ext4 /dev/vdb1 # Format file system ext4
[[email protected] ~]# blkid /dev/vdb1 # View file system types
[[email protected] ~]# mkfs.xfs /dev/vdb2 # Format file system xfs
[[email protected] ~]# blkid /dev/vdb2 # View file system types
3、 ... and 、 Accessing the file system
1. Access the formatted partition
—— Use mount Command mount to use , And visit the test
[[email protected] ~]# mkdir /mypart1
[[email protected] ~]# mount /dev/vdb1 /mypart1/ # mount
[[email protected] ~]# mkdir /mypart2
[[email protected] ~]# mount /dev/vdb2 /mypart2/ # mount
—— Use df Check usage
[[email protected] ~]# df -h # Display the information of the device being mounted
file system Capacity Already used You can use Already used % Mount point
/dev/mapper/centos-root 17G 3.7G 14G 22% /
devtmpfs 480M 0 480M 0% /dev
tmpfs 496M 0 496M 0% /dev/shm
tmpfs 496M 7.8M 489M 2% /run
tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/vda1 1014M 157M 858M 16% /boot
tmpfs 100M 4.0K 100M 1% /run/user/42
tmpfs 100M 28K 100M 1% /run/user/0
/dev/sr0 8.8G 8.8G 0 100% /run/media/root/CentOS 7 x86_64
/dev/vdb1 2.0G 6.0M 1.8G 1% /mypart1
2. Realize automatic mount after power on /etc/fstab

/dev/vdb1 /mypart1 ext4 defaults 0 0( Don't test )
1( Give priority to detection )
2( Secondary test )
[[email protected] ~]# vim /etc/fstab
/dev/vdb1 /mypart1 ext4 defaults 0 0
/dev/vdb2 /mypart2 xfs defaults 0 0
mount -a (auto) ---> /etc/fstab // Automatically mount
[[email protected] ~]# umount /mypart1 # uninstall
[[email protected] ~]# umount /mypart2 # uninstall
[[email protected] ~]# mount -a # Automatically mount
testing /etc/fstab Automatically mount the configuration file after power on , Is the format correct
testing /etc/fstab in , The writing is complete , But there are currently no mounted devices , Mount
[[email protected] ~]# df -h | grep mypart
Four 、 Hard disk partition advanced
1.GPT Partition mode
GPT,GUID Partition Table
— Globally unique logo
— Break through fixed size 64 Partition table limit of bytes
— Maximum support 128 Primary partitions , The biggest support 18EB disk
parted Common partition instructions
-help # View instruction help
-mktable msdos | gpt # Create the specified schema partition table
-mkpart primary File system type start end # Appoint size or percentage % As a starting point 、 End position
-print # View partition table
-rm Serial number # Delete the specified partition
-quit # Exit the interactive environment
[[email protected] ~]# parted /dev/vdd
GNU Parted 3.1
Use /dev/vdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)mktable gpt # Specify partition mode
(parted) mkpart # Divide the New Area
Partition name ? []? one # Write casually
File system type ? [ext2]? ext4 # Write at will , No formatting
The starting point ? 0
The end point ? 5G
Warning : The resulting partition is not properly aligned for best performance.
Ignore /Ignore/ give up /Cancel?Ignore # Choose to ignore , Input i(tab) completion
(parted)print # View the partition table information
Model: Virtio Block Device (virtblk)
Disk /dev/vdd: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name sign
1 17.4kB 5000MB 5000MB one
(parted) unit GB # Use GB As a unit
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdd: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name sign
1 0.00GB 5.00GB 5.00GB one
(parted) mkpart
Partition name ? []? two
File system type ? [ext2]? ext4
The starting point ? 5G # For the end of the previous partition
The end point ? 10G
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdd: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name sign
1 0.00GB 5.00GB 5.00GB one
2 5.00GB 10.0GB 5.00GB two
—— Swap space
Mode one : Use hard disk partition to make swap space
[[email protected] ~]# ls /dev/vdd2
/dev/vdd2
[[email protected] ~]# mkswap /dev/vdd2 # Format swap file system
[[email protected] ~]# blkid /dev/vdd2 # View file system types
[[email protected] ~]# swapon # View the member information of the swap space
[[email protected] ~]# swapon /dev/vdd2 # Enable swap partition
[[email protected] ~]# swapon
[[email protected] ~]# free -m # Check the swap space size
[[email protected] ~]# swapoff /dev/vdd2 Disable the swap partition
[[email protected] ~]# swapon
[[email protected] ~]# free -m
The switch partition is enabled automatically after startup
边栏推荐
- Basic process of configuring utf8 in idea
- Compile 6relayd using the cross compiler
- Openocd compilation and installation
- Live broadcast preview | front line experts invite you to talk: the value of data science enabling multiple application scenarios
- Section 13: simplify your code with Lombok
- Server pressure troubleshooting top
- Leetcode theme [array] -31- next spread
- Mysqldumpslow out slow statements in the database
- Cvpr2021 collection of papers | cvpr2021 latest papers | cvpr2021 review results | cvpr2021 admission results
- Introduction to interface test, interface protocol and common interface test tools
猜你喜欢
hashlib. Md5() function to filter out duplicate system files and remove them

What is a subnet mask? (Powercert animated videos)

Docker failed to remotely access 3306 after installing MySQL
Understand the offline mixing technology in the industry
Boomfilter learning

Node installation method you don't know
A new paradigm for large model application: unified feature representation optimization (UFO)

A simple file searcher
This is a simple and cool way to make large screen chart linkage. Smartbi will teach you

The correct way to clear the cache of the computer. The computer will not get stuck immediately after changing. practical
随机推荐
Talking about the foundation of function test today
What is a server? (Powercert animated videos)
Cloud development practice of the small program for brushing questions in the postgraduate entrance examination - page design and production (home page of the question bank, ranking page, my)
Cvpr2021 collection of papers | cvpr2021 latest papers | cvpr2021 review results | cvpr2021 admission results
Is it safe for qiniu school to open a securities account?
同花顺炒股软件开户是合法的吗?安全吗
Idea implements hot deployment
Soft test intermediate simple notes
Get the root directory of the package at compile time from buildreoot
After 20 days' interview, I finally joined Ali (share the interview process)
Leetcode theme [array] -31- next spread
Multi database and multi table backup and restore of MySQL under Linux
2022 oceanbase technical essay contest officially opened | come and release your force
What is an app circle of friends advertisement
Baidu AI Financing Innovation workshop enrollment!
Cloud native 04: use envoy + open policy agent as the pre agent
An unusual interview question: why doesn't the database connection pool adopt IO multiplexing?
Is it legal to open an account for flush stock trading software? Is it safe?
Local variables and global variables in C language
Web components series (11) -- realizing the reusability of mycard