• notice
  • Congratulations on the launch of the Sought Tech site

How to realize the expansion of CentOS server? ?

Hard Disk Recognition in Linux:

Generally use the "fdisk -l" command to list the currently connected hard disks in the system

Device and partition information. The new hard disk has no partition information, only the hard disk size information is displayed.

1. Turn off the server and add a new hard disk

2. Start the server and log in as root user

3. View hard disk information

#fdisk -lDisk /dev/sda: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0004406e
  Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1          39      307200   83  LinuxPartition 1 does not end on cylinder boundary./dev/sda2              39        2589    20480000   83  Linux/dev/sda3            2589        2850     2097152   82  Linux swap / Solaris/dev/sda4            2850        5222    19057664    5  Extended/dev/sda5            2850        5222    19056640   83  Linux
Disk /dev/sdb: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x14b52796
  Device Boot      Start         End      Blocks   Id  System

4. Create a new hard disk partition command parameters:

fdisk can use the m command to view the internal commands of the fdisk command;
a: The command specifies the boot partition;
d: command to delete an existing partition;
l: command to display a list of partition ID numbers;
m: View the fdisk command help;
n: command to create a new partition;
p: command to display a list of partitions;
t: command to modify the type ID number of the partition;
w: The command is to save the modification to the partition table to make it work

5. Enter the disk, partition the disk, pay attention to the red part.

#fdisk /dev/sdb
Command (m for help): n
Command action
e extended //Enter e to create an extended partition
p primary partition (1-4) //Enter p to create a logical partition
Partion number(1-4): 1 //Enter l here to enter the logical partitioning stage;
First cylinder (51-125, default 51): //Note: This is the Start value of the partition; it is best to press Enter directly here, if you enter a non-default number, it will cause a waste of space;
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M Note: This is to define the size of the partition, +200M means the size is 200M; of course, you can also use the unit cylinder size prompted by p to calculate, and then to specify the value of End. Look back and see how it is calculated; it is still more intuitive to use the method of +200M to add. If you want to add a partition with a size of about 10G, please enter +10000M;

Command (m for help): w //Finally enter w and press Enter to save.

Check it out:

#fdisk -l

You can see the /dev/sdb1 partition, I will omit the screenshot.

6. Format the partition:

#mkfs.ext3 /dev/sdb1 //Note: Format /dev/sdb1 as ext3 type
mke2fs 1.41.12 (17-May-2010)
filesystem label=
Operating System: Linux
block size=4096 (log=2)
chunk size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
640848 inodes, 2562359 blocks
128117 blocks (5.00%) reserved for the super user
first data block = 0
Maximum filesystem blocks=2625634304
79 block groups
32768 blocks per group, 32768 fragments per group
8112 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing to inode table: done
Creating journal (32768 blocks): Done
Writing superblocks and filesystem accounting information: Done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

This is formatted, we can use mount to mount the partition, and then use the file system;

7. Create the /data1 directory:

#mkdir /data1

8. Start mounting the partition:

#mount /dev/sdb1 /data1

9. Check the hard disk size and mounted partition:

#df -h

10. Configure automatic mount at startup

Because the mount will fail after restarting the server, you need to write the partition information to the /etc/fstab file to make it permanently mounted:

#vim /etc/fstab

join in:

/dev/sdb1 (disk partition) /data1 (mount directory) ext3 (file format) defaults 0 0

11. Restart the system


Technical otaku

Sought technology together

Related Topic


Leave a Reply