Linux basic commands and Operations 13 (Disk Management) __linux

Source: Internet
Author: User
    Disk Management1. Interpretation of nouns
Mbr
Mpt
Hard Drive Validity Indicator
Primary partition
Extended partitions
Logical partitions

2. Disk View command
Fdisk-l # #系统中的所有磁盘设备
Df-th # #系统正在挂载的磁盘设备
Blkid # #系统可以挂载的磁盘设备id

3. Zoning Division
Fidsk/dev/vdb


M # #获得帮助
N # #新建分区
Partition Type:
P Primary # #分区类型为主分区
E Extended # #分区类型为扩展分区
Select (default p): P

Partition number (2-4, default 2): 1 # #主分区id

Sector (206848-20971519, default 206848): # #此分区的起始位置 last sector, +sectors or +size{k,m,g} (206848-20971519, default 20971519): +1g # #分区大小


Command (M for help): Wq # #保存并退出, just enter Q to discard the change exit


Create a new primary partition/DEV/VDB1 Wq save launch


[Root@localhost ~]#

Partprobe # #同步分区表
MKFS.XFS/DEV/VDB1 # #格式化

MOUNT/DEV/VDB1/MNT # #临时挂载


Format the partition in XFS format and temporarily mount to/mnt



Vim/etc/fstab # #永久挂载
Write format:
Device Mountpoint ftype defaults (mountpoint) 0 0

/dev/vdb1/mnt XFS Defaults 0 0


Enter/etc/fstab file write to achieve permanent mount


Mount-a # #使 The Mount of records in/etc/fastab takes effect




4. Delete partitions
Use the Umount command to lift the Mount first
Note: When the mount point is used, the mount cannot be lifted, the process that is used to end the use is FUSER-KVM, and then the mount is lifted

Remove a partition using the FDISK/DEV/VDB command after the mount is lifted




5. Set partition mode, change Mkdocs to GPT
You need to turn off the partition you are using before you can change it
Partoff/dev/vdb2

Parted/dev/vdb



6. Add Swap partition
FDISK/DEV/VDB # #添加一个分区

[Root@localhost ~]# Fdisk/dev/vdb

Command (M for help): N New Partition


Command (M for help): T select partition type



Partition type (type L to list all types): 14 Select Linux Swap partition

Command (M for help): P Display partition


Command (M for help): Wq

The partition table has been altered!



7. Change the swap under GPT under Mkdos




8. Use file to add swap

DD If=/dev/zero of=/swapfile bs=1m count=1000 # #创建一个1G大小的文件
Mkswap/swapfile # #格式化为swap类型

Swapon-a/swapfile # #临时添加到swap里


-p + Number # #更改优先级
Vim/etc/fstab # #永久添加swap分区
Type:

/swapfile swap defaults,pri=1 0 0 #pri优先级

Swapon-a automatically turn on all swap devices



9. Delete Swap
Vim/etc/fstab # #删除此文件中添加的swap行
Swapoff/swapfile # #断开swap文件链接
SWAPOFF/DEV/VDB1 # #断开swap磁盘链接
Rm-rf/swapfile # #删除文件
FDISK/DEV/VDB # #删除磁盘分区

Partprobe # #同步分区表





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.