1. 程式人生 > >linux 創建擴展分區以及邏輯分區

linux 創建擴展分區以及邏輯分區

linux 邏輯分區 擴展分區

[[email protected] ~]# fdisk /dev/sdb //進入要分配的磁盤

WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to
switch off the mode (command ‘c‘) and change display units to
sectors (command ‘u‘).

Command (m for help): n //創建分區
Command action
e extended
p primary partition (1-4)

e //創建擴展分區
Partition number (1-4): 4 //分區號
First cylinder (5121-10240, default 5121): //分區開始柱面,enter默認
Using default value 5121
Last cylinder, +cylinders or +size{K,M,G} (5121-10240, default 10240): //分區結束柱面
Using default value 10240

Command (m for help): p //打印分區情況

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb92c060c

Device Boot Start End Blocks Id System
/dev/sdb1 1 5120 5242864 83 Linux
/dev/sdb4 5121 10240 5242880 5 Extended

Command (m for help): n //創建分區

Command action
l logical (5 or over)
p primary partition (1-4)
l //創建邏輯分區
First cylinder (5121-10240, default 5121): //分區開始柱面,enter默認

Using default value 5121
Last cylinder, +cylinders or +size{K,M,G} (5121-10240, default 10240): 8192

Command (m for help): n //再創建一個分區

Command action
l logical (5 or over)
p primary partition (1-4)
l //再創建一個邏輯分區

First cylinder (8193-10240, default 8193): //分區開始柱面,enter默認

Using default value 8193
Last cylinder, +cylinders or +size{K,M,G} (8193-10240, default 10240): //分區結束柱面

Using default value 10240

Command (m for help): p //打印分區表進行查看

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb92c060c

Device Boot Start End Blocks Id System
/dev/sdb1 1 5120 5242864 83 Linux
/dev/sdb4 5121 10240 5242880 5 Extended
/dev/sdb5 5121 8192 3145712 83 Linux
/dev/sdb6 8193 10240 2097136 83 Linux

Command (m for help): w //w保存上面設置,q退出而不報錯
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[[email protected] ~]# mkfs.ext4 /dev/sdb5 //格式化
mke2fs 1.41.12 (17-May-2010)
Could not stat /dev/sdb5 --- No such file or directory //這裏註意一下,先執行partprobe命令讓系統內核重讀分區表,如果報錯要reboot一下

[[email protected] ~]# mkfs.ext4 /dev/sdb5 //格式化/dev/sdb5
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 786428 blocks
39321 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

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

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[[email protected] ~]# mkfs.ext4 /dev/sdb6 //格式化/dev/sdb6
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524284 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 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 will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[[email protected] var]# mkdir /disk01
[[email protected] var]# mkdir /disk02
[[email protected] var]# mount /dev/sdb5 /disk01 //掛載分區
[[email protected] var]# mount /dev/sdb6 /disk02
[[email protected] var]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 3.9G 43G 9% /
tmpfs 940M 72K 940M 1% /dev/shm
/dev/sda1 485M 38M 423M 9% /boot
/dev/mapper/VolGroup-lv_home
45G 532M 43G 2% /home
/dev/sdb5 3.0G 69M 2.8G 3% /disk01
/dev/sdb6 2.0G 35M 1.9G 2% /disk02
[[email protected] var]# vi /etc/fstab //添加到配置文件,這裏略

linux 創建擴展分區以及邏輯分區