linux磁碟分割槽基本命令

RAYSUNNNY發表於2014-03-16

一直對磁碟分割槽這些一知半解,不管是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部落格 ” ,連結:http://blog.itpub.net/29227735/viewspace-1122535/,如需轉載,請註明出處,否則將追究法律責任。

相關文章