Linux Add hard disk

Source: Internet
Author: User

When you add a hard drive to a Linux host, the system automatically detects the hardware device. Due to the newly added hard disk, the hard disk is not partitioned and formatted (prompt after executing the fdisk-l command: Disk/dev/sdb doesn ' t contain a valid partition table)

. IDE hard disk is generally HDX,SCSI hard disk is generally sdx,x for a,b,c,d


2.linux the number of partitions, the first primary partition is 1, followed by 2, 3, the maximum is 4,

The logical partition on the expansion disk starts at 5. Note that the order of the hard drives here is different from the CDE under Windows, so you have to count the numbers, not the order inferred under Windows.


3. Add a new hard drive

New hard disk, first partition, SCSI as an example

#fdisk/dev/sdb

Enter Fdisk mode:

Command (M for help):p//View the partition of the new hard disk

Command (M for help): N//Create new partition

You can use the M command to see the internal command of the FDISK command; n command to create a new partition; d command to delete an existing partition; The P command to display the partition list; the T command to modify the type ID number of the partition, the command to display a list of partition ID numbers; a command to specify the boot partition The W command is to save changes to the partition table to make it work.

Command Action

E Extended//Enter E to create an extended partition

P primary partition (1-4)//input p to create the primary partition, here we select P

Partion Number (1-4): 1//First extended partition, up to 4 primary partitions according to your requirements

First Cylinder (1-1014,default 1): 1//number of disk blocks starting with the primary partition

Last Cylindet or +siza or +sizem or +sizek: +1024MB//Can be a number in megabytes or a number of disk blocks, where we enter +1024MB to indicate a partition size of 1G.

This way we create a partition, and if you want to create more partitions, you can continue with the steps above.

Save the partition with W when you are finished creating it.

Command (M for help): W

The partition table has been altered!

Calling IOCTL () to re-read partition table.

Syncing disks.

(Example: FDISK/DEV/SDB------------select number:1,2. -Start cylinder and end cylinder--W (save))


Next, Format the partition

#mkfs-T Ext3-c/dev/sdb1//If there are multiple partitions, the partition is modified to SDB2 so

After formatting, we need to mount the partition. If you #mkfs/dev/sdb1 directly without parameters, use the default file system type Ext2


Then create the mount point and mount the file system:

#mkdir/mount-point

#mount/dev/sdb1/mount-point


In this way, the newly added hard disk can be used basically, can use #df-k, see


However, each time the machine restarts, the filesystem has to be manually mount, so we can modify the/etc/fstab:

/dev/sdb1/mount-point ext3 Defaults 1 2


Report:

/etc/fstab-----filesystem tab Partition table

Linux uses this table to load partitions and directories in different ways during the boot process. Each filesystem has several coherent parameters that determine how the file system reads, what user rights are relevant to the file system, and so on.

The table typically contains 6 fields.

(Some systems are represented by a label)

partitions to be mounted (such as/DEV/HDA2) and file systems (such as/usr)

(or mount point, etc.)

The directory where the partitions and file systems are to be mounted

(or format, etc.)

File system format types, such as Ext3,vfat

(Mount options, etc.)

When the value is defaults, that is the default option, including the parameter RW (read-write), suid (suid permission), EXEC (binary executable), auto (automatic loading on system startup), Nouser (only the root user can mount, instead user), async ( Data asynchronous read/write), other parameters are umask,unhide (hide), Iocharset (locale), of course, you can specify the values yourself.

(Dump value)

Whether or not the backup flag is required for dump (in English for dumping), its value is 0. 1 indicates that the file system is automatically written to disk.

(Filesystem Check Order)

Set this filesystem whether to do check at boot, in addition to the root of the filesystem its necessary check is 1, others can be set, the default value is 0.

Example: If you have a Windows partition (FAT32) in/DEV/HDA1, you want to mount the partition automatically when the system starts up, and after it is mounted, the general user is readable and writable, and can display Chinese. Then add the following in the Fstab:

/dev/hda1/mnt/c vfat umask=000,iocharset=gb2312 0 0


This article is from the "Operations Notes" blog, make sure to keep this source http://axlewire.blog.51cto.com/1418858/1627964

Linux Add hard disk

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.