The use of Fdisk partitioning commands in Linux is detailed

Source: Internet
Author: User
Tags chmod dba versions

Under Linux, use FDISK to partition the hard disk: first delete the original partition, and then create a new partition

1) Delete partition

The code is as follows Copy Code

[Root@standby root]# FDISK/DEV/SDC

The number of cylinders for this disk is set to 4425.
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)

Command (M for help): M
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): P

disk/dev/sdc:36.4 GB, 36401479680 bytes
255 heads, Sectors/track, 4425 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System
/DEV/SDC1 1 2008093+ Linux
/DEV/SDC2 251 2008125 Linux
/DEV/SDC3 501 750 2008125 Linux
/DEV/SDC4 751 4425 29519437+ 5 Extended
/DEV/SDC5 751 1000 2008093+ Linux
/DEV/SDC6 1001 4425 27511281 Linux

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

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

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

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

Command (M for help): P

disk/dev/sdc:36.4 GB, 36401479680 bytes
255 heads, Sectors/track, 4425 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

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

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

2) Creating partitions

The code is as follows Copy Code

[Root@standby root]# FDISK/DEV/SDC

The number of cylinders for this disk is set to 4425.
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)

Command (M for help): P

disk/dev/sdc:36.4 GB, 36401479680 bytes
255 heads, Sectors/track, 4425 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

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

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

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

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Selected Partition 4
The cylinder (1002-4425, default 1002):
Using Default Value 1002
Last cylinder or +size or +sizem or +sizek (1002-4425, default 4425): +2048m

Command (M for help): N
Must delete some partition and add an extended partition

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

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

Command (M for help): N
The cylinder (1002-4425, default 1002):
Using Default Value 1002
Last cylinder or +size or +sizem or +sizek (1002-4425, default 4425): +2048m

Command (M for help): N
The cylinder (1252-4425, default 1252):
Using Default Value 1252
Last cylinder or +size or +sizem or +sizek (1252-4425, default 4425): +2048m

Command (M for help): N
The cylinder (1502-4425, default 1502):
Using Default Value 1502
Last cylinder or +size or +sizem or +sizek (1502-4425, default 4425):
Using Default Value 4425

Command (M for help): N
No Free sectors Available

Command (M for help): P

disk/dev/sdc:36.4 GB, 36401479680 bytes
255 heads, Sectors/track, 4425 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System
/DEV/SDC1 1 501 4024251 Linux
/DEV/SDC2 502 751 2008125 Linux
/DEV/SDC3 752 1001 2008125 Linux
/DEV/SDC4 1002 4425 27503280 5 Extended
/DEV/SDC5 1002 1251 2008093+ Linux
/DEV/SDC6 1252 1501 2008093+ Linux
/dev/sdc7 1502 4425 23486998+ Linux

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

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

There are two ways to build a partition: Using a file system, using a bare device

1 Use File system

Creating a file system

The code is as follows Copy Code

[Root@standby root]# Mkdir/test
[Root@standby root]# MKFS/DEV/SDC3
MKE2FS 1.32 (09-nov-2002)
FileSystem label=
OS Type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
251392 inodes, 502031 blocks
25101 blocks (5.00%) reserved for the Super user
The Data block=0
Block groups
32768 blocks per group, 32768 fragments per group
15712 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing Inode Tables:done
Writing superblocks and filesystem accounting Information:done

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

Hook up file system

The code is as follows Copy Code
[Root@standby root]# Mount/dev/sdc3/test

Change permissions

The code is as follows Copy Code

[Root@standby root]# Ls-ltr/test
Total 16
Drwx--2 root root 16384 June 21:51 Lost+found

[Root@standby root]# chown-r oracle.dba/test
[Root@standby root]# chmod 755/test

[Root@standby root]# Ls-ltr/test
Total 16
Drwx--2 Oracle DBA 16384 June 21:51 Lost+found

Create a table space

The code is as follows Copy Code

sql> Create Tablespace Chen
2 datafile '/test/chen.dbf ' size 10M;

Tablespace created.

Add a data file to a table space

The code is as follows Copy Code

Sql> Alter Tablespace Chen
2 Add datafile '/test/chen2.dbf ' size 10M;

Tablespace altered.

You can see that the table space Chen's size is 20m.

The code is as follows Copy Code

Sql> Select T.tablespace_name, round (SUM (bytes/(1024*1024)), 0) ts_size
2 from Dba_tablespaces T, Dba_data_files D
3 Where t.tablespace_name = D.tablespace_name
4 GROUP by T.tablespace_name;

Tablespace_name ts_size
———————————————————— ———-
CHEN 20
Eygle 10
SYSTEM 250
UNDOTBS1 200
USERS 25

2 Use bare equipment

You can see existing bindings

The code is as follows Copy Code
[Root@standby root]# Raw-qa
/dev/raw/raw1:bound to Major 8, minor 17
/dev/raw/raw2:bound to Major 8, minor 18
/dev/raw/raw3:bound to Major 8, minor 19
/dev/raw/raw4:bound to Major 8, minor 20
/dev/raw/raw5:bound to Major 8, minor 34

Bind Raw Device

The code is as follows Copy Code

[Root@standby test]# RAW/DEV/RAW/RAW6/DEV/SDC1
/dev/raw/raw6:bound to Major 8, minor 33

Ditional Information:1

Change permissions

The code is as follows Copy Code
[Root@standby root]# chown-r Oracle.dba/dev/raw
[Root@standby root]# chmod 755/dev/raw

Create a table space

The code is as follows Copy Code

sql> Create Tablespace Jin
2 datafile '/dev/raw/raw6′size 10M;

Tablespace created


directive: Fdisk

Purpose: To observe the physical use of the hard disk and split the hard disk.

How to use:

First, in the console input fdisk-l/DEV/SDA, observe the hard disk of the entity use case.

Second, enter the FDISK/DEV/SDA on the console, you can enter the split hard disk mode.

1. Input m shows all commands listed.

2. The input P shows the hard disk partition situation.

3. Enter a to set the hard drive boot area.

4. Enter N to set a new hard disk partition.

4.1. Enter e hard disk as [extended] partition area (extend).

4.2. Enter P hard disk as [main] partition area (primary).

5. The input t changes the hard disk partition property.

6. Enter D to delete the hard drive partition properties.

7. Enter Q End not in the hard drive partition property.

8. Enter W end and write hard disk partition properties

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.