Linux Disk Management
HDD :
Mechanical hard-disk
SSD Solid State Drive
Mechanical Type:
Track tracks
Sector sector: 512bytes
Cylinder cylinder: The basic unit of the partition;
MBR:Master Bootrecord
512bytes
446:bootloader
64:filesystem Allocation table
: identify a partition
2:55AA
Disk interface type:
IDE (ATA):133mb/s,/DEV/HD
scsi:640mb/s
SATA:6Gbps
SAS:6Gbps
USB:480mb/s
identify the hard drive device:/DEV/SD
mark a different hard drive device:/dev/sd[a-z]
mark different partitions on the same device:/dev/sd[a-z][1-]
1-4: primary or extended partition identification
5+: Logical partition Identification
device files: Special files
Device Number:
Major,minor
Major: Device type
Minor: different devices under the same type
"Block":block, random device
"character":character, linear device
Gpt:guidpartition Table
partitioning: Separates the storage space into multiple small spaces, each of which can use the file system independently;
Partitioning Tools:
fdisk,parted, Sfdisk
use of the Fdisk tool:
supports up to a maximum of four partitions on a single hard drive;
Partition Management sub-command:
P: Display
N: Create
D: Delete
T: Modify the partition ID
L: List all support ID types
W: Save exit
Q: Discard changes and exit
M: Get help
after the creation is complete, check to see if the kernel has identified the new partition:
#cat/proc/partitions
There are three commands that allow the kernel to reread the disk partition table:
Centos5:partprobe [DEVICE]
centos6,7:
Partx
Kpartx
partx command:
Partx DEVICE
Partx-a DEVICE
Register all partition information on a disk, and if a partition information is already logged, an error will be made.
If the partition information on a disk is not logged, then quiet is complete.
Partx-a-N m:n DEVICE records the first M to n partition information
m read into section m partition information
M: Specifies the minimum value of the read-in partition number
: N Specifies the maximum value of the read-in partition number
Kpartx Command:
Kpartx-af DEVICE
Linux File System Management
File System:
VFS:Virtual FileSystem
Linux:ext2, EXT3,EXT4, ReiserFS, XFS, Btrfs, swap
Disc:iso9660
Windows:fat32 (VFAT), NTFS
Unix:ffs, UFS, JFS, JFS2
Network File system:nfs,cifs
Cluster File system:OCFS2,GFS2
Distributed File systems:Ceph,
Moosefs,mogilefs, HDFs, GFS, Glusterfs
(1) journaled File System
non-journaled file system:ext2
journaled File system:ext3
(2) Swap: Swap partition
To create a file system:
perform formatting on a partition ( Advanced Format )
to use a file system, two conditions are met:
Kernel: Support for this file system
User space: There are file System management tools
Create tool:MKFS (make filesystem)
MKFS-T type DEVICE
Mkfs.typedevice
MKFS [tab][tab] View MKFS supported file formats
Special management tools for the EXT series file system:
mke2fs-t {EXT2|EXT3|EXT4} DEVICE
-B block:1024, 2048, 4096 specify block size
-L ' LABEL ': set the volume label name
Blkid Command:
Blkid DEVICE
Label,uuid, TYPE
Example:
[[email protected]]# fdisk -l /dev/sda disk /dev/sda: 128.8 gb, 128849018880bytes, 251658240 sectorsunits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes /512 bytesi/o size (Minimum/optimal): 512 bytes / 512bytesdisk label type: Dosdisk identifier: 0x000c2314 device boot start End Blocks Id System/dev/sda1 * 2048 411647 204800 83 linux/ dev/sda2 411648 41371647 20480000 83 linux/dev/sda3 41371648 61851647 10240000 83 Linux/dev/sda4 61851648 251658239 94903296 5 Extended/dev/sda5 61855744 82335743 10240000 83 Linux/dev/sda6 82337792 86532095 2097152 82 linux swap / solaris# Create a new 10G partition command (m for help): Nall primary partitions are in useadding logical partition 8first sector (86534144-251658239, default 86534144): using default value 86534144last sector, +sectors or +size{k,m,g} (86534144-251658239, default 251658239): + 10gpartition 8 of type linux and of size 10 gib is set# Delete 8th partition command (M FOR HELP): dpartition number (1-8, default 8): 9^h8partition number (1-8, default 8): 8partition 8 is deleted# The new partition is not mounted [[email protected] test]# cat /proc/partitionsmajor minor #blocks name 8 0 125829120 sda 8 1 204800 sda1 8 2 20480000 sda2 8 3 10240000 sda3 8 4 1 sda4 8 5 10240000 sda5 8 6 2097152 sda6 11 0 651264 sr0 #重读分区信息 [[email protected] test]# partx /dev/sda[[email protected] test]# cat /proc/partitionsmajor minor #blocks name 8 0 125829120 sda 8 1 204800 sda1 8 2 20480000 sda2 8 3 10240000 sda3 8 4 1 sda4 8 5 10240000 sda5 8 6 2097152 sda6 8 7 1024 sda7 8 8 10485760 sda8 11 0 651264 sr0 # Format Disk mkfs Format The sda8 you just created as xfs format [[email protected] test]# mkfs -t xfs /dev/sda8meta-data=/dev/sda8 isize=256 agcount=4, agsize=655360 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0data = bsize=4096 blocks=2621440, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype= 0log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count =1realtime =none extsz=4096 blocks=0, rtextents=0# View partition Format [[email Protected] test]# blkid /dev/sda8/dev/sda8: uuid= "5515906f-6e7b-4895-b9cf-c9214e16e7d5" type= "XFS"
If there is any mistake, please correct me!
Thank you!
Linux Disk Management