Linux Hard disk recognition:
The "fdisk-l" command is generally used to list the currently connected hard disks in the system.
Device and partition information. If the new hard disk has no partition information, only the size information of the hard disk is displayed.
1. Close the server and add a new hard disk
2. Start the server and log in as root
3. View Hard Disk Information
#fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0004406e Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 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 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x14b52796 Device Boot Start End Blocks Id System
4. Create new hard disk partition command parameters:
Fdisk can use the m command to see the internal command of fdisk command. a: The command specifies the boot partition; d: Command to delete an existing partition; l: The command displays a list of partition ID numbers. m: View fdisk command help; n: Command to create a new partition; p: The command displays the partition list. t: Command to modify the type ID number of the partition; w: The command is to save changes 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 p Partion number(1-4): 1 //When l is input here, the logical partitioning stage is entered. First cylinder (51-125, default 51): //Note: This is the Start value of the partition. It's better to press Enter directly. If you enter a non-default number, it will cause space waste. Using default value 51 Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M Note: This defines the partition size.+200M It's 200 in size. M ;Of course, you can also according to p Unit of prompt cylinder Let's calculate the size and then specify it. End Number. Look back and see how it works; or use it.+200M This way to add, so that it can be intuitive. If you want to add a 10 G About the size of the partition, please enter +10000M ; Command (m for help): w //Finally, enter w to save.
Check:
#fdisk -l
As you can see the / dev/sdb1 partition, I will omit the screenshot.
6. Format partitions:
# mkfs.ext3/dev/sdb1// Note: Format / dev/sdb1 into ext3 type
mke2fs 1.41.12 (17-May-2010) File System Label= Operating System: Linux Block size = 4096 (log=2) Block size = 4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 640848 inodes, 2562359 blocks 128117 blocks (5.00%) reserved for the super user The first 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: complete Creating journal (32768 blocks): completed Writing superblocks and filesystem accounting information: completed This filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
With this formatted, we can mount the partition and then use the file system.
7. Create / data1 directory:
#mkdir /data1
8. Start mounting partitions:
#mount /dev/sdb1 /data1
9. View hard disk size and mount partition:
#df -h
10. Configure boot-up automatic mounting
Because mount mount fails after restarting the server, you need to write partition information to the / etc/fstab file to make it permanent mount:
#vim /etc/fstab
Accession: |
/ dev/sdb1 (disk partition)/data1 (mount directory) ext3 (file format) defaults 0 0 |
11. Restart the system