linux fdisk命令权限,linux中fdisk分区命令使用详解linux操作系统 -电脑资料

在linux中如果我人要对磁盘进行分区我们可以直接使用fdisk命令来分区了,下面我来给大家介绍一个自己在使用fdisk分区笔记,希望对各位同学会有所帮助哦,只供参考大家需要仔细确认万无一失才操作哦,

在linux下,使用fdisk对硬盘分区:先删除原有分区,然后创建新的分区

1) 删除分区代码如下复制代码

[root@standby root]# fdisk /dev/sdc

The number of cylinders for this disk is set to 4425.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

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)

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, 63 sectors/track, 4425 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot   Start      End   Blocks  Id System

/dev/sdc1            1      250  2008093+ 83 Linux

/dev/sdc2          251      500  2008125  83 Linux

/dev/sdc3          501      750  2008125  83 Linux

/dev/sdc4          751     4425 29519437+  5 Extended

/dev/sdc5          751     1000  2008093+ 83 Linux

/dev/sdc6         1001     4425 27511281  83 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, 63 sectors/track, 4425 cylinders

Units = cylinders of 16065 * 512 = 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) 创建分区代码如下复制代码

[root@standby root]# fdisk /dev/sdc

The number of cylinders for this disk is set to 4425.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

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)

Command (m for help): p

Disk /dev/sdc: 36.4 GB, 36401479680 bytes

255 heads, 63 sectors/track, 4425 cylinders

Units = cylinders of 16065 * 512 = 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

First 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

First 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

First 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

First 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

You must delete some partition and add an extended partition first

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

First 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

First 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

First 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

First 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, 63 sectors/track, 4425 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot   Start      End   Blocks  Id System

/dev/sdc1            1      501  4024251  83 Linux

/dev/sdc2          502      751  2008125  83 Linux

/dev/sdc3          752     1001  2008125  83 Linux

/dev/sdc4         1002     4425 27503280   5 Extended

/dev/sdc5         1002     1251  2008093+ 83 Linux

/dev/sdc6         1252     1501  2008093+ 83 Linux

/dev/sdc7         1502     4425 23486998+ 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

分区建好后有两种方法:使用文件系统,使用裸设备

1) 使用文件系统

创建文件系统代码如下复制代码

[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

First data block=0

16 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 will be automatically checked every 38 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

挂接文件系统

代码如下复制代码[root@standby root]# mount /dev/sdc3 /test

改权限

代码如下复制代码

[root@standby root]# ls -ltr /test

total 16

drwx——   2 root    root       16384 Jun 20 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 Jun 20 21:51 lost+found

创建表空间

代码如下复制代码

SQL> create tablespace chen

2 datafile ‘/test/chen.dbf’ size 10M;

Tablespace created.

向表空间增加数据文件

代码如下复制代码

SQL> alter tablespace chen

2 add datafile ‘/test/chen2.dbf’ size 10M;

Tablespace altered.

可以看到表空间chen的大小是20m了代码如下复制代码

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) 使用裸设备

可以看到已有的绑定代码如下复制代码[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

绑定裸设备

代码如下复制代码

[root@standby test]# raw /dev/raw/raw6 /dev/sdc1

/dev/raw/raw6: bound to major 8, minor 33

ditional information: 1

改权限

代码如下复制代码[root@standby root]# chown -R oracle.dba /dev/raw

[root@standby root]# chmod 755 /dev/raw

创建表空间

代码如下复制代码

SQL> create tablespace jin

2 datafile ‘/dev/raw/raw6′ size 10M;

Tablespace created

指令:fdisk

用途:观察硬盘之实体使用情形与分割硬盘用,linux中fdisk分区命令使用详解linux操作系统》(https://www.unjs.com)。

使用方法:

一、在 console 上输入 fdisk -l /dev/sda ,观察硬盘之实体使用情形。

二、在 console 上输入 fdisk /dev/sda,可进入分割硬盘模式。

1. 输入 m 显示所有命令列示。

2. 输入 p 显示硬盘分割情形。

3. 输入 a 设定硬盘启动区。

4. 输入 n 设定新的硬盘分割区。

4.1. 输入 e 硬盘为[延伸]分割区(extend)。

4.2. 输入 p 硬盘为[主要]分割区(primary)。

5. 输入 t 改变硬盘分割区属性。

6. 输入 d 删除硬盘分割区属性。

7. 输入 q 结束不存入硬盘分割区属性。

8. 输入 w 结束并写入硬盘分割区属性

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值