Fdisk,sfdisk,part
Fdisk <= 15 partitions
fdisk-l [DEVICE]
fdisk [DEVICE]FDISK/DEV/SDA
Interactive commands:
D: Delete a partition
N: Create a new partition
P: Displays the current partition information
W: Save and exit
Q: Do not save exit
L: The system ID corresponding to each partition type;
83:linux
82:linux swap, swap partition
8e:lvm
Fd:soft Raid
T: Modify the system ID of the specified partition;
# cat/proc/partitions View the partition information identified by the kernel
Partprobe [DEVICE]: RHEL5 let kernel re-read hard disk partition table
partx-a [PARTITION] device:rhel6 allow kernel to reread hard disk partition table
Partx-a/DEV/SDA4/DEV/SDA
Next: Format the partition for creating the file system
LINUX,MKFS Formatting partitions
Mkfs-t fstyp/dev/partmkfs-t ext4/dev/sda4
Important: 1, the file system must be supported by the kernel to use, that is, the kernel has a corresponding kernel module, or has been integrated into the kernel
2, should have the corresponding file system creation tool, usually is mkfs,fstype
Rhel5:ext3
Rhel6:ext4
Mkfs-t Ext4 = MKFS.EXT4 = Mke2fs-t Ext4 =
Mkfs-t ext3 = Mkfs.ext3 = Mke2fs-j = Mke2fs-t ext3
Mkfs-t ext2 = mkfs.ext2 = MKE2FS = Mke2fs-t ext2
Profiles:/etc/mke2fs.conf, user-defined default features, and individual file system-specific features
mke2fs-t {EXT2|EXT3|EXT4}
-B {1024|2048|4096}: Block size
Block size depends on CPU support for memory page frame size, x86 system default Page box size is 4k
-L Label: Set Volume label
-M N: The proportion of the total space occupied by the block that is reserved for management use: n%
-R N: The number of blocks reserved for management use: N
-E: Setting extended properties of the file system
Tune2fs
-L: Display file system Super Block information tune2fs-l/dev/sda4
-L Label: re-set the volume label
-M N: Adjust the ratio of the total space occupied by the block reserved to the managed use: Change to n%
-R n: Adjust the number of blocks reserved for administration to use: N
-o: Set mount default option
-o: Set file system default features
-E: Adjusting extended properties of the file system
Tune2fs-l DEVICE | grep "Block Size": To display block sizes
E2abel: Displays or sets the volume label:
E2abel DEVICE [Volume_label]
Blkid device: Display the UUID and file system type
Mount Mount mounts [-t fstype] DEVICE Mount_point
-O: Used to specify mount options, common mount options
RO: Read-only Mount
RW: Read-write, read-write by default
Noatime: Turn off update access time
Auto: Can be mounted by "mount-a"
Defaults: equivalent to Rw,suid,dev,exec,auto,nouser,async,and relatime
Sync: Synchronous Write
Async: Asynchronous Write
Dev: Whether to allow the use of device files under this file system
Nodev
Remount: Re-mount
Loop: Local loopback device
-N: Do not update the/etc/mtab file when mounting the file system
-R: Equivalent to "-O ro", read-only Mount
Mount-o remount,other_options DEVICE
Mount-o loop,other_options device Mount_point for mounting loopback devices
Monut-t iso9660-o loop/root/centos-6.6-x86_64-bin-dvd1.iso/mnt/cdrom #把CentOS ... Mount to CDROM
Mount [-t Fstype] label= "Volume label" mount_point
Mount [-t Fstype] uuid= "UUID" Mount_point
# Mount #用这个命令会显示当前系统挂载的所有设备
Umount DEVICE
# UMOUNT/DEV/SDB3
Umount Mount_point
# Umount/media
After mounting, the original data will be hidden, so it can not be hung on the system common directory, will mount the uninstall, the original data will be displayed
When uninstalling, make sure no process is accessing the mounted device, otherwise it cannot be uninstalled
/etc/fstab: System will automatically mount the file system on boot
Fuser [Mount_point]: Viewing a process that is accessing a mount point
# fuser/media/
fuser-km [Mount_point]: Forcibly closes the process that is accessing this mount point
# fuser-km/media/
Swap partition for Linux: Swap
Must be a separate partition, separate file system
How big is the swap partition?
Scientific Computing Class Server: Swap memory can be as large as possible, such as twice times the physical memory
Application Class Server: Swap memory as small as possible, for example, only 1G
Physical memory is less than or equal to 2g,swap=memory*2
2G<MEMORY<4G, swap=memory*1.5
MEMORY>4G, swap=4g
How to view memory size:
Free Displays system usage and idle memory conditions, including physical memory, interactive area memory (swap), and kernel buffer memory
-M: Conversion of memory space size to MB
-G: Memory space size conversion to GB
gkfx: Shared memory
Buffer: Buffering
Cached: Caching
Mkswap DEVICE: Creating a Swap partition
-L label setting label
# mkwsap-l Newswap/dev/sda6
Swapon Enable swap partition:
Swapon DEVICE: Enable the specified swap partition
# Swapon/dev/sda6
SWAPON-A Enable all swap partitions
Swapoff DEVICE Disables swap partition
Swapoff-a
Auto enable swap partition on boot, can be defined in/etc/fstab
DEVICE swapswap defaults 0 0
mount point: Swap
File system type: Swap
DUMPE2FS: Output ext File System Information
-H: Show information about the super block
Du:disk usage
-s:summary, showing the sum of the sizes of all files under a specified path
-h:human-readable
Df:disk Free
-L: Show only information about the local file system
-H:
-p:posix-compatible style display
-I: Display inode usage information
New Hard disk
Creating partitions
Modify partition type T8e
Before you can create a physical volume pvcreate/dev/sdb{1,2}
Create Volume group vgcreate myvg/dev/sdb{1,2}
Create Logical Volume Lvcreate-l 10g-n mylv myvg-L Specify size-n Specifies the name of the logical volume
View the logical Volume LVS
Formatted mkfs.ext4-l mydata/dev/myvg/mylv
Lvm:logical Volume
PV: Physical Volume VG: Volume Group LV: Logical Volume
1. Logical Volume creation
PV-->VG-->LV
Pvcreare/dev/sdb5
Pvdisplay/dev/sdb5
PVs
Vgcreate VGNAME/DEV/SDB5 ...
-S PE
Vgdisplay
VGs
Lvcreate-l size-n-lv_name Vg_name
Number of-L PE
Lvdisplay
Lvs
Device files for logical volumes:/dev/vg_name/lv_name
/dev/mapper/vg_name-lv_name
/dev/mapper/testvg-mylv
2. Extended VG
First, prepare a PV.
Use the Vgextend command to complete the extension: Vgextend VG_NAME/PATH/TO/PV
3. Reduction of VG
Determine the PV to remove
Transfer data on this PV to other PV:PVMOVE/PATH/TO/PV
To remove this PV from the volume Group: Vgreduce VG_NAME/PATH/TO/PV
4. Extending the logical Volume
How big is the extension? 5G:-8G
Determine if the volume group that contains the current logical volume has enough free space:
Extensions:
1. Physical boundary: Lvextend-l [+]SIZE/PATH/TO/PV
2. Logical boundary: Resizefs/path/to/device
File System Detection:
fsck
e2fsck [-t fs_type] [-f] [-p]/path/to/device
5. Reduce the logical volume
How much are you sure to reduce? The premise is that you can at least accommodate all of the original data.
8G-3G
Reduction:
1, uninstall and forcibly detect the file system: E2fsck-f
2. Logical Boundary: Resize2fs/path/to/device SIZE
3. Physical boundary: Lvreduce-l [-]SIZE/PATH/TO/LV
6. Snapshot volume
Lvcreate
-S: Snapshot volume
-P R: Restrict snapshot volumes to read-only access
lvcreate-l size-s-P r-n lv_name/path/to/lv
7. Remove the logical Volume:
LVREMOVE/PATH/TO/LV
8. Remove the volume group
VGREMOVE/PATH/TO/VG
This article is from the "three elder brother" blog, please be sure to keep this source http://523958392.blog.51cto.com/9871195/1617632
Device Management Common commands