Linux system disk formatting and manually adding swap partition

Linux system disk formatting and manually adding swap partition

Windows: Support NTFS, FAT

Linux supports file formats:

Run cat /etc/filesystems to view the file formats supported by Centos 7.

xfs Centos 7 default file system name is xfs

Mount view /dev/vda1 on / type ext4 (rw,relatime,data=ordered)


Disk formatting

mke2fs -t exet4 specifies the file system format to be formatted
mke2fs -b specifies the block size

For example: mke2fs -t ext4 -b 2048 /dev/sdb1 #Specify the file system format as ext4, the block size as 2048k, and format the /dev/sdb1 disk (the principle is the same as Windows formatting)

blkid View unmounted partitions

mkfs.ext4 = mke2fs -t ext4

mke2fs -b 8192 /dev/sdb1

Note: Regarding the distinction between 8192 and 4096:

When storing large files such as videos, 8192 is recommended to speed up reading and writing.
When storing small files, 4096 or 2048 is recommended.

When formatting the hard disk, 5% of the space will be reserved for the root user, which will take up a lot of space. Set the reserved space:

mke2fs -m 1 /dev/sdb1 Set the reserved space to 1%
mke2fs -m 0.1 /dev/sdb1 sets the reserved space to 0.1%
mkfs.ext4 -m 0.1 /dev/sdb1

If the file system format is not specified, the default is ext2.

mke2fs -i 8192 ext4 /dev/sdb1 sets 8192 bytes as one inode


Set the file format to xfs

mkfs.xfs /dev/sdb1

Swap space: up to 8G

1. Simulate disk

dd if=/dev/zero of=/newdisk bs=1M count=100
Notes:
Creating zero is not a space, it is a file
/dev/zero is a special device that contains a constant stream of "0"
If specifies the source device
ofSpecify the target device


Check the swap disk sizeCheck the swap disk size
du -sh /name

2. Formatting

swap format
mkswap /path


Add the newly created swap space to the original swap space.

First check the current swap space.

free -m

Hang it on the original swap space.


Tip: unsafe permission 0644, it is recommended to use 0600. Although the prompt appears, it will still be mounted to the original swap space.


To ensure security, you can modify permissions

chmod 0600 /newdisk

Uninstall the swap space and delete it directly to restore the original space.

1 swapoff /newdisk
2 rm -f /newdisk

blkid View file format

You may also be interested in:
  • Analysis of the Principle and Method of Implementing Linux Disk Partition
  • An article to understand Linux disks and disk partitions
  • How to implement Linux disk mounting, partitioning, and capacity expansion operations
  • Detailed explanation of Linux virtual machine root partition disk expansion space record
  • Linux disk partitioning practical examples (must read)
  • Detailed process of LINUX disk partitioning, formatting, mounting and uninstalling
  • How to use GPT partitioning on Linux disks larger than 2T
  • Linux parted disk partition implementation steps analysis

<<:  js to implement collision detection

>>:  A brief discussion on whether MySQL can have a function similar to Oracle's nvl

Recommend

Comparison of the use of form element attributes readonly and disabled

1) Scope of application: readonly:input[type="...

HTML table tag tutorial (20): row background color attribute BGCOLOR

The BGCOLOR attribute can be used to set the back...

JS implementation of carousel example

This article shares the specific code of JS to im...

js to achieve floor scrolling effect

This article uses jQuery to implement the sliding...

Some details about semicolons in JavaScript

Preface Semicolons in JavaScript are optional, an...

The new version of Chrome browser settings allows cross-domain implementation

Preface Currently, the front-end solves cross-dom...

Detailed explanation of MySQL high availability architecture

Table of contents introduction MySQL High Availab...

Graphical introduction to the difference between := and = in MySQL

The difference between := and = = Only when setti...

Linux general java program startup script code example

Although the frequency of starting the shell is v...

Node.js makes a simple crawler case tutorial

Preparation First, you need to download nodejs, w...

How to extract string elements from non-fixed positions in MySQL

Preface Note: The test database version is MySQL ...