当前位置:网站首页>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
边栏推荐
- What is a server? (Powercert animated videos)
- [summary] 2021unctf Campus (cry & MISC)
- OLED driven learning based on ssd1306 (II): addressing mode of ssd1306
- What is machine learning? (Fundamentals)
- Barrier of cursor application scenario
- Lesson 3 urllib
- What is API
- MySQL lock
- Local variables and global variables in C language
- Web components series (11) -- realizing the reusability of mycard
猜你喜欢
Global netizens Yuanxiao created a picture of appreciating the moon together to experience the creativity of Baidu Wenxin big model aigc
Decipher the AI black technology behind sports: figure skating action recognition, multi-mode video classification and wonderful clip editing
Tencent music knowledge map search practice
Openocd adds third-party device support: ht32f52352 Cortex-M0+
2022 "gold, silver and four" is a must for job hopping. You must know 100 questions in 2022 intermediate and advanced Android interview to realize your big factory dream
Log4j2 vulnerability detection tool list
Slenium tips: how to handle some dialog boxes that may appear on Web pages
Barrier of cursor application scenario
Cloud native 04: use envoy + open policy agent as the pre agent
Attention to government and enterprise users! The worm prometei is spreading horizontally against the local area network
随机推荐
After 20 days' interview, I finally joined Ali (share the interview process)
Data query of server SQL. The most important chapter in database learning
Introduction to event flow, event capture, and event bubbling
Exploration of advanced document editor design in online Era
What is a subnet mask? (Powercert animated videos)
The SH runtime directly reported an error syntax error near unexpected token ` $'. \r‘
Those high-frequency and real software test interview questions sorted out by the test director in 7 days, come to get
Lesson 1 Preparation
VFS appears when mounting a file system from an SD card: cannot open root device "mmcblk1p2“
Code program related problems troubleshooting directory
Redis common principles interview
Barrier of cursor application scenario
"Space guard soldier" based on propeller -- geosynchronous geostationary orbit space target detection system
[deep learning series] - visual interpretation of neural network
Multi database and multi table backup and restore of MySQL under Linux
The super easy-to-use test tool sorted out by Ali P8 for a week
Leetcode topic [array] -33- search rotation sort array
Day 28/100 CI CD basic introductory concepts
Cvpr2021 collection of papers | cvpr2021 latest papers | cvpr2021 review results | cvpr2021 admission results
Jingxi Pinpin wechat applet -signstr parameter encryption