Linux Common Commands (4)-Disk Management __linux

Source: Internet
Author: User
Tags centos disk usage file permissions
In addition to the actual contents of the file, the 帯 has many 帯 attributes, such as file permissions (rwx) and file attributes (拞, group, time parameters, etc.) of the Linux operating system.
The file system stores these two data in separate blocks, and the permissions attribute is placed in the inode, where the actual data is placed into the data block blocks. In addition, there is a super block (Superblock) will be recorded 彔 the whole
The overall information of the file system, including the total amount of the inode, the amount of usage, the amount of surplus.
Each inode and block are numbered, and the meaning of the three data can be briefly described as follows:
Superblock: Record The overall information of this filesystem, including the total amount of inode/block, usage, surplus, and the format of the file system not relevant information, etc.
Inode: 彔 The attributes of a file, a file occupies an inode, and 彔 The block number of the data in this file;
Block: Actually remember the contents of the 彔 file, if the file is too large, will occupy multiple blocks.
Simple operation of File system
#df-K Lists the overall disk usage of the file system. The unit is k, optional parameters [k],[m],[i]inodes display inode information. DF Main read 叏 data is almost all for an entire file system, so the reading range is mainly within the Superblock letter
Interest.
# df-m/home
FileSystem 1m-blocks Used Available use% mounted on
/dev/sda8 12084 4833 6638 43%/home

#du-K evaluates the amount of disk usage for a file or directory. optional parameter [K],[m],[s] represents summation output total capacity only
# du-k/home/chenlly/eclipse/configuration
104/home/chenlly/eclipse/configuration/org.eclipse.equinox.simpleconfigurator
8/home/chenlly/eclipse/configuration/org.eclipse.equinox.source
36/home/chenlly/eclipse/configuration/org.eclipse.update
156/home/chenlly/eclipse/configuration

If you just want to know how much total capacity the 彔 occupies, use-s
# du-s/home/chenlly/eclipse/configuration
156/home/chenlly/eclipse/configuration
#df-H to see how much space is left on the disk
#du-sh * You need to know the disk usage under the current folder
# Mount Loading File system
The concept to be clear before you figure out the mount:
Devices generally in the/dev directory/dev/hda1 HD indicates that the floppy disk ETH network device (eth0 first network device) a identifies the first device, typically one device interface can receive four devices (such as four hard drives), 1 represents the first partition, So HDB2 represents the second partition of the second hard drive.
Mount-t Vfstype Displays the type of file system being loaded
For example, to access the contents of the CD-ROM, you need to mount the CD-ROM device under a file, Linux can identify the following file system
Fat32:vfat
Ntfs:ntfs
cd-rom:iso9660
Linux file system: EXT2 EXT3
Application: Mount-t Iso9660/dev/hdc/mnt/cdrom to mount the CD-ROM under Mnt/cdrom, generally under MNT have the following directory: Mnt/cdrom,mnt/floppy
For example, using Mount C to mount Windows, first create a new winc directory under MNT
mkdir Winc
Mount-t Vfat/dev/hda1/mnt/winc
Unmount Uninstall File system
Unmount/cdrom
Eg:centos mount a new hard drive
1. View current hard drive usage:
Df-h
2. To view the new hard drive, the DISK/DEV/SDA 4T hard drive is required to be mounted.
#fdisk –l

Device Boot Start End Blocks Id System
/DEV/SDB1 * 1 512000 Linux
Partition 1 does not end on cylinder boundary.
/DEV/SDB2 36405 291908608 8e Linux LVM

disk/dev/sda:4000.8 GB, 4000787030016 bytes
255 heads, Sectors/track, 486401 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk IDENTIFIER:0XA820DBCE

disk/dev/mapper/volgroup-logvol01:264.6 GB, 264551530496 bytes
255 heads, Sectors/track, 32163 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

disk/dev/mapper/volgroup-logvol00:34.4 GB, 34359738368 bytes
255 heads, Sectors/track, 4177 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

3, hard disk partition, because CentOS can only mount 2T. All 4T needs are divided into two districts
#sudo FDISK/DEV/SDA
Command (M for help): M
(1), input m into the Help interface
Command Action
A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS compatibility flag
D Delete a partition
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
U Change display/entry units
V Verify the partition table
W Write table to disk and exit
X Extra functionality (experts only)

(2), Input n Add partition
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
(3), select the number of partitions
Partition number (1-4): 2
(4) Set the cylinder, where you can choose the default value
Cylinder (267350-486401, default 267350): 267350
Last cylinder, +cylinders or +size{k,m,g} (267350-486401, default 486401): 486401

4. Mount Partition
# Fdisk-l View Zoning

Device Boot Start End Blocks Id System
/DEV/SDB1 * 1 512000 Linux
Partition 1 does not end on cylinder boundary.
/DEV/SDB2 36405 291908608 8e Linux LVM

disk/dev/sda:4000.8 GB, 4000787030016 bytes
255 heads, Sectors/track, 486401 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk IDENTIFIER:0XA820DBCE

Device Boot Start End Blocks Id System
/DEV/SDA1 1 267349 2147480811 Linux
/dev/sda2 267350 486401 1759535190 Linux

disk/dev/mapper/volgroup-logvol01:264.6 GB, 264551530496 bytes
255 heads, Sectors/track, 32163 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

disk/dev/mapper/volgroup-logvol00:34.4 GB, 34359738368 bytes
255 heads, Sectors/track, 4177 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

Found more than two partitions of/dev/sda1 and/DEV/SDA2
(1), new directory MAPHD1 and MAPHD2 for mounting/dev/sda1 and/dev/sda2 two partitions
(2), before the mount of the first format
# MKFS.EXT4/DEV/SDA1
# Mkfs.ext4/dev/sda2
(3), separately mounted
# MOUNT/DEV/SDA1/MAPHD1
# MOUNT/DEV/SDA2/MAPHD2

5. Set up the boot up automatic mount
The newly created partition is not automatically mounted, and is manually mounted each time the machine is restarted.
Setting up automatic mount requires modifying/etc/fstab files
#vi/etc/fstab
Add a row at the end of a file
/DEV/SDA1/MAPHD1 EXT4 Defaults 1 2
/DEV/SDA1/MAPHD1 EXT4 Defaults 1 2

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.