Linux Disk Management, new disks, partitions, mounts

Source: Internet
Author: User
Tags disk usage

1. Du-sh View directory, total file size
-A: All files and directory sizes are listed. If you do not add any options and parameters, only the size of the table of contents (including subdirectories) is listed.
-C: Last add total
2. Df-h View disk usage
3. LSBLK View System block device information
Blkid viewing the UUID of a disk partition

3. Free system memory and virtual memory usage
The-M option is viewed in m form

4. Fuser-km/home terminate all processes that use the directory

5. Mount/dev/sdc1/home Mount SDC1 to/home node
UMOUNT/DEV/SDC1 Uninstalling/DEV/SDC1

6.FDISK-L list the partition table for all/specified disk devices
FDISK/DEV/SDC into disk partition operation: M P N d w q
M menu
P Print the partition of the current disk
n re-establish a new partition: E (Extended extended partition) or P (primary partition primary partition)
W save operation.
Q Exit.
D Delete a partition
Example: FDISK/DEV/SDC
P Printing
N New
Option number: 2
Select p Main/E extension: P
Allocation Size: Enter all assigned
W Save
Partprobe immediate effect

Note: The primary partition is up to 4, the extended partition is 1, and the extended partition can be partitioned again as a logical partition
Re-partitioning allows the new partition to take effect without restarting the computer: Partprobe

7.mkfs formatting
mkfs.ext2/mkfs.ext3/mke2fs formatting Linux hard disk partitions
Mkfs-t ext3/dev/sda1

Common options are:
- B: Set the space size per data block when partitioning, currently supports 1024, 2048 and 4096 bytes per block.
-I: Set inode size
-N: Sets the number of inode, sometimes using the default inode number is not enough, so you have to set the inode number.
-C: Detect the disk before formatting the problem, plus this option will be very slow
-L: Default label for this partition label
-j: Build ext3 format partition, if you use MKFS.EXT3 do not add this option
Example:
MKFS.EXT3/DEV/HDB1 Direct format/dev/hdb1
mkfs.ext3-b 4096-i 4096/dev/hdb2 Set node number and block size
Mkfs.ext3-l LABEL3/DEV/HD B3 Add a label
E2LABEL/DEV/HDB3 to view or modify a partition's label (label)

8.fsck Check that the hard drive has no bad way
-A: All partitions (the operation is performed once during boot);
-A : Automatic repair checks to the problematic partition,
-r: When a partition with a bad path is checked, the user is asked to decide whether to fix it.

9./etc/fstab the partition that needs to be mounted when the system starts
Columns: Partition label, mount point, format, mount parameter, whether dump, whether to boot detect disk
Mount Parameters:
Async/sync:async indicates that it is not synchronized with the disk and memory, and the system writes the memory data to disk at intervals, while sync synchronizes the memory and disk data at all times;
Auto/noauto: Boot automatically mounted/not automatically mounted;
Default: Set the mount definition according to the default value of most permanent file system, it contains RW, suid, dev, exec, auto, Nouser,async;
RO: Mount by read-only permission;
RW: Mount According to readable writable permission;
Exec/noexec: Allow/Do not allow executable file execution, but do not mount the root partition as NOEXEC, then can not use the system, even mount command can not be used, at this time only to re-do the system;
User/nouser: Allow/Do not allow other users to mount the partition outside the root, for security purposes, please use nouser;
Suid/nosuid: Allow/Disallow partition has suid attribute, general setting nosuid;
Usrquota: Start Consumer disk quota mode, disk quota related content in the following chapters will be introduced;
Grquota: Start the group disk quota mode;

Example:/etc/fstab add a row to mount the new partition. For example, the author adds such a line
/dev/hdb1/test1ext3defaults0 0
The partition will then be mounted when the system restarts.

9. Mount/unmount Disk
Mount: Mount
Mount/dev/sdb1/home
-A All disks
-o option: Mount-o remount,rw,sync,noauto/dev/hdb1/test1
UUID mounted on UUID (Blkid uuid): Mount Uuid= "d233432fsf23fdfsf3e"/test1
-T specify file system: Mount-o remount-t Ext3/dev/hdb1/test1

Umount: Uninstalling
UMOUNT/DEV/HDB1: Uninstall according to partition
Umount/test1: Unloading according to mount point
Umount-l/DEV/HDB1: Forced uninstallation


--------------------------------------------------------
10. Create swap Files
1. Use DD to create a 419M file/tmp/newdisk out, where if represents the file from which to read,/dev/zero is a Linux-specific 0 generator, of which the output to which file, BS is the block size, count defines how many blocks.
DD If=/dev/zero Of=/tmp/newdisk bs=4k count=102400
2.mkswap formatted swap partition: Mkswap/tmp/newdisk
3.free-m viewing memory and virtual partitions
4.swapon/tmp/newdisk Enabling partition files
5.swapoff/tmp/newdisk closing a partition file


11. Disk Quotas Quota
Quota Quotacheck quotaoff Quotaon quotastats edquota setquota Warnquota Repquota
1.quata display group, user's limit
Syntax: quota [-guvs] [User,group]
-G: Show limits for a group
-U: Displays the limit for a user
-V: Meaning of the display
-S: Select Inod or hard disk space to display

2.quotacheck is used to scan the quota space of a particular disk.
Syntax: Quotacheck [-AUVG]/path
-A: Scans all already-mount disks with quota support
-U: Scan a user's files and directories
-G: Scan a group of files and directories
-V: Shows the scanning process
-m: Force a scan

3.edquota is used to edit the quota value of a user or group.
Syntax: Edquota [-u user] [-G Group] [-T]
Edquota-p user-u User
-U: Edit a user's quota
-G: Edit the quota of a group
-T: Editing a wide time limit
-P: Copy the Quta of a user or group to another user or group
When you run Edquota-u user, the system opens a file:
Column 1. Filesystem: Disk partitions, such as/dev/hda3
2.blocks: The current user's disk capacity in the current filesystem, in kilobytes.
3.soft/hard: The quota value of the current user in the filesystem, soft refers to the minimum limit, can exceed this value, but must be within the grace time to reduce the disk capacity below this value. Hard refers to the maximum limit, that is, the value cannot be exceeded. When the user's disk usage is higher than the soft value, the system warns the user that it wants to lower the usage space to the soft value within the grace period.
4.inodes: The state of the inode that is currently used, without modification.

4.quotaon start quota, after editing good quota, need to start to be quota effective
Syntax: Quotaon [-A] [-UVG directory]
-A: All set quota start
-U: Start a user's quota
-G: Start a quota of a group
-S: Show related information

5.quotaoff off Quota
Quotaoff-a Close all the quota


Quick Review
##################
To add a disk partition:
1.df-sh Current Disk partition mount point usage
2.FDISK-L list the partition table for the disk device (total disk, allocated)
3.fdisk/dev/sdb into disk partition operation
P Printing
N New
Option number: 1
Select p Main/E extension: P
Allocation Size: Enter all assigned
W Save
DISK/DEV/SDB Division produced the/DEV/SDB1
Partprobe immediate effect
4.MKFS.EXT3/DEV/SDB1 Direct formatting of/dev/sdb1 or
Mkfs-t EXT3/DEV/SDB1
5./etc/fstab adding/DEV/SDB1/HOMEEXT3DEFAULTS0 0
6.mount/dev/sdb1/home/tt/app Mount
7.LSBLK viewing system block device information

Linux Disk Management, new disks, partitions, mounts

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.