Simple partitioning and management in the linux--system

Source: Internet
Author: User

One, add File system space

Simple partitioning and file system
1. Recognize
1> storage is a basic requirement for every computer system. Red Hat Enterpriselinux provides powerful tools to manage multiple types of storage devices in a large number of scenarios

2> disk is a utility for managing partition of disks. You can run the utility by selecting the-l option and specifying the disk name (FDISK-CUL/DEV/VDA) to view the disk and its partitions. You can make changes by running the utility interactively and selecting the appropriate menu option (FDISK-CU/DEV/VDA). -c disables old DOS compatibility mode,-u displays output as sector (not cylinder, obsolete) format
Xiaot

3> Viewing system device information
Fdisk-l
Display all available device information in the system
Blkid
Displays the device ID that the system is using

2. Add a new device
1> New Partition
[Email protected] ~]# FDISK/DEV/VDB# operation #进入/dev/vdb
Welcome to Fdisk (Util-linux 2.23.2).

Changes'll remain in memory only, until the 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 0x115e3020.

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# #修改分区功能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): N# #新建分区
Partition Type:
P Primary (0 primary, 0 extended, 4 free)# #主分区, you can have up to four primary partitions
E Extended# #扩展分区, inside the extended partition as a container, logical partitions are created inside
Select (default p): P# #建立新的主分区
Partition number (1-4, default 1): 1# #选择建立1号主分区
First sector (2048-20971519, default 2048):# #默认从硬盘的使用结尾部分开始
Using Default Value 2048
Last sector, +sectors or +size{k,m,g} (2048-20971519, default 20971519): +100m # # #设置分区大小
Partition 1 of type Linux and of size MiB is set


Command (M for help): P# #显示当前分区情况

disk/dev/vdb:10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk identifier:0x115e3020

Device Boot Start End Blocks Id System
/DEV/VDB1 2048 206847 102400-up Linux

Command (M for help): N# #再次建立新的分区
Partition Type:
P Primary (1 primary, 0 extended, 3 free)
E Extended
Select (default p): E# #选择建立新的扩展分区
Partition number (2-4, default 2): 2
First sector (206848-20971519, default 206848):
Using Default Value 206848
Last sector, +sectors or +size{k,m,g} (206848-20971519, default 20971519): +200m
Partition 2 of type Extended and of size MiB is set

Command (M for help): P

disk/dev/vdb:10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk identifier:0x115e3020

Device Boot Start End Blocks Id System
/DEV/VDB1 2048 206847 102400-up Linux
/DEV/VDB2 206848 616447 204800 5 Extended

Command (M for help): N
Partition Type:
P Primary (1 primary, 1 extended, 2 free)
L Logical (numbered from 5)
Select (default P): L# #新建逻辑分区
Adding Logical Partition 5
First sector (208896-616447, default 208896):
Using Default Value 208896
Last sector, +sectors or +size{k,m,g} (208896-616447, default 616447): +100m
Partition 5 of type Linux and of size MiB is set

Command (M for help): P

disk/dev/vdb:10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk identifier:0x115e3020

Device Boot Start End Blocks Id System
/DEV/VDB1 2048 206847 102400-up Linux
/DEV/VDB2 206848 616447 204800 5 Extended
/DEV/VDB5 208896 413695 102400-up Linux


Command (M for help): W# #设置完毕后保存以上所有设置
The partition table has been altered!

Calling IOCTL () to re-read partition table.
Syncing disks.
[Email protected] ~]# Partprobe# #更新分区系统文件
[Email protected] ~]# cat/proc/partitions# #查看分区系统文件内分区情况
Major Minor #blocks name

253 0 10485760 VDA
253 1 10484142 vda1
253 10485760 VDB
253 102400 VDB1
253 1 VDB2
253 102400 VDB5
[Email protected] ~]#

Figure: Fdisk displays the device currently in existence

650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/01/c09829d89d0752d88cbf06942af268a6.png-wh_500x0-wm_3 -wmp_4-s_1515707217.png "title=" screenshot from 2017-11-01 19-26-50.png "alt=" C09829d89d0752d88cbf06942af268a6.png-wh_ "/>

[Email protected] ~]# Blkid# #当前可以使用的设备, because the new partition is occupied by data and is not considered available by the system, so there is no new device
/dev/vda1:uuid= "9bf6b9f7-92ad-441b-848e-0257cbb883d1" type= "XFS"

2> format new partition, activation settings can be used
File system:
# #mkfs. Btrfs mkfs.ext2 mkfs.ext4 Mkfs.minix mkfs.vfat
# #mkfs. Cramfs mkfs.ext3 mkfs.fat Mkfs.msdos mkfs.xfs
650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/01/d28b0abce112bcef78ff16737e08facc.png-wh_500x0-wm_3 -wmp_4-s_1697995224.png "title=" screenshot from 2017-11-01 19-28-20.png "alt=" D28b0abce112bcef78ff16737e08facc.png-wh_ "/>
#
#/etc/fstab
# Created by Anaconda on Wed 7 01:22:57 2014
#
# Accessible filesystems, by reference, is maintained under '/dev/disk '
# See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info
#
UUID=9BF6B9F7-92AD-441B-848E-0257CBB883D1/XFS Defaults 1 1
/dev/vdb1/mnt XFS Defaults 0 0
Device Mount location File system type 0 backup 0 check



Second, add swap swap partition

The swap space or swap area is the space on the disk drive that is used as an overflow that is not currently using partial memory. This allows the system to allow space in the main memory to store the data that is currently being processed and to provide an emergency overflow when the system is at risk of running out of main memory space

1. Add partitions the same way, after creating a new partition, set

Figure: T add partition function Id,l view partition function each ID


Figure: Set the Swap function ID of the partition, save the changes to the hard drive, refresh


Figure: Swap type file format device, becomes available swap device

2. Managing Swap Partitions
Use Fdisk to create a new partition. Also, change the partition type to "0x82 Linuxswap" before you save the changes with Fdisk
Mkswap/dev/vdan will be ready to use the partition as a swap area.
Blkid/dev/vdan will determine the UUID
Add new swap space to/etc/fstab:uuid=uuid swap swap defaults 0 0
SWAPON-A will activate the new swap area
Swapon-s will display the status of the current swap area
Swapoff/dev/vdan will deactivate the specific swap area
[Email protected] ~]# swapon-a/dev/vdb[1,2]# #激活/DEV/VDB1 and vdb2 swap area
[Email protected] ~]# swapon-s# #显示当前交换区的状态
Filename Type Size used priority# #Filename文件名, type, size, used used size, Priorty priority
/DEV/VDB1 Partition 102396 0-1
/DEV/VDB2 Partition 102396 0-2

Third, disk encryption protection

1. Recognize
LUKS (Linux Unified key setting) is the standard device encryption format
LUKS can encrypt a partition or volume
The encrypted volume must first be decrypted to mount the file system

2. Steps
1> creating a new partition with Fdisk

2> Cryptsetup Luksformat/dev/vdan to encrypt the new partition and set the decryption password

[Email protected] ~]# Cryptsetup LUKSFORMAT/DEV/VDB1

warning!
========
This would overwrite data on/dev/vdb1 irrevocably.

Is you sure? (Type uppercase Yes): Yes
Enter Passphrase:
Verify Passphrase:


3> you enter the correct decryption password, Cryptsetup Luksopen/dev/vdan name unlocks the encrypted volume/dev/vdan to/dev/mapper/name
Illustration:

Create XFS file system on 4> decrypted volume: Mkfs-t xfs/dev/mapper/name
Illustration:

5> Create a directory mount point and mount the file system: MKDIR/MNT
–mount/dev/mapper/name/mnt


After the 6> is complete, umount/dev/mapper/name and run Cryptsetup luksclose name to lock the encrypted volume


This article is from the "13342594" blog, please be sure to keep this source http://13352594.blog.51cto.com/13342594/1978199

Simple partitioning and management in the linux--system

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.