Add a new hard disk under CentOS and format the partition

Linux tape backup, so I first add a hard disk, and accordingly create a partition, format it, and then mount it for use. Let me see the steps of my operation:

1. Use Fdisk -l first to check the disk status in the current state.

 

[[email protected] ~]# 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 logo line above, I added a new hard disk /dev/hdb with a size of 2G and no partition formatting.

 

 

 

2. Use Fdisk /dev/hdb for partitioning.

 

 

[[email protected] ~]# 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

(eg, 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 a raw partition

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

First cylinder (1-4161, default 1): 1 //1 means to use the default starting cylinder number. If you want to divide multiple zones, first calculate how big it is, then enter the number.

Last cylinder or size or sizeM or sizeK (1-4161, default 4161): // Enter: Enter means to use the default ending cylinder number. This partition uses the entire hard disk space.

 

Using default value 4161

 

Command (m for help): w //Save the partition

 

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

 

 

3. View the current partition status again:

[[email protected] ~]# 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

It can be seen that a new partition of /dev/hdb1 has been released. Next format it and use it again

 

 

 

4. Format the new partition with mkfs.ext3

[[email protected] ~]# 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. Mount and use.

[[email protected] ~]# mkdir /mnt/hdb1 //Create a new mount point.

[[email protected] ~]# mount /dev/hdb1 /mnt/hdb1 //mount.

[[email protected] ~]# df -h

File system capacity has been used with % used mount points

/ 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. Boot automatically mount

Third, set a new hard disk boot automatically mount

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

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

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

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to choose the cloud server?

★ Choose the right cloud server configuration based on your actual business needs: Understand...

How do I connect to my cloud server? (including linux and windows)

First of all to distinguish between linux and windows, including ubuntu, centos, debian are...

linux system data disk merged into the system disk

 Check it out, the current command: df -h [[email protected] ~]# df -h Filesystem...

Linux cloud server data disk expansion tutorial guide

This tutorial belongs to the data disk expansion [non-system disk] default directory /dev/sdb...

About the automatic synchronization of cloud server time, and the problem that time cannot be modified.

Recently, there have been user feedback, cloud server time cannot be modified. The solution is...