CentOS format the newly added Hard Disk

Source: Internet
Author: User

First, format the new hard disk.

Step 1:

Copy codeCode example: [root @ rac1 ~] # Fdisk/dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
Until you decide to write them. After that, of course, the previous
Content won't be recoverable.
The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
And coshould in certain setups cause problems:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(E.g., dos fdisk, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w (rite)
Command (m for help): m
Command action
A toggle a bootable flag
B edit bsd disklabel
C toggle the dos compatibility flag
D delete a partition
L list known partition types
M print this menu
N add a new partition
O create a new empty DOS partition table
P print the partition table
Q quit without saving changes
S create a new empty Sun disklabel
T change a partition's system id
U change display/entry units
V verify the partition table
W write table to disk and exit
X extra functionality (experts only)

Step 2:

Copy codeCode example: Command (m for help): n
Command action
E extended
P primary partition (1-4)
P
Partition number (1-4): 1
First cylinder (1-1305, default 1 ):
Using default value 1
Last cylinder or + size or + sizeM or + sizeK (1-1305, default 1305 ):
Using default value 1305
Command (m for help): w
The partition table has been altered!
Calling ioctl () to re-read partition table.
Syncing disks.

Step 3:

Copy codeCode example: [root @ rac1 ~] # Fdisk-l
Disk/dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sda1*1 1147 9213246 83 Linux
/Dev/sda2 1148 1305 1269135 82 Linux swap
Disk/dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sdb1 1 1305 10482381 5 Extended

Step 4 format the partition

Copy codeCode example: [root @ rac1 ~] # Mkfs-t ext3-c/dev/sdb1
Mke2fs 1.35 (28-Feb-2004)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
1310720 inodes, 2620595 blocks
131029 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768,983 04, 163840,229 376, 294912,819 200, 884736,160 5632
Checking for bad blocks (read-only test): done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs-c or-I to override.

Step 5: create a directory and then add the partition to the directory.

Copy codeCode example: [root @ rac1/] # mkdir/u01
[Root @ rac1/] # mount/dev/sdb1/u01


Step 6: Modify the/etc/fstab file and add the following records so that the partition can be automatically loaded after each restart.
Step 7:
[Root @ rac1/] # vi/etc/fstab
Add the following content at the end of the file:
/Dev/sdb1/u01 ext3 defaults 1 2

Note:
If you choose to create a Logical Disk (that is, select e) when adding a new hard disk, the following error will be reported during formatting:

Copy codeCode example: mkfs-t ext3-c/dev/sdb1
Invalid argument passed to ext2 library while setting up superblock.


This is because only the Logical Disk is created and no logical partition is created. Therefore, you need to create a logical partition after creating the Logical Disk:

Copy codeCode example: [root @ jbxue oracle] # fdisk/dev/sdb
The number of cylinders for this disk is set to 2088.
There is nothing wrong with that, but this is larger than 1024,
And coshould in certain setups cause problems:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(E.g., dos fdisk, OS/2 FDISK)
Command (m for help): m
Command action
A toggle a bootable flag
B edit bsd disklabel
C toggle the dos compatibility flag
D delete a partition
L list known partition types
M print this menu
N add a new partition
O create a new empty DOS partition table
P print the partition table
Q quit without saving changes
S create a new empty Sun disklabel
T change a partition's system id
U change display/entry units
V verify the partition table
W write table to disk and exit
X extra functionality (experts only)
Command (m for help): n
Command action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (1-2088, default 1 ):
Using default value 1
Last cylinder or + size or + sizeM or + sizeK (1-2088, default 2088 ):
Using default value 2088
Command (m for help): w
The partition table has been altered!
Calling ioctl () to re-read partition table.
Syncing disks.
[Root @ jbxue oracle] # fdisk-l
Disk/dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sda1*1 1000 8032468 + 83 Linux
/Dev/sda2 1001 1200 1606500 82 Linux swap/Solaris
/Dev/sda3 1201 2610 11325825 83 Linux
Disk/dev/sdb: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sdb1 1 2088 16771828 + 5 Extended
/Dev/sdb5 1 2088 16771797 83 Linux
[Root @ jbxue oracle] # mkfs-t ext3-c/dev/sdb5
Mke2fs 1.39 (29-may-2006)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
2097152 inodes, 4192949 blocks
209647 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 0
128 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768,983 04, 163840,229 376, 294912,819 200, 884736,160 5632, 2654208,
4096000
Checking for bad blocks (read-only test): done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs-c or-I to override.
[Root @ jbxue oracle] # fdisk-l
Disk/dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sda1*1 1000 8032468 + 83 Linux
/Dev/sda2 1001 1200 1606500 82 Linux swap/Solaris
/Dev/sda3 1201 2610 11325825 83 Linux
Disk/dev/sdb: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sdb1 1 2088 16771828 + 5 Extended
/Dev/sdb5 1 2088 16771797 83 Linux

In this way, you can add, partition, and format new hard disks in linux.

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.