Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add a new hard disk and partition and format it under CentOS

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to add a new hard disk and partition format under CentOS". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to add a new hard disk and partition format under CentOS".

Let's take a look at the steps I did:

1. First use Fdisk-l to check the disk status in the current state.

[root@linux1 ~] # fdisk-l

Disk / dev/hda: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/hda1 * 1 13 104391 83 Linux

/ dev/hda2 14 652 5132767 8e Linux LVM

Disk / dev/hdb: 2147 MB, 2147483648 bytes

16 heads, 63 sectors/track, 4161 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Disk / dev/hdb doesn't contain a valid partition table

As you can see from the red identification line above, I have added a new hard drive / dev/hdb with a size of 2G and an unpartitioned formatted state.

two。 Use Fdisk / dev/hdb for partitioning operations.

[root@linux1 ~] # fdisk / dev/hdb

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 4161.

There is nothing wrong with that, but this is larger than 1024

And could in certain setups cause problems with:

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): n / / enter N to create a new partition

Command action

E extended

P primary partition (1-4)

P / / p means to create an original partition

Partition number (1-4): 1 / / 1 indicates that the partition number is 1.

First cylinder (1-4161, default 1): 1 / / 1 means the default starting cylinder number is used. If you want to divide into multiple districts, figure out how big you want to be, and then enter the number.

Last cylinder or size or sizeM or sizeK (1-4161, default 4161): / / enter: enter indicates that the default ending column number is used. That is, this partition uses the entire hard disk space.

Using default value 4161

Command (m for help): W / / Save partition

The partition table has been altered!

Calling ioctl () to re-read partition table.

Syncing disks.

3. Check the current partition status again:

[root@linux1 ~] # fdisk-l

Disk / dev/hda: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/hda1 * 1 13 104391 83 Linux

/ dev/hda2 14 652 5132767 8e Linux LVM

Disk / dev/hdb: 2147 MB, 2147483648 bytes

16 heads, 63 sectors/track, 4161 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System

/ dev/hdb1 1 4161 2097112 83 Linux

As you can see, a new partition of / dev/hdb1 has come out. The next step is to format it and then use the

4. Format the new partition with mkfs.ext3

[root@linux1 ~] # mkfs.ext3 / dev/hdb1

Mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

262144 inodes, 524278 blocks

26213 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=536870912

16 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912

Writing inode tables: done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or

180 days, whichever comes first. Use tune2fs-c or-i to override.

5. Mounting use.

[root@linux1 ~] # mkdir / mnt/hdb1 / / create a mount point.

[root@linux1 ~] # mount / dev/hdb1 / mnt/hdb1 / / mount.

[root@linux1] # df-h

File system capacity used available used% mount point

/ dev/mapper/VolGroup00-LogVol00

4.3G 3.6G 487m 89% /

/ dev/hda1 99m 12m 82m 13% / boot

Tmpfs 125m 0 125m 0% / dev/shm

/ dev/hdb1 2.0G 3.0M 1.9G 1% / mnt/hdb1

6. Power on and mount automatically

three。 Set up a new hard disk to boot and mount automatically

Add the mount information of the new hard disk in vi / etc/fstab. Add the following line:

/ dev/hdb1 / mnt/hdb1 ext3 defaults 1 / 2 (if there is another partition is 1 / 3, and so on)

In this way, the system will automatically mount / dev/hdb1 to / mnt/hdb1 after each boot.

Thank you for your reading, the above is the content of "how to add a new hard disk and partition formatting under CentOS". After the study of this article, I believe you have a deeper understanding of how to add a new hard disk and partition formatting under CentOS. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report