linux系统创建主分区、逻辑分区 、设置ext系列分区的参数以及检
linux对不同的磁盘设备的设备文件命名如下: nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; IDE: /dev/hd[a-z] 查看linux的磁盘分区可使用fdis(分区管理命令) nbsp;nbsp;nbsp; fdisk /dev/sda (非IDE硬盘) [root@localhost ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). 说明: nbsp;nbsp;nbsp; 1、Disk /dev/sda: 16.1 GB 硬盘的大小是16GB,16106127360 个字节,31457280个扇区。 创建分区:(下图中指定起始扇区与/dev/sda2的结束扇区能对接上) nbsp; nbsp; 创建逻辑分区 Command (m for help): n Partition type: nbsp; nbsp;p nbsp; primary (3 primary, 0 extended, 1 free) nbsp; nbsp;e nbsp; extended Select (default e): e nbsp;nbsp;指定新建扩展分区 Selected partition 4 First sector (23068672-31457279, default 23068672):nbsp; Using default value 23068672 Last sector, +sectors or +size{K,M,G} (23068672-31457279, default 31457279): +1G nbsp;指定扩展分区的大小 Partition 4 of type Extended and of size 1 GiB is set Command (m for help): nnbsp; All primary partitions are in use Adding logical partition 5 nbsp; ID号1-4已经用完,系统直接使用逻辑分区ID的范围5-15 First sector (23070720-25165823, default 23070720):nbsp; Using default value 23070720 Last sector, +sectors or +size{K,M,G} (23070720-25165823, default 25165823): 24000000nbsp;nbsp;这里的结束扇区25165823-23070720=2095103*512/1024/1024=1022.99MB,即1GB,与指定的扩展分区大小相同 Partition 5 of type Linux and of size 453.8 MiB is setnbsp;新建逻辑分区的大小是453.8MB Command (m for help): n All primary partitions are in use Adding logical partition 6 First sector (24002049-25165823, default 24002560):nbsp; Using default value 24002560 Last sector, +sectors or +size{K,M,G} (24002560-25165823, default 25165823): nbsp;这里的结束扇区ID与上述的相同 Using default value 25165823 Partition 6 of type Linux and of size 568 MiB is set Command (m for help): p Disk /dev/sda: 16.1 GB, 16106127360 bytes, 31457280 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 Disk label type: dos Disk identifier: 0x000a72d4 nbsp; nbsp;Device Boot nbsp; nbsp; nbsp;Start nbsp; nbsp; nbsp; nbsp; End nbsp; nbsp; nbsp;Blocks nbsp; Id nbsp;System /dev/sda1 nbsp; * nbsp; nbsp; nbsp; nbsp;2048 nbsp; nbsp; 1026047 nbsp; nbsp; nbsp;512000 nbsp; 83 nbsp;Linux /dev/sda2 nbsp; nbsp; nbsp; nbsp; 1026048 nbsp; nbsp;20971519 nbsp; nbsp; 9972736 nbsp; 8e nbsp;Linux LVM /dev/sda3 nbsp; nbsp; nbsp; nbsp;20971520 nbsp; nbsp;23068671 nbsp; nbsp; 1048576 nbsp; 83 nbsp;Linux /dev/sda4 nbsp; nbsp; nbsp; nbsp;23068672 nbsp; nbsp;25165823 nbsp; nbsp; 1048576 nbsp; nbsp;5 nbsp;Extended /dev/sda5 nbsp; nbsp; nbsp; nbsp;23070720 nbsp; nbsp;24000000 nbsp; nbsp; nbsp;464640+ nbsp;83 nbsp;Linux /dev/sda6 nbsp; nbsp; nbsp; nbsp;24002560 nbsp; nbsp;25165823 nbsp; nbsp; nbsp;581632 nbsp; 83 nbsp;Linux nbsp;新建的逻辑分区 Command (m for help): wnbsp;保存退出 nbsp;检查linux是否已经识别出新的分区查看/rroc/paritions文件 [root@localhost ~]# cat /proc/partitionsnbsp; major minor nbsp;#blocks nbsp;name nbsp; nbsp;8 nbsp; nbsp; nbsp; nbsp;0 nbsp; 15728640 sda nbsp; nbsp;8 nbsp; nbsp; nbsp; nbsp;1 nbsp; nbsp; 512000 sda1 nbsp; nbsp;8 nbsp; nbsp; nbsp; nbsp;2 nbsp; nbsp;9972736 sda2 nbsp;新创建的/dev/sda3-6没有还没有识别出来 nbsp; 11 nbsp; nbsp; nbsp; nbsp;0 nbsp; nbsp;4228096 sr0 nbsp;253 nbsp; nbsp; nbsp; nbsp;0 nbsp; nbsp;8880128 dm-0 nbsp;253 nbsp; nbsp; nbsp; nbsp;1 nbsp; nbsp;1048576 dm-1 强制让内核更新分区 [root@localhost ~]# partx -u /dev/sdanbsp; [root@localhost ~]# cat /proc/partitionsnbsp; major minor nbsp;#blocks nbsp;name nbsp; nbsp;8 nbsp; nbsp; nbsp; nbsp;0 nbsp; 15728640 sda nbsp; nbsp;8 nbsp; nbsp; nbsp; nbsp;1 nbsp; nbsp; 512000 sda1 nbsp; nbsp;8 nbsp; nbsp; nbsp; nbsp;2 nbsp; nbsp;9972736 sda2 nbsp;nbsp;nbsp;8 nbsp; nbsp; nbsp; nbsp;3 nbsp; nbsp;1048576 sda3 nbsp; nbsp;8 nbsp; nbsp; nbsp; nbsp;4 nbsp; nbsp; nbsp; nbsp; nbsp;1 sda4 nbsp; nbsp;8 nbsp; nbsp; nbsp; nbsp;5 nbsp; nbsp; 464640 sda5 nbsp; nbsp;8 nbsp; nbsp; nbsp; nbsp;6 nbsp; nbsp; 581632 sda6nbsp;已识别出新分区 nbsp; 11 nbsp; nbsp; nbsp; nbsp;0 nbsp; nbsp;4228096 sr0 nbsp;253 nbsp; nbsp; nbsp; nbsp;0 nbsp; nbsp;8880128 dm-0 nbsp;253 nbsp; nbsp; nbsp; nbsp;1 nbsp; nbsp;1048576 dm-1 [root@localhost ~]#nbsp; 格式化新建的分区mkfs命令 nbsp; nbsp;nbsp;把sda6、sda5格式为ext4 [root@localhost ~]# mkfs.ext4 -L test /dev/sda6 mke2fs 1.42.9 (28-Dec-2013) Filesystem label=test OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 36400 inodes, 145408 blocks 7270 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=148897792 5 block groups 32768 blocks per group, 32768 fragments per group 7280 inodes per group Superblock backups stored on blocks:nbsp; 32768, 98304 Allocating group tables: done nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; Writing inode tables: done nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done 也可用 ext系列专用的格式化工具mke2fs [root@localhost ~]# mke2fs -t ext3 -m 5 -L TEST_sda5 -b 4096 /dev/sda5nbsp; mke2fs 1.42.9 (28-Dec-2013) Filesystem label=TEST_sda5nbsp;标识符为TEST_sda5 OS type: Linux Block size=4096 (log=2)nbsp;block为4096 Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 116224 inodes, 116160 blocks 5808 blocks (5.00%) reserved for the super usernbsp;为管理员预留5%的空间 First data block=0 Maximum filesystem blocks=121634816 4 block groups 32768 blocks per group, 32768 fragments per group 29056 inodes per group Superblock backups stored on blocks:nbsp; 32768, 98304 Allocating group tables: done nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; Writing inode tables: done nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done 查看所有分区的属性使用blkid [root@localhost ~]# blkidnbsp; /dev/sda1: UUID=quot;050a347a-4a99-4e80-a6b4-a4ed0a47eaa1quot; TYPE=quot;xfsquot;nbsp; /dev/sda2: UUID=quot;dv2Krn-BlSL-4NBt-yduR-BXax-tChJ-V2YpbMquot; TYPE=quot;LVM2_memberquot;nbsp; /dev/sda5: LABEL=quot;TEST_sda5quot; UUID=quot;b5b2b12b-236d-4578-845b-a5632ca5eafaquot; SEC_TYPE=quot;ext2quot; TYPE=quot;ext3quot; nbsp; /dev/sda6: LABEL=quot;testquot; UUID=quot;a0a549a2-0aec-4ff6-bce8-f2dfdfa1539equot; TYPE=quot;ext4quot; nbsp; /dev/sr0: UUID=quot;2015-12-09-23-14-10-00quot; LABEL=quot;CentOS 7 x86_64quot; TYPE=quot;iso9660quot; PTTYPE=quot;dosquot;nbsp; /dev/mapper/centos-root: UUID=quot;0adba78a-e1e3-4900-87c2-069105c6a1fcquot; TYPE=quot;xfsquot;nbsp; /dev/mapper/centos-swap: UUID=quot;2228d7dd-b7ed-44fb-9f68-668fc942a542quot; TYPE=quot;swapquot;nbsp; 使用fsck命令检测分区 [root@localhost ~]# fsck.ext3 -frc /dev/sda5 nbsp;nbsp; f是强制检测 nbsp;c是提示测试进度 r进行交互式检测 e2fsck 1.42.9 (28-Dec-2013) (编辑:徐州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |