Linux partition details
It is divided into two parts
1. Hard disk partition when installing Linux system.
2. Linux add hard disk partition
1. Hard disk partition when installing Linux system.
Usually, the hard disk is about 500G.
1.1 partitions that must exist
/The partition that must exist when partitioning. All level-1 directories are located under the partition. At the same time, they are also related to actions such as boot, restore and system repair, including some programs to repair the system. The file system Hierarchy Standard (FHS) suggests that the root partition / should be as small as possible to meet the system requirements, so as to avoid system damage caused by hard disk failure as much as possible. At the same time, it is better not to create new subdirectories and store unnecessary files in / partitions. The recommended size is 50G~100G.
/boot/efi must exist when the firmware is uefi. The recommended size is 200M.
/The biosboot hard disk adopts GPT partition. When the firmware is BIOS, it must exist. The recommended size is 2M.
Tips: / partition must exist, / boot/efi and / biosboot must also exist under specific circumstances.
1.2 recommended partitions
/Boot contains the static files required to boot the system, such as Linux kernel files, boot menu and some configuration files required for boot. The recommended size is 1G.
1.3 zoning as required
/Under var, there are some changed data, such as logs and caches. It is recommended to separate them. With the use of the system, the utilization rate of the partition will become larger and larger, and the space demand is still relatively large. It is recommended to separate it. In particular, some high load applications will produce a large number of logs, with the recommended size of 100~200G.
/tmp places some temporary files and temporary files during program operation. It is recommended to divide some servers with high load. The recommended size is 100G. (at least 2G if Dameng database is installed)
/Home mainly depends on the purpose of the server. For example, ftp places the files of a specific user into the user's home directory by default, so it is necessary to allocate space to the partition as much as possible. However, usually at this time, there will be additional data disks. If similar services are not provided, the partition can not be divided.
Swap swap partition should have been divided according to the memory size, but now the server configuration is generally high, and it can be divided into 4~8G standby.
Others, such as / usr and / opt, generally do not need to be divided separately. Usually, the server is usually used as a special server, and many software will not be installed. Sometimes, it may be necessary to divide a / date storage point data.
Tips: it is recommended not to divide all the space of the hard disk and leave part for standby and capacity expansion (LVM). The mount point, partition type and file system can be used as recommended by the system. The soft raid is not necessary to use now, and the volume group is not necessary to be modified. The Label (equivalent to naming the partition system and software under Windows) and Name are set according to the actual situation.
1.4 recommended zoning scheme
For a nominal 500G hard disk, the actual space should be about 450G/ biosboot and / boot/efi can use the recommended size if necessary according to the actual situation.
/ 100G /boot 1G /var 100G swap 8G
In most cases, these partitions can be divided in this way, so that there is about 240G left in the 450G hard disk. I suggest leaving at least 50G unallocated for future expansion partitions. In this way, there is 190G unallocated space in the hard disk, which needs to be determined according to the actual use of the server.
1.5 running high load applications
/tmp 100G
Because high load applications often produce a large number of temporary files, it is recommended that / tmp be separated separately. The log volume of high load servers is also large. It is suggested that the remaining 90G can be added to / VAR, that is, / var (100G+90G)
1.6 test and development environment
/usr 100G
For the testing and development environment, more software needs to be installed, so it is recommended to separate a / usr partition to install the software, and the remaining 90G is free to decide.
1.7 multi user environment
/home 100G
For servers in multi-user environment, each user may often need to store some things in their own home directory. It is recommended to divide a / home directory separately, and the remaining 90G is free to decide.
Remarks: the above contents are reproduced. Here is the address
https://www.linuxidc.com/Linux/2019-04/158216.htm
2.Linux partition when adding hard disk
Linux add hard disk
2.1 operating environment
- VMware Workstation
- CentOS7.9
- Intel® Core™ i5-7200U CPU @ 2.50GHz
2.2 prepare to add a 200G hard disk
2.3 right click the virtual machine to which you want to add the hard disk.
- Click settings
- Select the hard disk and click add below
- Select the hard disk, click next, default until the hard disk capacity is selected, select 200G and click next.
- Click OK
- Restart the system
- Generally, after adding a hard disk, if fdisk -l does not display the added hard disk, you need to restart the system
2.4 connecting Linux with xshell
fdisk -l
View hard disk information
[root@localhost ~]# fdisk -l Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000e6221 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 125829119 61864960 8e Linux LVM Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
2.5 interpretation of zoning operation
fdisk /dev/sdb
[root@localhost ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x53ca703f. Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help):
Noun interpretation
command(input m get help): m help: GPT M Entry protection/blend MBR routine d delete a partition F List free areas that are not partitioned l List known partition types n Add new partition p Print partition table t Change partition type v Check partition table i Print information about a partition miscellaneous m Print this menu x More features(Professionals only) script I from sfdisk Script file loading disk layout O Dump disk layout to sfdisk Script file Save and exit w Write partition table to disk and exit q Exit without saving changes New empty disk label g Create a new one GPT Partition table G Create a new blank GPT (IRIX) Partition table o Create a new blank DOS Partition table s Create a new blank Sun Partition table #This is the help information obtained on galaxy Unicorn v10. It's for reference only.
2.6 partition operation
fdisk /dev/sdb n p 1 Enter until w
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-419430399, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): Using default value 419430399 Partition 1 of type Linux and of size 200 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
2.7 formatting
mkfs.ext3 /dev/sdb1
[root@localhost ~]# mkfs.ext3 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 13107200 inodes, 52428544 blocks 2621427 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 1600 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
Create mount point
mkdir /data
2.9 mount the partition
mount /dev/sdb1 /data
2.10 check the partition mounting
df -h
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 475M 0 475M 0% /dev tmpfs 487M 0 487M 0% /dev/shm tmpfs 487M 7.7M 479M 2% /run tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/mapper/centos-root 29G 13G 17G 45% / /dev/mapper/centos-home 4.0G 33M 4.0G 1% /home /dev/mapper/centos-tmp 2.0G 33M 2.0G 2% /tmp /dev/sda1 1014M 138M 877M 14% /boot /dev/mapper/centos-var 20G 364M 20G 2% /var tmpfs 98M 0 98M 0% /run/user/0 /dev/sdb1 197G 60M 187G 1% /data
2.11 cancel mounting
umount /dev/sdb1 /data
2.12 set automatic mount after startup
vim /etc/fstab Create a new row at the bottom /dev/sdb1 /data ext3 defaults 0 0
# # /etc/fstab # Created by anaconda on Mon Oct 18 02:04:54 2021 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/centos-root / xfs defaults 0 0 UUID=3e049b0e-b709-4afe-af77-e15a0ca6d3e7 /boot xfs defaults 0 0 /dev/mapper/centos-home /home xfs defaults 0 0 /dev/mapper/centos-tmp /tmp xfs defaults 0 0 /dev/mapper/centos-var /var xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 /dev/sdb1 /data ext3 defaults 0 0
2.13 problems and summary
A 200G hard disk is added to vmware, but the display is 214.7G with fdisk -l. after formatting, it is only 187G. You still have to study hard.
If you are adding a hard disk in a production environment, start with 5.
If it is to be divided into multiple areas, the sixth step is to take a closer look. See others' blogs for details.
3. Summary
This is a simple partition interpretation and application. Make a record.