linux--using Fidsk to operate the Linux hard drive "Go"

Source: Internet
Author: User

This article transferred from: http://www.liusuping.com/ubuntu-linux/linux-fdisk-disk.html

Fdisk is a Linux-brought hard disk partitioning tool that allows you to partition your hard disk or make adjustments to your hard disk partition. For this test environment, please refer to [Linux Disk System Basics]

First select the disk to be operated on

[Email protected] ~]# Fdisk/dev/sdb

Enter m to list the commands that can be executed

Command (M for help): M
Command action
   a   toggle a bootable flag
 & nbsp b   Edit BSD Disklabel
   c   Toggle the DOS compatibility flag
   d    Delete a partition
   l   list known partition types
   m   print th is menu
   n   Add a new partition
   o   Create a new empty DOS partition T Able
   p   print the partition table
   q   quit without saving changes< br>   s   Create a new empty Sun Disklabel
   t   Change a partition ' s system i D
   u   change display/entry units
   v   Verify the partition table
   w   Write table to disk and exit
   x   Extra functionality (experts only)

Enter p to list the current partitioning of the disk

Command (M for help): P

disk/dev/sdb:3221 MB, 3221225472 bytes
255 heads, Sectors/track, 391 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1 8001 8e Linux LVM
/DEV/SDB2 2 200812+ Linux

Enter D, then select the partition, delete the existing partition

Command (M for help): D
Partition number (1-4): 1

Command (M for help): D
Selected Partition 2

To view the partition, confirm that the partition has been deleted

Command (M for help): print

disk/dev/sdb:3221 MB, 3221225472 bytes
255 heads, Sectors/track, 391 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

Command (M for help):

Enter N to create a new disk partition, first set up two primary disk partitions

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P//Establish primary partition
Partition number (1-4): 1//Partition code
First cylinder (1-391, default 1)://partition Start location
Using Default value 1
Last cylinder or +size or +sizem or +sizek (1-391, default 391): 100///partition end position, unit sector

Command (M for help): N//Create a partition again
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 2//Partition 2
First cylinder (101-391, default 101):
Using Default Value 101
Last cylinder or +size or +sizem or +sizek (101-391, default 391): +200m//partition end position in M

Confirm that the partition was established successfully

Command (M for help): P

disk/dev/sdb:3221 MB, 3221225472 bytes
255 heads, Sectors/track, 391 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System
/DEV/SDB1 1 803218+ Linux
/DEV/SDB2 101 200812+ Linux

and create a logical partition.

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
E//Select extended partition
Partition number (1-4): 3
First cylinder (126-391, default 126):
Using Default Value 126
Last cylinder or +size or +sizem or +sizek (126-391, default 391):
Using Default Value 391

Confirm that the extended partition was established successfully

Command (M for help): P

disk/dev/sdb:3221 MB, 3221225472 bytes
255 heads, Sectors/track, 391 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System
/DEV/SDB1 1 803218+ Linux
/DEV/SDB2 101 200812+ Linux
/DEV/SDB3 126 391 2136645 5 Extended

Establish two logical partitions on an extended partition

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L//Select logical partition
First cylinder (126-391, default 126):
Using Default Value 126
Last cylinder or +size or +sizem or +sizek (126-391, default 391): +400m

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (176-391, default 176):
Using Default Value 176
Last cylinder or +size or +sizem or +sizek (176-391, default 391):
Using Default Value 391

Confirm logical Partition Establishment succeeded

Command (M for help): P

disk/dev/sdb:3221 MB, 3221225472 bytes
255 heads, Sectors/track, 391 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System
/DEV/SDB1 1 803218+ Linux
/DEV/SDB2 101 200812+ Linux
/DEV/SDB3 126 391 2136645 5 Extended
/DEV/SDB5 126 175 401593+-up Linux
/DEV/SDB6 176 391 1734988+-Up Linux

Command (M for help):

From the above results we can see that in HDD SDB we have established 2 primary partitions (SDB1,SDB2), one extended partition (SDB3), 2 logical partitions (SDB5,SDB6)

Note: The disk number of the primary and extended partitions is 1-4, which means that there are up to 4 primary partitions or extended partitions, and the logical partition starts with a disk number of 5, so there is no SDB4 in this experiment.

Finally, the partition operation is saved

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

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

After the partition is established, we also need to format the partition to use the disk in the system.

Establish ext2 partition on SDB1

[[email protected] ~]#&NBSP;MKFS.EXT2/DEV/SDB1
mke2fs 1.39 (29-may-2006)
Filesystem label=
OS type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
100576 inodes, 200804 blocks
10040 blocks (5.00%) reserved for the Super User
First Data block=0
Maximum filesystem blocks=209715200
7 block G Roups
32768 blocks per group, 32768 fragments per group
14368 inodes per group
superblock backups stored on block S:&NBSP
        32768, 98304, 163840

Writing inode tables:done & nbsp;                           
Writing superblocks and filesystem accounting information : Done

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

Establish EXT3 partition on SDB6

[Email protected] ~]# 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)
217280 inodes, 433747 blocks
21687 blocks (5.00%) reserved for the Super user
First Data block=0
Maximum filesystem blocks=444596224
Block groups
32768 blocks per group, 32768 fragments per group
15520 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 would be automatically checked every mounts or
Whichever comes first. Use Tune2fs-c or-i to override.
[Email protected] ~]#

Set up two directories/oracle and/web to mount the new two partitions to the system

[Email protected] ~]# mkdir/oracle
[Email protected] ~]# Mkdir/web
[Email protected] ~]# mount/dev/sdb1/oracle
[Email protected] ~]# Mount/dev/sdb6/web

View partition Mount conditions

[[email protected] ~]# df-h
File System                capacity   used available% mount point
/dev/mapper/volgroup00-logvol00
                       6.7G   2.8g  3.6g  44%/
/dev/sda1               99m   12m   82m  13%/boot
tmpfs                  125m     0  125m   0%/ DEV/SHM
/dev/sdb1             773M  808K   733m   1%/oracle
/dev/sdb6              1.7g   35m  1.6g   3%/web

If you need to automatically mount each boot, you need to modify the/etc/fstab file, add two lines of configuration

[Email protected] ~]# Vim/etc/fstab

/DEV/VOLGROUP00/LOGVOL00/EXT3 Defaults 1 1
Label=/boot/boot ext3 Defaults 1 2
TMPFS/DEV/SHM TMPFS Defaults 0 0
Devpts/dev/pts devpts gid=5,mode=620 0 0
Sysfs/sys Sysfs Defaults 0 0
PROC/PROC proc Defaults 0 0
/DEV/VOLGROUP00/LOGVOL01 swap swap defaults 0 0
/dev/sdb1/oracle ext2 Defaults 0 0
/dev/sdb6/web ext3 defaults 0 0

linux--using Fidsk to operate the Linux hard drive "Go"

Related Article

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.