Linux HDD installation and partitioning fdisk

Source: Internet
Author: User

Abstract: This article will introduce a new hard drive from virtual machine VMware simulation to describe the partition and installation of the newly added hard disk in Linux. In this article, a virtual hard disk with a 10G SCSI interface is added to the virtual machine, then 3 partitions are established on the new virtual hard disk, a Ext3fs file system is established on the 1th and 3rd partitions, and the 2nd partition is reserved for swap partition.
First, the hard disk is installed on the computer host, this refers to the installation of hardware. This article uses a virtual machine to add a 10G of virtual SCSI hard disk. How to add a hard disk under the virtual machine, you can refer to the following URL: https://jingyan.baidu.com/article/0eb457e50394d803f0a90554.html
After adding a new hard drive, we can check whether the new hard drive is recognized correctly by the following command.

Through the results we see that the current system has SDA, SDB two hard drives, SDA is divided into 3 blocks sda1, Sda2, Sda5, the 2nd hard disk is a whole block, has not been partitioned. The system has correctly identified this new SCSI hard drive.
Next, use FDISK to partition this new hard drive.

Start the FDISK program with the target device (/DEV/SDB) as the parameter. Fdisk is an interactive application that after performing an operation, Fdisk displays a line of information and gives a colon: waits for the user to enter a command. As a positive, input m will give you help information.

Then we'll use the N command (new) to create a new partition.

Select p to create the primary partition, and E to create the logical partition, we will set up three partitions on the primary partition. Select p to select the partition number and a hard disk with 4 primary partitions. The 1th partition is built on the hard disk SDB's 1th primary partition SDB1. Then it is the cylinder that selects the beginning of the partition, starting from 2048. The partition size is 2G. So the first partition is set up, of course, we haven't written the partition into the hard disk, this step will be written after all the partitions have been created, we now use the P (print) command to view the 1th partition we created.

Then the 2nd and 3rd partitions are partitioned according to the above method. 2nd partition Swap partition 1G size, section 3 partition 2G. Such as.


Since the second partition is a swap partition, we need to modify the partition type to change it to swap, and the default new partition is the EXT4 type. You can use the T command to modify its type, the partition number is selected 2, and then the modified type can be viewed by the L command, where swap is 82.


This completes the 3 partition settings and uses the command to view the partition information. The partitioned partition is then written to the hard disk by the W command, and the settings are not written to the hard disk until the W command is used.


Then use the MKFS command to write to the Ext3fs file system. Then use fsck to check. Then create a new/web directory to mount it. The 3rd partition is similar to the first partition and is no longer described and mounted in the/store directory.



3rd partition:



The 2nd partition Swap partition is then initialized and activated for use. The swap partition needs to be initialized with the Mkswap command, which uses the partition's device name as the parameter, and finally checks and activates the swap partition using the Swapon command. Use the Swapon command with-s to view the swap partitions that already exist on the current system.


Above, the partition and initialization of the new hard disk have been completed. The next step is to modify the/etc/fstab configuration file so that the hard drive is automatically mounted each time it starts. This section can refer to my previous blog "/etc/fstab configuration file Details". At this point, you have completed the partition and installation of the new hard disk.

Linux HDD installation and partitioning fdisk

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.