If you have a hard drive, how do you use it for your Linux system?
1. Install the hard drive on the server
2. Partition the hard disk
3. Format the partition
4. Create a directory (mount point) on a Linux system
5. Mount a formatted partition to a directory
Partitioning the hard disk
Fdisk-l View
The absolute path to the Fdisk hard disk device indicates that a hard disk is partitioned, for example:
Fdisk/dev/sdb
d--means to delete a partition
n--means adding a partition
l--indicates that a known partition type is listed
P Print out all the partitions
Q exits the current shell and does not save the previous operation
W Save the previous operation and exit
T change ID----partition type, L can view
To add a partition:
n-------P (primary partition)---------1-4----------First Sector direct carriage return----last sector +2g
N-----E (extended partition)-----2/3/4--------First and Last direct carriage (the rest is placed in the extended partition)
n------L (logical partition)----------5----------
Partprobe refreshes the partition table. In some cases, the partition cannot take effect immediately after it is restarted, but partprobe refreshes the partition table without restarting. will allow the partition to take effect.
Partprobe is used as a standard command after partitioning.
Formatting a partition
Just partition the hard disk is no file system, the purpose of formatting is to give the partition file system
The command is MKFS. The absolute path to the file system partition, such as:
MKFS.EXT4/DEV/SDB1 formats the first partition of SDB into a ext4
MKFS.XFS/DEV/SDB2 format the second partition into XFS
Never format an extended partition/logical partition, and formatting will cause the logical partition to disappear.
Create a directory (mount point) on a Linux system df-th
Mkdir/diskb1
Mount a formatted partition to a directory
Mount/dev/sdb1/diskb1
*******************************
Mount command is temporarily mounted and server reboot is not mounted
If you need to mount permanently, (boot automatically mount):
When the system is powered on, it will mount the storage device according to the contents of the/etc/fstab file.
Vim/etc/fstab
Modify a file
/DEV/SDB1/DISKB1 XFS Defaults 0 0
Mount-a
This command will allow the system to be mounted once in accordance with the/etc/fstab file. If the file is wrong, it will mount the failure, this time, through the error can be seen to write the file is wrong.
So mount-a as a must-knock command after modifying/etc/fstab.
Swap partition: Free
Virtual memory is the swap partition, the swap partition is the virtual memory
The role of virtual memory, memory is not enough when you're on
#虚拟内存 swap, when the memory is low, some programs are stuck in swap.
Free-h/k/m/g
[Email protected] tmp]# free-h
Total used free shared buffers Cached
mem:3.7g 1.5G 2.2G 9.9M 2.7M 434M
-/+ buffers/cache:1.0g 2.7G
swap:0b 0B 0B
P.S.
Memory 384M Character Interface
GUI Page 700M
MKSWAP/DEV/SDB2 format into swap file
Vim/etc/fstab
/DEV/SDB2 swap swap defaults 0 0
MOUNT-A Check that the configuration file is correct
Swapon-a the command on the swap partition mount
Free-h
How to uninstall:
Swapoff/dev/sdb2
Block UUID for Blkid devices
Ls/dev/disk/by-uuid/-L = blkid
This article is from the "12902999" blog, please be sure to keep this source http://12912999.blog.51cto.com/12902999/1976098
Linux Partition format mount mount