磨礪技術珠磯,踐行數據之道,追求卓越價值
回到上一級頁面: PostgreSQL雜記頁 回到頂級頁面:PostgreSQL索引頁
首先,由於 歷史上的原因,各個操作系統為共存的需要而約定俗成。一個物理磁盤最多有4個主分區。
http://www.express.nec.co.jp/linux/distributions/knowledge/system/fdisk.html
可以是這樣:
比如第一塊物理磁盤,它一般會有啟動分區部分用來包含系統。其余的可以作其他用途。
它可能最多包含四個主分區:
第一區:主分區(被設為活動者,啟動時,此分區被引導)
第二區:主分區
第三區:主分區
第四區:主分區
也可能是這樣:
第一區: 主分區
第二區: 擴展分區
而擴展分區 又分為 : 邏輯分區1 , 邏輯分區2,邏輯分區3 ,邏輯分區4....
第一塊物理硬盤中,主分區是必須的,因為要引導系統嘛,這是沒有辦法的事。
對第二塊物理硬盤, 可以有幾種方法去使用:
1 主分區 + 擴展分區(里面分成邏輯分區1,邏輯分區2...),
此方式下,此處主分區似乎有點不倫不類。當然也是可以當作數據區使用。
2 僅有一個 主分區,拿來直接當數據區用也是可以的。
3 完全是擴展分區。(里面分成邏輯分區1,邏輯分區2...)
要注意: 僅有擴展分區,不進一步划分邏輯分區,是不能拿來做文件系統的。
下面就以第三種情況來試驗一下:
[root@localhost ~]# fdisk -l Disk /dev/sda: 12.8 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 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 1566 12474472+ 8e Linux LVM Disk /dev/sdb: 12.8 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table
在第二塊物理硬盤上建立擴展分區:
[root@localhost ~]# fdisk /dev/sdb The number of cylinders for this disk is set to 1566. 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) e Partition number (1-4): 1 First cylinder (1-1566, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-1566, default 1566): Using default value 1566 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@localhost ~]# fdisk -l Disk /dev/sda: 12.8 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 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 1566 12474472+ 8e Linux LVM Disk /dev/sdb: 12.8 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 1566 12578863+ 5 Extended
此時如果直接建文件系統會失敗:
[root@localhost ~]# mkfs /dev/sdb1 mke2fs 1.39 (29-May-2006) /dev/sdb1: Invalid argument passed to ext2 library while setting up superblock [root@localhost ~]# [root@localhost ~]# mkfs /dev/sdb mke2fs 1.39 (29-May-2006) /dev/sdb is entire device, not just one partition! Proceed anyway? (y,n) n [root@localhost ~]#
對/dev/sdb 繼續運用 fdisk, 此時會出現 l 與 p 選項,不要理會p, 用l (logical)
[root@localhost ~]# fdisk /dev/sdb1 Unable to read /dev/sdb1 [root@localhost ~]# fdisk /dev/sdb The number of cylinders for this disk is set to 1566. 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): p Disk /dev/sdb: 12.8 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 1566 12578863+ 5 Extended Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (1-1566, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-1566, default 1566): +8G
上面選 +8G 做一個8G的邏輯分區后,再做一個:
Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (975-1566, default 975): Using default value 975 Last cylinder or +size or +sizeM or +sizeK (975-1566, default 1566): Using default value 1566 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@localhost ~]# [root@localhost ~]# fdisk -l Disk /dev/sda: 12.8 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 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 1566 12474472+ 8e Linux LVM Disk /dev/sdb: 12.8 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 1566 12578863+ 5 Extended /dev/sdb5 1 974 7823592 83 Linux /dev/sdb6 975 1566 4755208+ 83 Linux
此時可以作文件系統了,注意由於是邏輯分區,所以從第5開始計數:/dev/sdb5 /dev/sdb6
[root@localhost ~]# mkfs /dev/sdb5 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 979200 inodes, 1955898 blocks 97794 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2004877312
60 block groups
32768 blocks per group, 32768 fragments per group 16320 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Writing inode tables: 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. [root@localhost ~]# mkfs /dev/sdb6 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 595552 inodes, 1188802 blocks 59440 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1220542464
37 block groups
32768 blocks per group, 32768 fragments per group 16096 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Writing inode tables: done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 37 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@localhost ~]# cd / [root@localhost /]# ls bin etc lib64 misc opt sbin sys tmp boot home lost+found mnt proc selinux test usr dev lib media net root srv tftpboot var [root@localhost /]# mkdir /test01 [root@localhost /]# mkdir /test02 [root@localhost /]# mount /dev/sdb5 /test01 [root@localhost /]# mount /dev/sdb6 /test02 [root@localhost /]# cd /test01 [root@localhost test01]# ls lost+found [root@localhost test01]# cd /test02 [root@localhost test02]#
回到上一級頁面: PostgreSQL雜記頁 回到頂級頁面:PostgreSQL索引頁
磨礪技術珠磯,踐行數據之道,追求卓越價值