1. 程式人生 > >Linux建立主分割槽擴充套件分割槽fdisk,格式化分割槽mkfs,掛載分割槽mount

Linux建立主分割槽擴充套件分割槽fdisk,格式化分割槽mkfs,掛載分割槽mount

這裡對Linux建立擴充套件分割槽和邏輯分割槽,以及格式化分割槽和掛載分割槽進行一個詳細的介紹,希望能幫助到你們!

1.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.

2.Linux 格式化分割槽

[[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.

3.Linux 進行分割槽掛載

先建立兩個掛載點disk01,disk02

[[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 //新增到配置檔案,這裡略
    最後ESC Shift+: wq 儲存退出即可

再重啟系統看看吧!希望能幫助到你哦!!!

具體的可以到http://c.biancheng.net/view/887.html詳細檢視