Manage disks in Linux

Source: Internet
Author: User
Article Title: Manage disks in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Any computer operating system has its own disk management tools, including DOS, Windows, linux, FreeBSD, and Solaris. Without a disk management tool, the operating system cannot be installed and work. If you want to install the operating system on bare metal, the installer must have the disk partitioning and formatting functions. This document describes the disk management tools in Linux.

Unique fdisk

Similar to DOS and Windows, the partition command in Linux is also fdisk. It is a complete character interface tool that many beginners are afraid. In fact, fdisk has specific prompts, which are very easy to use and far more powerful than DOS and Windows fdisk.

The fdisk-l command displays existing partitions.

The command for partitioning/dev/hda is:

Fdisk/dev/hda

Then the interactive interface is displayed.

M Displays the fdisk prompt, which is the most common.

P shows the current partition status.

N adds a partition.

D. Delete the partition.

T changes the partition format.

L supports the partition list. It supports DOS, FAT16, FAT32, and OS2 partitions.

Q exits. The modification is not saved. If you just want to familiarize yourself with the use of fdisk, you should use q to exit.

W write the partition modification to the disk.

Scalable parted

There may be many people who have used the PQ-Magic tool to adjust the partition size, but I am afraid there will not be many people who know that Linux can also adjust the partition size. Linux has a parted tool that can adjust partitions, but it has some restrictions. If you want to increase a partition, there must be unused space behind the partition, And the partition is not mounted.

Use the fdisk-l command to display:

Disk/dev/hda: 255 heads, 63 sectors, 2498 cylinders.

Units = cylinders of 16065*512 bytes

Device Boot Start End Blocks Id System

/Dev/hda1*1 6 48163 + 83 Linux

...................

/Dev/hda3 644 1159 4144770 83 Linux

...................

It indicates that partition 3 starts from cylinder 644 and ends at 1159. The size is 4144770 kb.

To increase partition 3, run the following command:

Parted/dev/hda resize3 644 1300

This means to adjust partition 3 from cylindrical 644 to cylindrical 1300.

Restart the machine, and the partition change takes effect.

E2label

Many Linux users may not use the e2label command. However, this command is quite effective. Before introducing it, let's take a look at the/etc/fstab file:

Label = // ext3 defaults 1 1

/Dev/hda7/usr ext3 defaults 1 1

The second line is easy to understand, that is, mount/dev/hda7 to/usr. The partition is not specified in the first line, which means to mount the partition marked as/. The advantage of this writing is that the system can automatically mount the correct partition even if the hard disk is switched from ide0 (hda) on the motherboard to ide2 (hdc. Generally, the volume label is automatically specified during Linux installation. For a new partition that is manually added, you can use the following command to specify the volume label for it:

E2label/dev/hdax/new

Mkdir/new

Then add the following to/etc/fstab:

Label =/new ext3 defaults 1 1

When you restart the machine next time, the partition marked as/new will be mounted to/new.

Tune2fs

Red Hat 7.x can use the ext3 file system. This article does not specifically compare the advantages and disadvantages of ext2 and ext3, simply put, ext3 is better than ext2. If you want to convert the previous ext2 File System to the ext3 file system, you can use the command

Tune2fs-j-e 0-I 0/dev/hdax

Ordered world mkfs

Mkfs is equivalent to the formatting command in DOS/Windows. In Linux, partitions such as ext2, dos, vfat, and other partitions can be formatted. Unlike Windows, partitions such as DOS, FAT32, FAT16, and NTFS can only be formatted.

Example:

Mkdosfs knows it is in DOS format at first glance;

Mke2fs format the ext2 file system;

Mkfs. bfs format the SCO Unix file system;

Mkfs. ext2 is also used to format ext2;

Mkfs. ext3 format ext3 file system;

Mkfs. minix format minix file system. minux, which is a Unix for teaching;

Mkfs. msdos can be viewed in DOS format;

Mkfs. reiserfs file system. reiserfs is a replacement of ext2/ext3 for Linux players, but it is considered unstable;

Mkreiserfs and mkfs. reiserfs are the same;

Mkfs. vfat format the fat partition;

Mkswap format the swap partition in Linux.

E2fsck saves disk

Sometimes the disk is faulty due to sudden power failure or other reasons, you need to use the disk Repair Tool e2fsck. The command is as follows:

E2fsck/dev/hdax-

Note: In general, you can use e2fsck-p/dev/hdax to automatically repair damaged partitions, but e2fsck cannot repair mounted hard disks.

In general, system governance in Linux is not only more complex than the DOS/Windows 9x Fdisk/Format tool, but also more powerful than DOS/Windows 9x.

However, compared with windows 2000's graphical disk management tool, Linux's partition management tool is not easy to use. However, Windows 2000 does not have the ability to create and recognize partitions other than FAT and NTFS.

Linux supports almost all partitions in the operating system. The only pity is that it has insufficient governance capabilities for NTFS partitions. If your computer has a Linux, FreeBSD, Solaris, x86, and other operating systems in addition to the Windows system, you have to give up the Windows 2000 administration tool, the disk management tool of Unix/Linux is used.

Skillful disk governance is very important for Linux. The best way to learn about disk governance is to learn more and practice more. Remember to back up data carefully before trying it out. Disk governance misoperations often cause fatal damage.

Related Article

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.