8th. File System Management (2) _ Mount, Fdisk partition and allocate swap

Source: Internet
Author: User

3. fdisk Partitioning

3.1 fdisk Command Partitioning procedure

(1) Adding a new hard drive

(2) View new drive #fdisk –l

(3) Use the FDISK command partition: #fdisk/dev/sdb

Fdisk Interactive instruction Description

Command

Description

A

To set a bootable tag

B

Edit BSD Disk Labels

C

Set DOS operating system compatible tags

D

Delete a partition

L

Displays the type of file system you know. 82 for Linux swap,83 for Linux partitioning

M

Show Help Menu

N

New Partition

O

Create a blank DOS partition table

P

Show Partition list

Q

Do not save exit

S

New Blank Sun Disk label

T

Change the system ID of a partition

U

Change the display recording unit

V

Verify partition Table

W

Save exit

X

Additional features (experts only)

"Example" new primary and logical partitions

(4) Re-read partition table information: #partprobe//Avoid partition after reboot system

(5) format partition: #mkfs –t ext4/dev/sdbx ( where x is the partition number, but be aware that the primary and logical partitions can only be formatted.) Extended partitions are used for logical partitioning, so they cannot be formatted.

(6) Set up the mount point and mount the load

#mkdir/disk1

#mount/dev/sdb1/disk1/

3.2 partition Auto Mount and fstab file repair

(1)/etc/fstab file

① 1th field: partition device file name or UUID(hard disk universal unique identification code) , use #dumpe2fs–h/dev/sdb1 to find the "Filesystem uuid" and see the UUID of the partition.

② 2nd field: mount point

③ 3rd field: File system name

④ 4th field: Mount Parameters

⑤ 5th field: Specifies whether the partition is backed by a dump, 0 means no backup, 1 represents a daily backup, and 2 represents an unscheduled backup.

⑥ 6th field: Specifies whether the partition is detected by fsck, 0 means no detection, and the other number represents the priority of the detection, then of course 1 has a higher priority than 2.

(2) Auto-mount:

① #vi/etc/fstab//Edit/etc/fstab

② New Line: "/dev/sdb1/disk1 ext4 defaults 1 2" to automatically mount the/DEV/SDB1 partition to the/disk1 directory at startup

  ③ #mount –a //automatically mounts according to the profile/etc/fstab content (executes this command to mount each partition automatically without rebooting the system)

4./etc/fstab File Repair

(1) If the partition table is not filled out correctly, the error occurs when restarting, but the system still allows us to enter the root password after logging into the system, but at this time the root partition is mounted as read-only permission , can be used #mount –o REMOUNT,RW/ To assign read and write permissions to the root partition .

(2) You can then #vi/etc/fstab the file and fix the wrong mount point one by one.

5. Assigning a swap partition

(1) query memory and swap partition usage :#free

①cached (cache):   refers to the reading of the data stored in memory, when read again, without reading the hard disk and directly from the memory to read, accelerating the reading process of the data .

②buffer (buffering):   When writing data, the distributed write operation is saved to the memory, when a program is reached to focus on the hard disk, reducing the disk fragmentation and the hard disk repeatedly seek, accelerating the data writing process.

(2) New swap partition:#fdisk/dev/sdb

① Create a new logical partition: #fdisk/dev/sdb, then create a new logical partition

 ② Change the area codeto 82 (the ID number of the swap partition)

(3) Formatting: #mkswap/DEV/SDB6

① will need to be restarted to format after dividing the swap partition

  ② Note that the command for the rasterized swap partition is Mkswap, not mkfs

(4) Adding and canceling swap partitions into the system

① Join the swap partition to the system:   #swapon/dev/sdb6 ( Temporary entry into force!) )

  ② Cancel swap partition:SWAPOFF/DEV/SDB6

(5) Automatic mount of swap partition boot

#vi/etc/fstab

/DEV/SDB6 swap swap defaults 0 0 (note that the 1th swap is a mount point, do not write the error/swap, the 2nd swap is the file system type)

8th. File System Management (2) _ Mount, Fdisk partition and allocate swap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.