[Linux] partitioning, formatting, checking, and attaching a disk

Source: Internet
Author: User

You do not need to remember the command for disk partition-fdiskfdisk, because after entering m, you will see detailed help information, as shown below:

[root@lx15 /data ]# fdisk /dev/sdaThe number of cylinders for this disk is set to 36404.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs   (e.g., DOS FDISK, OS/2 FDISK)Command (m for help): mCommand 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)
Partition formatting-after mkfs is partitioned through fdisk, it must be formatted before use. The partition formatting command is simple:
Mkfs [-t File System Format] Device File Name
The following is an example: mkfs-t ext3/dev/sda2 appeal example: Format partition/dev/sda2 in ext3 format disk Validation-fsck
Fsck [-t File System Format] Device File Name
There will be a lost + found directory at the top of the ext2/ext3 file system. This directory is used to check if any problem occurs after you use fsck, the problematic data will be placed in this directory, so the directory should be empty ideally. The Mount-mountmount command for a disk is complex and has many parameters. However, you can use the default command. The mount command is as follows:
Mount/dev/sda2 to the/home directory by default. mkdir/homemount/dev/sda2/home
The remount command is as follows:
Mount/home again, and add the rw and auto mount-o remount, rw, auto/home parameters.
The unmount command is unmount, which can be followed by the mount point or partition:
unmount /homeunmount /dev/sda2
Set boot mounting-/etc/fstab
# cat /etc/fstabLABEL=/                 /                       ext3    defaults        1 1LABEL=/data             /data                   ext3    defaults        1 2LABEL=/var              /var                    ext3    defaults        1 2LABEL=/boot             /boot                   ext3    defaults        1 2tmpfs                   /dev/shm                tmpfs   defaults        0 0devpts                  /dev/pts                devpts  gid=5,mode=620  0 0sysfs                   /sys                    sysfs   defaults        0 0proc                    /proc                   proc    defaults        0 0LABEL=SWAP-sda5         swap                    swap    defaults        0 0
When we run the mount command, the configuration will be written to/etc/fstab. The meaning of each column of the file is as follows: Column 1: disk device file name or its LABEL column 2: mount point Column 3: file system type column 4: file system parameter Column 5: Can be dumped (0 indicates no, 1 indicates dump every day) Column 6: set whether to start fsck (0 indicates no, 1 indicates the earliest test, 2 indicates the later test than 1)

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.