Linux Disk Management
Hard disk:
Mechanical HDD
SSD solid-State drives
Track
Sector:512bytes
Cylinder: The basic unit of the partition;
MBR : Master Boot Record
512bytes 446:bootloader 64:filesystem allocation table: identifies 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
" blocks ": block, Random device
" character ": Character, linear device
Partitioning: Separates the storage space into multiple small spaces, each of which can use the file system independently;
Partitioning tools: fdisk, parted, Sfdisk
fdisk tool Usage: Supports up to 15 partitions on one hard drive;
Partition Management sub-command:
P: Show
N: Create
D: Delete
T: Modify 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:
CentOS 5:partprobe [DEVICE]
CentOS 6 or 7:partx,kpartx
Partx command:
Partx DEVICE
Partx-a DEVICE
Partx-a-N m:n DEVICE
M
M:
: N
Kpartx command:
Kpartx-af DEVICE
Linux File System Management
File system:
VFS : Virtual File System
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 formatting)
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 Usage:
MKFS-T type DEVICE
Mkfs.type DEVICE
ext dedicated management tools for series file systems:
mke2fs-t {EXT2|EXT3|EXT4} DEVICE
-B block:1024, 2048, 4096
- l ' LABEL ': set the volume label
Blkid command:
Blkid DEVICE
LABEL, UUID, TYPE
Homework:
1. allow ordinary users to use/tmp/cat to view/etc/shadow files;
[Email protected] ~]# cp/usr/bin/cat/tmp/
[Email protected] ~]# cd/tmp/
[Email protected] tmp]# chmod u+s Cat
[email protected] tmp]# su tgy
[Email protected] tmp]$/tmp/cat/etc/shadow
2. Create a directory/test/data, let a group of ordinary users have write permissions to it, and all the files created by the group is the directory belongs to the group, in addition, each user can only delete their own files;
[Email protected]/]# mkdir-p/test/data
[Email protected]/]# chmod g+w/test/data/
[Email protected]/]# chmod g+s/test/data/
[Email protected]/]# chmod o+t/test/data/
How to use Linux Disk Management, file system and related commands