Linux newly added hard disk partition (including greater than 2T)

If the disk of the Linux server is not enough, you need to add a new disk. There are usually 4 steps to add a disk to use. The first step is different between the virtual machine and the physical server. The next three steps are the same. Here we use the VMWare virtual machine to demonstrate how to add a disk.

(1) Disk add

Open the virtual machine settings, click "Add" --> "Hard Disk", select Next to complete the addition

image

image

(2) Disk partition

After adding, you can use fdisk -l to view the disk. The disk we added is /dev/sdb. At this time, the disk is still unusable and needs to be partitioned first.

image

Next, perform the partition operation, and partition "/dev/sdb"

image

After partitioning, the results are as follows:

image

(3) Format

To format the partition as a file system, you can use the following 2 commands with the same effect.

-t ext3 mkfs / dev / sdb 
# or
mkfs.ext3
/ dev / sdb1

image

(4) Disk mounting

image.png

After mounting, you can write data to the disk

image.png

(5) Partition method of hard disk over 2T

First use the fdisk -l command in super user mode to view the mounted hard disk device. Assuming the device number is /dev/sdb, then we use the parted command to partition the GPT:

1. yum install parted -y

# parted /dev/sdb

GNU Parted 1.8.1

Using /dev/sdb

Welcome to GNU Parted! Type ‘help’ to view a list of commands.


2. Format the MBR disk as GPT

(parted) mklabel gpt


3. Divide all the space into one partition

(parted) mkpart primary 0 -1


This step can also be set like this:

unit TB (Set the unit to TB)

mkpart primary 0 3 (set as a primary partition, the size is 3TB, the start is 0, the end is 3)


4. Display the set partition size

(parted) print


5. Exit the parted program

(parted) quit


6. After the partition is completed with parted, format it, and then you can mount it for use.Add /etc/fstab to automatically mount

mkfs.ext4 -F /dev/sdb1


The production environment is also the same operation steps, most hard disks support hot-swappable, add the hard disk directly partition and format, and finally mount, and other methods can be used.


Guess you like

Origin blog.51cto.com/15127516/2657668