Linux Fundamentals 05

Source: Internet
Author: User


Tracks: Track

Sector: Sector 512 bytes

Head: Head

Cylinder: Cylinder


Identify the hard disk and partition Plan = + format and mount using


Mbr/msdos partition mode

–1~4 primary partition, or 0~3 primary partition + one extended partition (n

Logical partitions)

– Maximum supported disks with a capacity of 2.2TB

– Extended partitions cannot be formatted


First, check that there are currently those disks


[Email protected] ~]# ls/dev/vd*

[Email protected] ~]# lsblk


Ii. Division of partitions


View Partition Table

[Email protected] ~]# fdisk-l/DEV/SDA


[Email protected] ~]# FDISK/DEV/VDB


Common Interactive directives:

M list instructions Help

P View the existing partition table

N New Partition

D Delete Partition

Q Discard Changes and exit

W Save changes and exit


# LS/DEV/VDB

# LSBLK


Third, the format of

MKFS Tool Set

–MKFS.EXT3 Partition Device Path

–MKFS.EXT4 Partition Device Path

–MKFS.XFS Partition Device Path

–MKFS.VFAT-F 32 Partition Device path


[Email protected] ~]# MKFS.EXT3/DEV/VDB1

[Email protected] ~]# MKFS.EXT4/DEV/VDB2 #此为常用项

[Email protected] ~]# MKFS.XFS/DEV/VDB3



Iv. Mounting and use

[Email protected] ~]# Mkdir/part1

[Email protected] ~]# Mkdir/part2

[Email protected] ~]# MKDIR/PART3

[Email protected] ~]# Mount/dev/vdb1/part1

[Email protected] ~]# Mount/dev/vdb2/part2

[Email protected] ~]# MOUNT/DEV/VDB3/PART3


V. Viewing mount Usage

[Email protected] ~]# df-h



When a partition needs to be swapped for a mount point and retains the contents of the directory


[Email protected] ~]# #mount/dev/vdb5/mnt

[Email protected] ~]# #cp-R/home/*/mnt/

[Email protected] ~]# #rm-rf/home/*

[Email protected] ~]# #umount/mnt/

[Email protected] ~]# #mount/dev/vdb5/home






# FDISK/DEV/VDB

[Email protected] ~]# ls/dev/vdb*

[Email protected] ~]# Partprobe #刷新分区表

[Email protected] ~]# ls/dev/vdb*

[Email protected] ~]# lsblk

####################################################

Boot Auto Mount/etc/fstab


– Device path mount point type parameter backup mark detection order


/dev/vdb3/part3 XFS Defaults 0 0

/dev/vdb2/part2 EXT4 Defaults 0 0



Add: Blkid View partition UUID file system

[Email protected] ~]# Vim/etc/fstab

[Email protected] ~]# Tail-2/etc/fstab


/dev/vdb3/part3 XFS Defaults 0 0

/dev/vdb2/part2 EXT4 Defaults 0 0



[Email protected] ~]# mount-a

Detect/etc/fstab Boot automatically mount profile, format is correct

Detects/etc/fstab, writes complete, but does not currently mount the device, mounts

[Email protected] ~]# df-h


#####################################################

General idea of partition operation

1. LSBLK View Hard Drive information

2. Fdisk partitioning

3. Partprobe refresh the new partition table

4. MKFS.XFS formatted partition

5. Mount Mount Test

6./etc/fstab Boot automatically mount


###################################################


LVM logical Volumes


1. Managing Scattered spaces

2. Extended domain reduction for logical volume dynamics

A number of physical volumes (PV) are first formed into a volume group (VG), in which logical volumes (LVS) are divided from the volume group


##################################################

First, create physical volumes and volume groups


Vgcreate Volume Group name partition


[Email protected] ~]# vgcreate Myvg/dev/vdc[1-2]

[Email protected] ~]# PVs #显示物理卷基本信息

[Email protected] ~]# VGS #显示卷组基本信息


Ii. Creating a logical volume


Lvcreate-l Logical Volume Size-n Logical volume name of the volume group

[Email protected] ~]# VGS

[Email protected] ~]# lvcreate-l 16g-n mylv MYVG

[Email protected] ~]# VGS

[[email protected] ~]# LVS


Third, use the logical volume LV

[Email protected] ~]# MKFS.EXT4/DEV/MYVG/MYLV

[Email protected] ~]# MKDIR/LVM

[Email protected] ~]# Vim/etc/fstab

/DEV/MYVG/MYLV/LVM EXT4 Defaults 0 0


[Email protected] ~]# mount-a

[Email protected] ~]# df-h


###################################################


Logical volume expansion, support for on-line operations


One, the volume group has enough space left

1. Directly extend the space of the logical volume

[Email protected] ~]# VGS

[[email protected] ~]# LVS

[Email protected] ~]# lvextend-l 18G/DEV/MYVG/MYLV

[[email protected] ~]# LVS

[Email protected] ~]# VGS


2. Size of the extended file system

Extension ext4 file system: Resize2fs/dev/myvg/mylv #常用

Extended XFS File system: XFS_GROWFS/DEV/MYVG/MYLV


[Email protected] ~]# df-h

[Email protected] ~]# RESIZE2FS/DEV/MYVG/MYLV

[Email protected] ~]# df-h



Second, the volume group does not have enough space left

1. Expand the volume group first

[Email protected] ~]# VGS

[[email protected] ~]# LVS

[Email protected] ~]# vgextend MYVG/DEV/VDC3

[Email protected] ~]# VGS


2. Directly extend the space of the logical volume

[Email protected] ~]# VGS

[[email protected] ~]# LVS

[Email protected] ~]# lvextend-l 25G/DEV/MYVG/MYLV

[[email protected] ~]# LVS

[Email protected] ~]# VGS


3. Size of the extended file system

[Email protected] ~]# df-h

[Email protected] ~]# RESIZE2FS/DEV/MYVG/MYLV

[Email protected] ~]# df-h


####################################################

Set PE size when creating a volume group

–vgcreate-s PE Size Volume group name free partition ...


PE: The default unit of volume group partition space, 4M can be changed artificially


Lvcreate-l PE number-n test Volume group name


[Email protected] ~]# vgchange-s 1M MYVG


[Email protected] ~]# Vgdisplay MYVG


[Email protected] ~]# lvcreate-l 50-n test MYVG


[[email protected] ~]# LVS


###################################################

Managing Swap Space


Equivalent to virtual memory,

– Use disk space to simulate memory when physical memory is not sufficient

– To some extent alleviate the problem of low memory

– Swap partition: Swap space acting as an idle partition


[Email protected] ~]# MKSWAP/DEV/VDC5 #格式化SWAP命令

[Email protected] ~]# swapon-s #查看SWAP状态

[Email protected] ~]# SWAPON/DEV/VDC5 #启用交换空间

[Email protected] ~]# swapon-s


[Email protected] ~]# MKSWAP/DEV/VDC6

[Email protected] ~]# SWAPON/DEV/VDC6

[Email protected] ~]# swapon-s


[Email protected] ~]# SWAPOFF/DEV/VDC5 #停用交换空间

[Email protected] ~]# swapon-s

[Email protected] ~]# swapoff/dev/vdc6 #停用交换空间

[Email protected] ~]# swapon-s


#############################################


Auto mount on Boot

[Email protected] ~]# Vim/etc/fstab

/DEV/VDC5 swap swap defaults 0 0


[Email protected] ~]# swapon-a #专用于检测swap分区

[Email protected] ~]# swapon-s


[Email protected] ~]# blkid/dev/vdc6 #查看设备UUID的信息

[Email protected] ~]# Vim/etc/fstab


Uuid= "5bbbb9cf-bb65-4b55-80b0-c54b722c2759" swap swap defaults 0 0


[Email protected] ~]# swapon-s

[Email protected] ~]# swapon-a

[Email protected] ~]# swapon-s



Linux Fundamentals 05

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.