環境:
Redhat6.5 64位
安裝前準備,給虛拟機添加一塊磁盤,大小10G
第一步先檢視系統磁盤清單
1 [[email protected] ~]# fdisk -l
2
3 Disk /dev/sda: 32.2 GB, 32212254720 bytes
4 255 heads, 63 sectors/track, 3916 cylinders
5 Units = cylinders of 16065 * 512 = 8225280 bytes
6 Sector size (logical/physical): 512 bytes / 512 bytes
7 I/O size (minimum/optimal): 512 bytes / 512 bytes
8 Disk identifier: 0x00029423
9
10 Device Boot Start End Blocks Id System
11 /dev/sda1 * 1 64 512000 83 Linux
12 Partition 1 does not end on cylinder boundary.
13 /dev/sda2 64 587 4194304 82 Linux swap / Solaris
14 Partition 2 does not end on cylinder boundary.
15 /dev/sda3 587 3917 26749952 83 Linux
16
17 Disk /dev/sdb: 10.7 GB, 10737418240 bytes //第二塊磁盤沒有分區清單,也就是沒有分區
18 255 heads, 63 sectors/track, 1305 cylinders
19 Units = cylinders of 16065 * 512 = 8225280 bytes
20 Sector size (logical/physical): 512 bytes / 512 bytes
21 I/O size (minimum/optimal): 512 bytes / 512 bytes
22 Disk identifier: 0x00000000
第二步,給第二塊磁盤(/dev/sdb)分區
1 [[email protected] ~]# fdisk /dev/sdb //給第二塊硬碟分區
2
3 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
4 switch off the mode (command 'c') and change display units to
5 sectors (command 'u').
6
7 Command (m for help): n //建立一個分區
8 Command action
9 e extended
10 p primary partition (1-4)
11 p //分區類型為主分區
12 Partition number (1-4): 1 //由于主分區加擴充分區隻能有四個1-4
13 First cylinder (1-1305, default 1): //直接回車預設為第一塊分區
14 Using default value 1
15 Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): +2G //由于磁盤柱面不好了解,可以直接指定分區大小機關(K,M,G)
16
17 Command (m for help): n //再建立一個分區
18 Command action
19 e extended
20 p primary partition (1-4)
21 e //分區類型為擴充分區
22 Partition number (1-4): 2 //不能使用前面已用過的分區号
23 First cylinder (263-1305, default 263): //直接回車,預設起始柱面即可
24 Using default value 263
25 Last cylinder, +cylinders or +size{K,M,G} (263-1305, default 1305): +5G //指定分區大小
26
27 Command (m for help): n //建立分區
28 Command action
29 l logical (5 or over)
30 p primary partition (1-4)
31 l //前面已經有了擴充分區,是以可以建立邏輯分區了
32 First cylinder (263-916, default 263): //直接回車
33 Using default value 263
34 Last cylinder, +cylinders or +size{K,M,G} (263-916, default 916): +2G //指定分區大小
35
36 Command (m for help): n
37 Command action
38 l logical (5 or over)
39 p primary partition (1-4)
40 l
41 First cylinder (525-916, default 525):
42 Using default value 525
43 Last cylinder, +cylinders or +size{K,M,G} (525-916, default 916): +2G
44
45 Command (m for help): p //檢視分區清單
46
47 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
48 255 heads, 63 sectors/track, 1305 cylinders
49 Units = cylinders of 16065 * 512 = 8225280 bytes
50 Sector size (logical/physical): 512 bytes / 512 bytes
51 I/O size (minimum/optimal): 512 bytes / 512 bytes
52 Disk identifier: 0x9c990fc8
53
54 Device Boot Start End Blocks Id System
55 /dev/sdb1 1 262 2104483+ 83 Linux
56 /dev/sdb2 263 916 5253255 5 Extended
57 /dev/sdb5 263 524 2104483+ 83 Linux
58 /dev/sdb6 525 786 2104483+ 83 Linux
59
60 Command (m for help): w //儲存分區清單并退出
注意退出後,這時磁盤還不能寫入内容。
第三步,重新整理磁盤
1 [[email protected] ~]# partprobe /dev/sdb
第四步格式化前面的sdb5和sdb6,分區隻有格式化後才能寫入内容。
1 [[email protected] ~]# mkfs -t ext4 /dev/sdb5 //mkfs 制作檔案系統 -t 指定檔案系統類型
2 mke2fs 1.41.12 (17-May-2010)
3 Filesystem label=
4 OS type: Linux
5 Block size=4096 (log=2)
6 Fragment size=4096 (log=2)
7 Stride=0 blocks, Stripe width=0 blocks
8 131648 inodes, 526120 blocks
9 26306 blocks (5.00%) reserved for the super user
10 First data block=0
11 Maximum filesystem blocks=541065216
12 17 block groups
13 32768 blocks per group, 32768 fragments per group
14 7744 inodes per group
15 Superblock backups stored on blocks:
16 32768, 98304, 163840, 229376, 294912
17
18 Writing inode tables: done
19 Creating journal (16384 blocks): done
20 Writing superblocks and filesystem accounting information: done
21
22 This filesystem will be automatically checked every 34 mounts or
23 180 days, whichever comes first. Use tune2fs -c or -i to override.
24 [[email protected] ~]# mkfs -t ext4 /dev/sdb6
25 mke2fs 1.41.12 (17-May-2010)
26 Filesystem label=
27 OS type: Linux
28 Block size=4096 (log=2)
29 Fragment size=4096 (log=2)
30 Stride=0 blocks, Stripe width=0 blocks
31 131648 inodes, 526120 blocks
32 26306 blocks (5.00%) reserved for the super user
33 First data block=0
34 Maximum filesystem blocks=541065216
35 17 block groups
36 32768 blocks per group, 32768 fragments per group
37 7744 inodes per group
38 Superblock backups stored on blocks:
39 32768, 98304, 163840, 229376, 294912
40
41 Writing inode tables: done
42 Creating journal (16384 blocks): done
43 Writing superblocks and filesystem accounting information: done
44
45 This filesystem will be automatically checked every 38 mounts or
46 180 days, whichever comes first. Use tune2fs -c or -i to override.
第五步,挂在分區測試
1 [[email protected] ~]# mkdir /media/mountsdb //建立一個目錄挂載分區使用
2 [[email protected] ~]# mount /dev/sdb5 /media/mountsdb/
3 [[email protected] ~]# cd /media/mountsdb/
4 [[email protected] mountsdb]# ls
5 lost+found
6 [[email protected] mountsdb]# touch example.txt //建立檔案測試是否能寫入内容
7 [[email protected] mountsdb]# ls
8 example.txt lost+found
9 [[email protected] mountsdb]#
轉載于:https://www.cnblogs.com/iaknehc/p/Linux.html