Linux_Centos6_新增硬盘分区,格式化和加载
2018-02-08 17:21
197 查看
Linux_Centos6_新增硬盘分区,格式化和加载
此次操作是在VM虚拟机环境中进行:- 首先需要添加一块硬盘–>点击编辑虚拟机设置–>点击弹框下面的添加–>选择硬盘–>点击下一步
- 选择SCSI类型–>点击下一步
- 默认–>下一步
- 选择下面的多文件–>下一步
- 点击完成–>确定–>左边的虚拟机就会多一块20G的硬盘
然后虚拟机开机,在进行分区操作之前先简单介绍下磁盘分区工具fdisk,有几个常用的命令,例:
fdisk + 新增磁盘:对指定的硬盘进行分区操作
fdisk -l :显示指定硬盘分区表信息
fdisk -d:删除一个硬盘分区
fdisk -n:创建一个分区
fdisk -p:列出硬盘分区表
fdisk -q:退出fdisk,不保存更改
fdisk -w:把设置写入硬盘分区表,然后退出。
介绍完命令我们开始操作,首先查看一下我们现在的分区情况
[root@root ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda6 17G 3.2G 13G 20% / tmpfs 503M 72K 503M 1% /dev/shm /dev/sda1 504M 39M 440M 9% /boot /dev/sda2 5.8G 140M 5.4G 3% /home /dev/sda3 4.9G 222M 4.4G 5% /var [root@root ~]# fdisk -l Disk /dev/sda: 32.2 GB, 32212254720 bytes #第一块硬盘30G 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0007c967 #具体的分区情况 Device Boot Start End Blocks Id System /dev/sda1 * 1 66 524288 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 66 831 6144000 83 Linux Partition 2 does not end on cylinder boundary. /dev/sda3 831 1468 5120000 83 Linux /dev/sda4 1468 3917 19667968 5 Extended /dev/sda5 1468 1723 2048000 82 Linux swap / Solaris /dev/sda6 1723 3917 17617920 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes #这是新增的20G硬盘 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
现在进行分区,我这次练习分为1个主分区,4个逻辑分区,主分区大小为8G,逻辑分区大小分别为2G、3G、3G、2G
[root@root ~]# fdisk /dev/sdb #执行分区命令 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x543c4b70. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 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 #N 新建分区 Command action e extended p primary partition (1-4) p #P 主分区 E 扩展分区 Partition number (1-4): 1 #分区号 输入1 First cylinder (1-2610, default 1): #默认 Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +8G #sdb1 分8G Command (m for help): w # W 保存 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@root ~]# fdisk -l # 我这里分完主分区先看看,毕竟操作不熟想保险一点,你们也可以做完主分区继续往下操作 Disk /dev/sda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0007c967 Device Boot Start End Blocks Id System /dev/sda1 * 1 66 524288 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 66 831 6144000 83 Linux Partition 2 does not end on cylinder boundary. /dev/sda3 831 1468 5120000 83 Linux /dev/sda4 1468 3917 19667968 5 Extended /dev/sda5 1468 1723 2048000 82 Linux swap / Solaris /dev/sda6 1723 3917 17617920 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x543c4b70 Device Boot Start End Blocks Id System /dev/sdb1 1 1045 8393931 83 Linux [root@root ~]# 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): 2 #分区号 2 First cylinder (1046-2610, default 1046): Using default value 1046 Last cylinder, +cylinders or +size{K,M,G} (1046-2610, default 2610): #这里扩展分区的容量什么都不写,默认所有 Using default value 2610 Command (m for help): n #新建 Command action l logical (5 or over) p primary partition (1-4) l #L 逻辑分区 First cylinder (1046-2610, default 1046): Using default value 1046 Last cylinder, +cylinders or +size{K,M,G} (1046-2610, default 2610): +2G #2G Command (m for help): n #新建 Command action l logical (5 or over) p primary partition (1-4) l #L 逻辑分区 First cylinder (1308-2610, default 1308): Using default value 1308 Last cylinder, +cylinders or +size{K,M,G} (1308-2610, default 2610): +3G #3G Command (m for help): n #新建 Command action l logical (5 or over) p primary partition (1-4) l #L 逻辑分区 First cylinder (1701-2610, default 1701): Using default value 1701 Last cylinder, +cylinders or +size{K,M,G} (1701-2610, default 2610): +3G #3G Command (m for help): n #新建 Command action l logical (5 or over) p primary partition (1-4) l #L 逻辑分区 First cylinder (2094-2610, default 2094): Using default value 2094 Last cylinder, +cylinders or +size{K,M,G} (2094-2610, default 2610): +2G #2G Command (m for help): w #W 保存 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
到这里所有分区就完了,再看一眼分区
[root@root ~]# fdisk -l Disk /dev/sda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0007c967 Device Boot Start End Blocks Id System /dev/sda1 * 1 66 524288 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 66 831 6144000 83 Linux Partition 2 does not end on cylinder boundary. /dev/sda3 831 1468 5120000 83 Linux /dev/sda4 1468 3917 19667968 5 Extended /dev/sda5 1468 1723 2048000 82 Linux swap / Solaris /dev/sda6 1723 3917 17617920 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x543c4b70 Device Boot Start End Blocks Id System /dev/sdb1 1 1045 8393931 83 Linux /dev/sdb2 1046 2610 12570862+ 5 Extended /dev/sdb5 1046 1307 2104483+ 83 Linux /dev/sdb6 1308 1700 3156741 83 Linux /dev/sdb7 1701 2093 3156741 83 Linux /dev/sdb8 2094 2355 2104483+ 83 Linux
下面进行格式化操作
[root@root ~]# mkfs.ext4 /dev/sdb1 #以EXT4分区格式 格式化sdb1 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 525200 inodes, 2098482 blocks 104924 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=2151677952 65 block groups 32768 blocks per group, 32768 fragments per group 8080 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 正在写入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 37 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@root ~]# mkfs.ext4 /dev/sdb2 mke2fs 1.41.12 (17-May-2010) mkfs.ext4: 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@root ~]# mkfs.ext4 /dev/sdb5 #以EXT4分区格式 格式化sdb5 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526120 blocks 26306 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 正在写入inode表: 完成 Creating journal (16384 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 39 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@root ~]# mkfs.ext4 /dev/sdb6 #以EXT4分区格式 格式化sdb6 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 197600 inodes, 789185 blocks 39459 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=809500672 25 block groups 32768 blocks per group, 32768 fragments per group 7904 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 正在写入inode表: 完成 Creating journal (16384 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 23 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@root ~]# mkfs.ext4 /dev/sdb7 #以EXT4分区格式 格式化sdb7 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 197600 inodes, 789185 blocks 39459 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=809500672 25 block groups 32768 blocks per group, 32768 fragments per group 7904 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 正在写入inode表: 完成 Creating journal (16384 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 34 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@root ~]# mkfs.ext4 /dev/sdb8 #以EXT4分区格式 格式化sdb8 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526120 blocks 26306 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 正在写入inode表: 完成 Creating journal (16384 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 38 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
下面进行挂载操作,先创建挂载点,再挂载
[root@root ~]# mkdir /tmp/sdb{1,5,6,7,8} #创建5个区的挂载点;分别挂载 [root@root ~]# mount /dev/sdb1 /tmp/sdb1 [root@root ~]# mount /dev/sdb5 /tmp/sdb5 [root@root ~]# mount /dev/sdb6 /tmp/sdb6 [root@root ~]# mount /dev/sdb7 /tmp/sdb7 [root@root ~]# mount /dev/sdb8 /tmp/sdb8
再次查看分区
[root@root ~]# fdisk -l Disk /dev/sda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0007c967 Device Boot Start End Blocks Id System /dev/sda1 * 1 66 524288 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 66 831 6144000 83 Linux Partition 2 does not end on cylinder boundary. /dev/sda3 831 1468 5120000 83 Linux /dev/sda4 1468 3917 19667968 5 Extended /dev/sda5 1468 1723 2048000 82 Linux swap / Solaris /dev/sda6 1723 3917 17617920 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x543c4b70 Device Boot Start End Blocks Id System /dev/sdb1 1 1045 8393931 83 Linux /dev/sdb2 1046 2610 12570862+ 5 Extended /dev/sdb5 1046 1307 2104483+ 83 Linux /dev/sdb6 1308 1700 3156741 83 Linux /dev/sdb7 1701 2093 3156741 83 Linux /dev/sdb8 2094 2355 2104483+ 83 Linux
[root@root ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 17G 3.2G 13G 20% /
tmpfs 503M 72K 503M 1% /dev/shm
/dev/sda1 504M 39M 440M 9% /boot
/dev/sda2 5.8G 140M 5.4G 3% /home
/dev/sda3 4.9G 222M 4.4G 5% /var
/dev/sdb1 7.9G 147M 7.4G 2% /tmp/sdb1
/dev/sdb5 2.0G 68M 1.9G 4% /tmp/sdb5
/dev/sdb6 3.0G 69M 2.8G 3% /tmp/sdb6
/dev/sdb7 3.0G 69M 2.8G 3% /tmp/sdb7
/dev/sdb8 2.0G 68M 1.9G 4% /tmp/sdb8
到这里这次练习就结束了,希望可以和小伙伴们多多交流。
QQ:754124306
相关文章推荐
- linux_文件系统管理、新增硬盘分区格式化
- linux 新增硬盘分区格式化
- Linux 空闲空间的格式化与加载
- linux 硬盘分区,分区,删除分区,格式化,挂载,卸载笔记
- Linux分区、格式化、加载磁盘
- Linux 空闲空间的格式化与加载
- Linux硬盘分区格式化の硬盘初始化一
- Linux 硬盘分区格式化
- Linux 硬盘分区格式化
- linux 硬盘分区,分区,删除分区,格式化,挂载,卸载笔记
- Linux存储管理及硬盘分区、格式化、挂载
- linux 硬盘分区,分区,删除分区,格式化,挂载,卸载
- Linux 硬盘分区、格式化、自动挂载配置
- linux 下添加新硬盘设备和硬盘分区格式化挂载使用磁盘配额限制
- Linux格式化并重新加载磁盘
- linux下查看硬盘信息、硬盘分区、格式化、挂载、及swap分区
- Linux中新增硬盘的分区,格式化与挂载
- Linux实例新增磁盘->格式化->分区->挂载->卸载案例参考
- Linux基础——硬盘分区、格式化及文件系统的管理
- 关于Linux VPS硬盘分区、格式化、挂载