Linux Basics-Hard disk partitioning, formatting, and file system management

Source: Internet
Author: User
Tags readable disk usage

1. The correspondence between the hardware device and the file name
In the Linux system, each device is treated by a file.

Equipment

The file name of the device within Linux

IDE Hard disk

/DEV/HD[A-D]

SCSI HDD

/DEV/SD[A-P]

U disk

/dev/sd[a-p] (with SCSI hard disk. Sample)

CDROM

/dev/sro

2. Structure of hard disk and partition of hard disk
1) Why to partition the hard disk:

L easier to manage and control the system, because the relevant files and directories are placed in a partition.

L The system is more efficient.

L can limit the user's share of the hard disk (the size of the disk space).

L Easier backup and recovery.

3. Partitioning of hard disks in Linux systems

L MASTER the classification of hard disk partition: The partition of hard disk can be divided into primary partition, extended partition and logical partition.

Master the number of primary partitions: up to 4 primary partitions can be divided on one hard disk.

• Knowing that the Linux operating system's kernel supports the number of partitions on each hard disk or limit, the Linux kernel can support up to a maximum on each hard disk:

N Divide 15 partitions (partitions) on the SCSI hard disk.

n divides 63 partitions (partitions) on the IDE hard disk.

4. Fdisk and Partprobe commands

The function of the FDISK command: Create a disk partition

L D: Delete an (already existing) partition, where D is the 1th letter of the Delete.

L: Lists the types of partitions (which already exist), where L is the 1th letter of the list.

L m: Lists all commands used in Fdisk, where M is the 1th letter of the menu.

L N: Add a new partition where n is the 1th letter of new.

L P: Lists the contents of a partitioned table, where p is the 1th letter of print.

L Q: Quit Fdisk, but do not store the changes, where Q is the 1th letter of quit.

L T: Change the ID of the partition system, where T is the 1th letter of the title.

L W: Exit Fdisk and store the changes, where W is the 1th letter of write.

Partprobe command: Re-initialize the partition table of the in-memory kernel.

5. Create File System MKFS command

Formatting: The so-called format is to partition the hard disk space into a number of equal size data blocks (Blocks), and how many I nodes in this partition can be used and so on.

File system: A file system is the method and data structure used by the operating system to identify files on a disk or partition; The method of organizing files on disk.

MKFS Command: Format disk

Format: mkfs. File system Type

The format you can create is:

Mkfs.btrfs mkfs.ext2 MKFS.EXT4 Mkfs.minix mkfs.vfat

Mkfs.cramfs mkfs.ext3 Mkfs.fat Mkfs.msdos mkfs.xfs

6. File system mount and unload mount, Umount command

Mount: Mount refers to a device (typically a storage device) that is attached to an existing directory.

Mount command: Implements the file system mount.

-V: Displays the program version;

-L: Displays a list of loaded file systems;

-H: Displays help information and exits;

-V: Verbose mode, output instruction execution details;

-N: Loading a file system that is not written to the file "/etc/mtab";

-r: Load the file system into read-only mode;

-A: Loads all file systems described in the file "/etc/fstab".

Example: Mount a/DEV/SDB1 partition to a command on the/test directory: mount/dev/sdb1/test

Umount command: Implementation of file system uninstallation.

-L: Forced uninstallation

-A: Remove all file systems recorded in the/etc/mtab;

-H: Display Help;

-N: Do not deposit information in/etc/mtab file when unloading;

-R: If it fails to dismount successfully, try to re-mount the file system in read-only mode;

-t< file system type;: Remove only the file system specified in the option;

-V: Displays detailed information when executing;

-V: Displays version information.

Example: Uninstalling the file system on the/test command: umount/test

7. DF command

The DF command is used to display the available disk space on a disk partition. The default display unit is KB. You can use this command to get information about how much space the hard disk is taking up, and how much space is left.

Df-h-i-t File System type

-A or--all: contains all file systems;
--block-size=< block size;: Displays the number of chunks in the specified chunk size;
-H or--human-readable: Display information in a more readable manner;
-H or--si: Same as-h parameter, but is calculated with the Bytes as the conversion unit instead of the Bytes;
-I or--inodes: Displays the Inode information (number of files) (the hard disk may be full or the file is full)
-K or--kilobytes: Specifies a chunk size of 1024 bytes;
-L or--local: Displays only the local file system;
-M or--megabytes: Specifies a chunk size of 1048576 bytes;
--no-sync: Do not perform sync instructions before obtaining disk usage information, this is a preset value;
-P or--portability: use POSIX output format;
--sync: Before obtaining the disk usage information, perform the sync instruction first;
-t< file System type > or--type=< file system type;: Displays only disk information for the specified file system type;
-T or--print-type: Displays the type of file system;
-x< file System type > or--exclude-type=< file system type;: Do not display disk information for the specified file system type;
--help: Display Help;
--version: Displays version information.

8. DD Command

The DD command is used to copy files and convert and format the contents of the original file. The DD command is powerful, and for some of the lower-level problems, using the DD command can often get unexpected results. Use more or use DD to back up the bare device. But not recommended

Example: dd If view hard disk I/O speed (if,input file) (of output file)

DD If=/dev/zero of=/a.txt bs=1g count=1

Options

bs=< bytes: Set the IBS (input) and the granny (output) to the specified number of bytes;
cbs=< bytes;: Converts only the specified number of bytes at a time;
conv=< keyword;: Specify how the file is converted;
count=< block number;: Reads only the specified number of chunks;
ibs=< bytes;: Number of bytes per read;
obs=< bytes;: The number of bytes per output;
of=< file;: output to file;
seek=< number of blocks;: When the output starts, the number of blocks specified is skipped;
skip=< block number;: The number of blocks specified is skipped at the start of the read;
--help: Help;
--version: Displays version information.

Linux Basics-Hard disk partitioning, formatting, and file system management

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.