Hard drive recognition for Linux:
The "fdisk-l" command is generally used to list the hard drives currently connected in the system
Device and partition information. The new hard disk does not have partition information, only the hard disk size information is displayed.
1. Turn off the server plus the new hard drive
2. Start the server and log in as root
3. View hard Drive information
#fdisk-L
[CPP]View PlainCopy
- disk/dev/sda:42.9 GB, 42949672960 bytes
- 255 heads, Sectors/track, 5221 cylinders
- Units = Cylinders of 16065 * 8225280 bytes
- Sector size (logical/physical): bytes/512 bytes
- I/O size (minimum/optimal): bytes/512 bytes
- Disk identifier:0x0004406e
- Device Boot Start End Blocks Id System
- /DEV/SDA1 * 1 307200 Linux
- Partition 1 does not end on cylinder boundary.
- /dev/sda2 2589 20480000 Linux
- /dev/sda3 2589 2850 2097152, Linux Swap/solaris
- /DEV/SDA4 2850 5222 19057664 5 Extended
- /dev/sda5 2850 5222 19056640-up Linux
- disk/dev/sdb:10.7 GB, 10737418240 bytes
- 255 heads, Sectors/track, 1305 cylinders
- Units = Cylinders of 16065 * 8225280 bytes
- Sector size (logical/physical): bytes/512 bytes
- I/O size (minimum/optimal): bytes/512 bytes
- Disk identifier:0x14b52796
- Device Boot Start End Blocks Id System
4. Create a new hard disk partition command parameter:
Fdisk can use the M command to see the internal commands of the FDISK command; |
A: The command specifies the boot partition; |
D: command to delete an existing partition; |
L: command displays a list of partition ID numbers; |
M: View the fdisk command help; |
N: command to create a new partition; |
P: command displays a list of partitions; |
T: Command modifies 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, and note the Red section.
#fdisk/dev/sdb
[CPP]View PlainCopy
- Command (M for help ): N
- Command Action
- E Extended //Enter E to create an extended partition
- P primary partition (1-4) //input p to create a logical partition
- P
- Partion Number (1-4): 1 //Enter the L here and enter the logical partitioning phase;
- First Cylinder (51-125, Default): //Note: This is the start value of the partition, it is best to press ENTER directly, if you enter a non-default number, will cause space waste;
- Using Default Value Wuyi
- Last cylinder or +size or +sizem or +sizek (51-125, default): +200m Note: This is the definition of the partition size, +200m is the size of 200M, of course, you can also according to the P hint of the unit CY The size of the Linder is counted, and then the value of end is specified. Look back to see how it is, or use +200m this method to add, this can be intuitive. If you want to add a 10G or so size partition, please enter +10000m;
- Command (M for help ): W //Last input W enter save.
Take a look:
#fdisk-L
You can see the/DEV/SDB1 partition, I'll omit it.
6. Format the partition:
#mkfs. EXT3/DEV/SDB1//NOTE: Format/dev/sdb1 as ext3 type
[CPP]View PlainCopy
- MKE2FS 1.41.12 (17-may-2010)
- File System label =
- Operating system: Linux
- Block size =4096 (log=2)
- Chunked 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 block of data =0
- Maximum filesystem blocks=2625634304
- 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 Inode table: complete
- Creating Journal (32768 blocks): complete
- Writing Superblocks and FileSystem accounting information: Complete
- This filesystem would be automatically checked every mounts or
- Whichever comes first. Use Tune2fs-c or-i to override.
So it's formatted so that we can load the partition with mount and then use the filesystem;
7. Create the/DATA1 directory:
#mkdir/data1
8. Start Mount Partition:
#mount/dev/sdb1/data1
9. View the hard disk size and mount the partition:
#df-H
10. Configure Boot Auto Mount
Because mount Mount fails after restarting the server, it is necessary to write the partition information to the/etc/fstab file so that it is permanently mounted:
#vim/etc/fstab
Join: |
/DEV/SDB1 (disk partition)/data1 (Mount directory) ext3 (file format) defaults 0 0 |
11. Rebooting the system
Mount a new disk under Linux