"Linux" Disk partition __linux

Source: Internet
Author: User
Tags reserved
We may experience disk partitioning during Linux operations. This article is a partition of the/DEV/SDB disk.
The Linux partition is different from the Windows,linux hard disk device name (IDE hard disk is HDX (x is a-d) because the IDE hard disk is up to four, Scsi,sata,usb hard disk is SDX (x is a-Z), hard disk primary partition is up to 4, needless to say everyone knows ... So the primary partition starts from SDB1 to SDB4, logical partitions start from SDB5, (logical partitions always start with sdb5 ...). )
Primary partitions (create up to 4): The first partition primarily holds disk startup information.
Extended partitions (up to 1 in Linux): Extended partitions belong to the logical schema, no more file systems can be created, and logical partitions can be created below.
Logical partitions: Created under extended partitions, different operating systems have different limits on the number of logical partitions.
Partition step:
1.fdisk Zoning;
2.MKFS format partition;
3. Create mount points;
4. Mount the disk or edit the/etc/fstab file to set up automatic mount

1. View all disks of the current operating system[Root@lgr ~]# Fdisk-l

disk/dev/sda:42.9 GB, 42949672960 bytes
255 heads, Sectors/track, 5221 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 104391 Linux
/dev/sda2 535 4192965 Linux Swap/solaris
/dev/sda3 536 5221 37640295 Linux

disk/dev/sdb:10.7 GB, 10737418240 bytes
255 heads, Sectors/track, 1305 cylinders
Units = Cylinders of 16065 * 8225280 bytes

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

the 2.fdisk command divides the SDB into 1 primary partitions, one extended partition[Root@lgr ~]# Fdisk/dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF Disklabel
Building a new DOS Disklabel. Changes would remain in memory only,
Until you decide to write them. After that, the course, the previous
Content won ' t be recoverable.


The number of cylinders for this disk is set to 1305.
There is no wrong with then, but this is larger than 1024,
And could in certain setups cause problems with:
1 software that runs in boot time (e.g., old versions of LILO)
2) booting and partitioning software from the other OSs
(e.g., DOS fdisk, OS/2 fdisk)
Warning:invalid flag 0x0000 of partition table 4 is corrected by W (rite)

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 1
The cylinder (1-1305, default 1):
Using Default value 1
Last cylinder or +size or +sizem or +sizek (1-1305, default 1305): +5g

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
E
Partition number (1-4): 2
The cylinder (610-1305, default 610):
Using Default Value 610
Last cylinder or +size or +sizem or +sizek (610-1305, default 1305):
Using Default Value 1305

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
The cylinder (610-1305, default 610):
Using Default Value 610
Last cylinder or +size or +sizem or +sizek (610-1305, default 1305): +3g

Command (M for help):
Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
The cylinder (976-1305, default 976):
Using Default Value 976
Last cylinder or +size or +sizem or +sizek (976-1305, default 1305): +2g

Command (M for help): P

disk/dev/sdb:10.7 GB, 10737418240 bytes
255 heads, Sectors/track, 1305 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System
/DEV/SDB1 1 609 4891761 Linux
/DEV/SDB2 610 1305 5590620 5 Extended
/DEV/SDB5 610 975 2939863+ Linux
/DEV/SDB6 976 1219 1959898+ Linux

Command (M for help): W
The partition table has been altered!

Calling IOCTL () to re-read partition table.

Warning:re-reading the partition table failed with error 16:device or resource busy.
The kernel still uses the old table.
The new table is used at the next reboot.
Syncing disks.

3.MKFS command to format a partition[Root@lgr ~]# MKFS.EXT3/DEV/SDB1
MKE2FS 1.39 (29-may-2006)
FileSystem label=
OS Type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
611648 inodes, 1222940 blocks
61147 blocks (5.00%) reserved for the Super user
The Data block=0
Maximum filesystem blocks=1254096896
Block groups
32768 blocks per group, 32768 fragments per group
16096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing Inode Tables:done
Creating journal (32768 blocks): Done
Writing superblocks and filesystem accounting Information:done

This filesystem'll be automatically checked every mounts or
180 days, whichever comes. Use Tune2fs-c or-i to override.
[Root@lgr ~]#
[Root@lgr ~]# MKFS.EXT3/DEV/SDB5
MKE2FS 1.39 (29-may-2006)
FileSystem label=
OS Type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
368000 inodes, 734965 blocks
36748 blocks (5.00%) reserved for the Super user
The Data block=0
Maximum filesystem blocks=754974720
Block groups
32768 blocks per group, 32768 fragments per group
16000 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing Inode Tables:done
Creating journal (16384 blocks): Done
Writing superblocks and filesystem accounting Information:done

This filesystem would be automatically checked every Notoginseng mounts or
180 days, whichever comes. Use Tune2fs-c or-i to override.
[Root@lgr ~]# MKFS.EXT3/DEV/SDB6
MKE2FS 1.39 (29-may-2006)
FileSystem label=
OS Type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
245280 inodes, 489974 blocks
24498 blocks (5.00%) reserved for the Super user
The Data block=0
Maximum filesystem blocks=503316480
Block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing Inode Tables:done
Creating journal (8192 blocks): Done
Writing superblocks and filesystem accounting Information:done

This filesystem'll be automatically checked every mounts or
180 days, whichever comes. Use Tune2fs-c or-i to override.

4. Create mount point[Root@lgr ~]# Mkdir/dsk1/dsk5/dsk6

5.mount command to do a temporary mount, edit/etc/fstab can be set to automatically mount the boot. ① Temporary Mount
Mount/dev/sdb1/dsk1
Mount/dev/sdb5/dsk5
Mount/dev/sdb6/dsk6

② edit file set to mount automatically
[Root@lgr ~]# Vi/etc/fstab
Append the following information
/dev/sdb1/dsk1 ext3 defaults 0 0
/DEV/SDB5/DSK5 ext3 defaults 0 0
/DEV/SDB6/DSK6 ext3 defaults 0 0
Description: First line: Disk directory; second row: mount point; Third line: file system format; line four: Startup disk mode; line five: on whether to detect (0 do not detect, 1 detection); line six: Error dump (0, no dump, 1 dumps)

6. Reboot the system, fdisk-l/dev/sdb view the partition.

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.