Linux 分区备忘

Submitted by Lizhe on Wed, 06/07/2017 - 21:53

 

fdisk -l 

可以看到新加的硬盘

Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
 

这里唯一需要说明一下的是

主分区P+扩展分区E 个数最多4个

你最多只能有一个扩展分区 ( 扩展分区可以划出多个逻辑分区)

也就是说你最多可以有3个主分区一个扩展分区, 然后这个扩展分区可以划出多个逻辑区

扩展分区=逻辑区1+逻辑区2+逻辑区3  

如果给一个20G的硬盘划分15G的扩展分区

然后第一次划分1G的逻辑分区, 剩余扩建全部划分给又一个逻辑分区将得到

Device     Boot   Start      End  Sectors Size Id Type
/dev/sdb1          2048 31459327 31457280  15G  5 Extended
/dev/sdb5          4096  2101247  2097152   1G 83 Linux
/dev/sdb6       2103296 31459327 29356032  14G 83 Linux

其中sdb1 不能被直接使用, 你甚至不能格式化它, 它只是下面sdb5和sdb6的总和

 

[root@localhost ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
Found a dos partition table in /dev/sdb1
Proceed anyway? (y,n) y
mkfs.ext3: inode_size (128) * inodes_count (0) too big for a
    filesystem with 0 blocks, specify higher inode_ratio (-i)
    or lower inode count (-N).

[root@localhost ~]# mkfs -t ext3 /dev/sdb5
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: 74a1a47a-b43d-4273-9528-e3048c99be63
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

[root@localhost ~]# mkfs -t ext3 /dev/sdb6
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 3669504 4k blocks and 917504 inodes
Filesystem UUID: faabf431-b05e-4c98-9895-d26339371b37
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done