Add dual hard drive in linux

Source: Internet
Author: User
Add dual hard disks in linux-general Linux technology-Linux technology and application information. For more information, see the following. Add a 20 gb ide hard disk to the CetntOS system and divide the partitions into/dev/hdb1 and/dev/hdb2.
Transfer http://www.online990.com/htm/201027/181.htm
The procedure is as follows:
[Root @ localhost/] # fdisk/dev/hdb
The number of cylinders for this disk is set to 44384.
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): p # list hard disk partition table information

Disk/dev/hdb: 21.4 GB, 21474836480 bytes # New Hard Disk added
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945*512 = 483840 bytes

Device Boot Start End Blocks Id System

Command (m for help): n # partition a disk
Command action
E extended # extended partition
P primary partition (1-4) # primary partition
P # generally, select partition as the primary partition, and select p
Partition number (1-4): 1 # enter the Partition number. Here is the first Partition. Select 1.
First cylinder (1-44384, default 1): # enter the number of disk blocks. The default value is 1.
Using default value 1
Last cylinder or + size or + sizeM or + sizeK (1-44384, default 44384): + 10240 M
# Enter the partition size. By default, all disk space is allocated.
Command (m for help): n
Command action
E extended
P primary partition (1-4)
P
Partition number (1-4): 2
First cylinder (21166-44384, default 21166 ):
Using default value 21166
Last cylinder or + size or + sizeM or + sizeK (21166-44384, default 44384 ):
Using default value 44384

Command (m for help): p

Disk/dev/hdb: 21.4 GB, 21474836480 bytes
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945*512 = 483840 bytes

Device Boot Start End Blocks Id System
/Dev/hdb1 1 21165 10000431 83 Linux
/Dev/hdb2 21166 44384 10970977 + 83 Linux

Command (m for help): w # write data to the disk and exit
The partition table has been altered!

Calling ioctl () to re-read partition table.
Syncing disks.

In this way, the partition is created, and we need to format the disk.
[Root @ localhost/] # mkfs-t ext3-c/dev/hdb1 # format partition 1 in ext3 format.
Mke2fs 1.39 (29-may-2006)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
1251712 inodes, 2500107 blocks
125005 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 2562719744
77 block groups
32768 blocks per group, 32768 fragments per group
16256 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 (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs-c or-I to override.

[Root @ localhost/] # mkfs-t ext3-c/dev/hdb2 # format partition 2 in ext3 format.
Mke2fs 1.39 (29-may-2006)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
1373568 inodes, 2742744 blocks
137137 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 2810183680
84 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768,983 04, 163840,229 376, 294912,819 200, 884736,160 5632, 2654208

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 39 mounts or
180 days, whichever comes first. Use tune2fs-c or-I to override.

Re-check whether the disk partition is formatted.
Root @ localhost ~] # Fdisk-l

Disk/dev/hda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System
/Dev/hda1*1 2550 20482843 + 83 Linux
/Dev/hda2 2551 2811 2096482 + 82 Linux swap/Solaris
/Dev/hda3 2812 13054 82276897 + 83 Linux

Disk/dev/hdb: 21.4 GB, 21474836480 bytes
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945*512 = 483840 bytes

Device Boot Start End Blocks Id System
/Dev/hdb1 1 21165 10000431 83 Linux
/Dev/hdb2 21166 44384 10970977 + 83 Linux

Next, mount the disk.
[Root @ localhost/] # mkdir/www; mkdir data # create two directories: www and data
[Root @ localhost/] # mount/dev/hdb1/www # mount hdb1 TO www
[Root @ localhost/] # mount/dev/hdb2/data # mount hdb2 to data

Use df to check whether the partition is mounted.
[Root @ localhost ~] # Df-kv
File System 1 K-block used available % mount point
/Dev/hda1 19840892 3488364 15328388 19%/
/Dev/hda3 79699248 367392 75218012 1%/home
Tmpfs 127772 0 127772 0%/dev/shm
/Dev/hdb1 9843276 153192 9190064 2%/www
/Dev/hdb2 10798528 157992 10091988 2%/data
Modify/etc/fstab and add the partition loading information at the end of the file to enable the system to automatically mount the partition at startup.
[Root @ localhost/] # vi/etc/fstab
/Dev/hdb1/www ext3 defaults 1 2
/Dev/hdb2/data ext3 defaults 1 2
Save and exit, restart the server, and check whether the disk is mounted successfully. In this way, the work of adding a new hard disk is successfully completed.

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.