ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux磁盘分区基本命令

linux磁盘分区基本命令

原创 Linux操作系统 作者:RAYSUNNNY 时间:2014-03-16 10:21:58 0 删除 编辑

一直对磁盘分区这些一知半解,不管是window还是linux。今天装ORACLE11g时拷文件一直存在。
基本命令:
fdisk -l查看有哪些磁盘及分区,大小等情况

对某个磁盘进行分区:
fdisk /dev/sda
n  //进行分区            d //删除分区
p  //建主分区
1 //选择分区number(1-4)
选择该分区的首位置
选择该分区的末位置
w  //保存
mkfs -t ext3 /dev/sdb1  //格式化分区
mount /dev/sdb1 /opt   //挂载某个分区到某个文件

以下为示例:

[root@localhost ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

Disk /dev/sdb: 48.3 GB, 48318382080 bytes
255 heads, 63 sectors/track, 5874 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb2            2400        5874    27912937+  83  Linux
[root@localhost ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 5874.
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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-5874, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2399, default 2399):
Using default value 2399

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2410624 inodes, 4817484 blocks
240874 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
148 block groups
32768 blocks per group, 32768 fragments per group
16288 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]# mount /dev/sdb1 /opt

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29227735/viewspace-1122535/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-12-05

  • 博文量
    38
  • 访问量
    242782