Detailed tutorial on partitioning, formatting, and attaching a new hard disk in linux

Source: Internet
Author: User
The company's intranet server does not have enough hard disk space. mount the new GB hard disk and set it to the samba shared directory. for samba, refer to this article. The server already has two hard disks, so the hard disk is

Company intranet server hard disk space is insufficient, will buy a new GB hard disk mounted and set to samba shared directory, samba please refer to this article http://www.centoscn.com/CentosServer/test/2013/0804/990.html, the following describes how to partition, format, and mount a new hard disk to the system. if this applies, continue reading. There are already two hard disks on the server, so the hard disk is sdc, which will not be explained later. as for people who do not know what sdc is going on, ask Baidu's eldest brother to come back and see it.

1. # fdisk-l view the current disk information and you will find that the newly added hard disk is not a valid partition, as shown below:
Disk/dev/sdc: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065*512 = 8225280 bytes

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

2. # fdisk/dev/sdc to partition the new hard disk and perform further operations as prompted
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 182401.
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): h input h to view help commands
H: unknown command
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 input n to partition
Command action
E extended
P primary partition (1-4)
P input p is the primary partition, and e is the logical partition.
Partition number (1-4): 1 because it is a new disk, we enter 1 to divide it into the first primary Partition, which can be divided into four primary partitions.
First cylinder (1-182401, default 1): select the starting disk number of the partition. if you have no special requirements, we strongly recommend that you select the default value, that is, 1 to partition (press enter directly)
Using default value 1
Last cylinder or + size or + sizeM or + sizeK (1-182401, default 182401): defines the size of the partition. if you press the default value (press enter), you can use all available storage resources, for example, if you want to allocate 1 GB space, enter + 1024 MB.
Using default value 182401

Command (m for help): w write partition
The partition table has been altered!

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

3. # fdisk-l: you can find the partition we just divided. the content is as follows:
Disk/dev/sdc: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System
/Dev/sdc1 1 182401 1465136001 83 Linux

4. # mkfs-t ext3-c/dev/sdc1 format partitions using ext3, such as multiple partitions sdc2 and so on, because the-c parameter must be added to the new hard disk to detect the disk's bad track, this process is very long (150 GB), waiting...
Mke2fs 1.39 (29-may-2006)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
183156736 inodes, 366284000 blocks
18314200 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 0
11179 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,796 2624, 11239424,204 80000, 23887872,716 63616, 78675968,
102400000,214 990848

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

5. # Create a Mount directory for mkdir/var/samba

6. # mount/dev/sdc1/var/samba to mount a new hard disk

7. # df-hl check whether the partition size is the same as what we Reserve:
File system capacity used available % mount point
/Dev/sda7 9.5 GB 3.2G 5.9G 35%/
/Dev/sda6 9.5G 151 M 8.9G 2%/tmp
/Dev/sda5 19G 3.6G 15G 20%/usr
/Dev/sda3 19G 719 M 18G 4%/home
/Dev/sda2 230G 23G 196G 11%/var
/Dev/sda1 99 M 25 M 69 M 27%/boot
/Dev/sdb1 233G 156G 78G 67%/var/samba2
Tmpfs 1008 M 0 1008 M 0%/dev/shm
/Dev/sdc1 1.4 T 198 M 1.3 T 1%/var/samba this line is a new hard disk

8. # vi/etc/fstab: set the system to automatically mount the hard disk and add one line:
/Dev/sdc1/var/samba2 ext3 defaults 0 0

9. restart the server and perform step 7 to check whether everything is properly mounted. good luck ~

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.