博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
磁盘分区(20G升50G)
阅读量:5961 次
发布时间:2019-06-19

本文共 25874 字,大约阅读时间需要 86 分钟。

 

  不多说,直接上干货!

 

 

本博文的主要内容有

  .磁盘分区的概述

  .常用的磁盘管理工具

      ./下分5G,给/home扩容

    .系统自带的fdisk和parted这两款工具

  .磁盘空间管理

 

 

 

前言

  系统自带的fdisk和parted这两款工具,可以为我们提供更方便地对磁盘空间进行查看和管理的能力,也可以使用带-l选项的fdisk命令来查看某块磁盘上更新详细的信息。

  

 

 

磁盘分区的概述

  磁盘由两个分区组成,即分为主分区和扩展分区,扩展分区又可由多个逻辑分区组成。

   我们在安装linux系统时,若使用自动分区的方式进行磁盘分区,系统则将自动将分成两个分区,即根分区/和交换分区swap。交换分区的作用是充当虚拟内存,主要是物理内存不足时用于暂时对数据进行保存,并在需要时进行调用。由于交换分区只能用于暂时数据的存储,因此系统还必须有一股分区用于长期存储文件及数据。

  Linux系统下的磁盘类型有IDE和SCSI这两种。当然,这些磁盘设备也被映射到一个系统文件上。对于这两种磁盘的命名方式,IDE的命名方式采用/dec/hdx(x代表磁盘快),而其下的分区则是/dec/hdxy(y代表该磁盘块上的分区号).SCSI则采用/dev/sdx,其下的分区是/dev/sdxy。

 

  对于Linux的磁盘分区,至少要有/分区、boot分区和swap分区。否则,安装会受阻,考虑到实际的工作环境及后期对磁盘的维护(如后期磁盘空间需要扩容,在Linux系统下安装Oracle数据库)等。Linux磁盘分区的格式建议是LVM格式,而设计Oracle的安装时,swap分区往往与物理内存对应,因此在实际的工作环境下安装系统时应该做好分区工作。

 

 

 

 

  推荐

            下载地址:

 

    磁盘管理工具是系统管理员需要经常使用的软件,是完成磁盘管理的重要手段。常用的磁盘管理工具包括:fdisk、Partition Magic、parted、mkfs和e2fsck。

           使用partprobe重载分区也只能是对不同的硬盘才能及时生效。对于同一块硬盘,修改过分区信息后,必须重启系统才能使修改过的分区信息生效。(比如,SCSI硬盘和IDE硬盘。)

 

 

 

 

 

 

问题的描述

 

  可以看出,我的虚拟机里的这个系统,因之前,在安装分区时,未考虑周到,/home的容量太小了,现在,我想,希望从/下分5G容量给/home?

或者,新建一磁盘,来进行对分区的扩容。(实则,是想从/dev/sdb扩容5G到/dev/sda下的/home)。求解!!!

 

 

 

   流程:添加磁盘   ->   使用fdisk创建磁盘分区   ->  使用parted工具创建分区     ->    挂载磁盘分区到系统 

 

 

 

 

 

 

 

 

 

  1、使用fdisk -l查询当前系统分区情况

 

[root@weekend110 ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/sda5        16G  3.7G   12G  25% /tmpfs           931M  232K  931M   1% /dev/shm/dev/sda1       194M   30M  155M  16% /boot/dev/sda2       2.9G  2.8G     0 100% /home/dev/sr0        4.2G  4.2G     0 100% /media/CentOS_6.5_Final[root@weekend110 ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000491de    Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1          26      204800   83  LinuxPartition 1 does not end on cylinder boundary./dev/sda2              26         409     3072000   83  LinuxPartition 2 does not end on cylinder boundary./dev/sda3             409         536     1024000   82  Linux swap / SolarisPartition 3 does not end on cylinder boundary./dev/sda4             536        2611    16669696    5  Extended/dev/sda5             536        2611    16668672   83  Linux[root@weekend110 ~]#

  可以看到新增加的sda磁盘还没有分区!!!

 

  重启机器,后,再次执行

[root@weekend110 ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/sda5        16G  3.7G   12G  25% /tmpfs           931M   72K  931M   1% /dev/shm/dev/sda1       194M   30M  155M  16% /boot/dev/sda2       2.9G  2.8G     0 100% /home[root@weekend110 ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000491de  想说的是,一看/dev/sda,就是原来的硬盘。     Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1          26      204800   83  LinuxPartition 1 does not end on cylinder boundary./dev/sda2              26         409     3072000   83  LinuxPartition 2 does not end on cylinder boundary./dev/sda3             409         536     1024000   82  Linux swap / SolarisPartition 3 does not end on cylinder boundary./dev/sda4             536        2611    16669696    5  Extended/dev/sda5             536        2611    16668672   83  Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000想说的是,一看/dev/sda,就是新增的硬盘。

 

 

 

 

 

[root@weekend110 ~]# ll /dev/sd*brw-rw----. 1 root disk 8, 0 Oct 18 20:04 /dev/sdabrw-rw----. 1 root disk 8, 1 Oct 18 20:04 /dev/sda1brw-rw----. 1 root disk 8, 2 Oct 18 20:04 /dev/sda2brw-rw----. 1 root disk 8, 3 Oct 18 20:04 /dev/sda3brw-rw----. 1 root disk 8, 4 Oct 18 20:04 /dev/sda4brw-rw----. 1 root disk 8, 5 Oct 18 20:04 /dev/sda5brw-rw----. 1 root disk 8, 16 Oct 18 20:04 /dev/sdb[root@weekend110 ~]# fdisk -l /dev/sdbDisk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000[root@weekend110 ~]#

 

  可见,该新增的磁盘/dec/sdb,上没有创建任何分区。

 

 

[root@weekend110 ~]# clear[root@weekend110 ~]# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0xace34bc7.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 toswitch off the mode (command 'c') and change display units tosectors (command 'u').Command (m for help): mCommand actiona toggle a bootable flag       //设置可引导的标记b edit bsd disklabel      //修改bsd磁盘的标签c toggle the dos compatibility flag    //设置dos的兼容性d delete a partition    //删除一个分区l list known partition types    //列出分区类型m print this menu    //显示帮助菜单n add a new partition    //添加一个新的分区o create a new empty DOS partition table    //创建一个新的、空的DOS分区表p print the partition table    //显示当前的分区表q quit without saving changes    //退出操作、不保存修改s create a new empty Sun disklabel    //创建一个新的、空的Sun磁盘标签t change a partition's system id    //更改系统分区id号u change display/entry units    //更改显示记录v verify the partition table    //对分区表进行验证w write table to disk and exit    //退出并保存所做的修改x extra functionality (experts only)    //特殊功能Command (m for help):

 

 

 

 

 

 

2.创建主分区

       因为,新增磁盘,是sdb。

fdisk /dev/sdb
输入n

[root@weekend110 ~]# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0xf5778f69.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): nCommand action   e   extended   p   primary partition (1-4)
 
提示说,输入p

Command (m for help): nCommand action   e   extended   p   primary partition (1-4)pPartition number (1-4): 1First cylinder (1-2610, default 1): 1Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +10G Command (m for help):
在输入结束柱面的这里如果你不知道该输入多大的数字,你可以输入+然后输入你要设的大小。这里我设置10G的主分区。

     输入p查看分区信息,可以看到刚创建的sdb1主分区。

Command (m for help): p        //查看当前分区表Disk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xc0585a2e   Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1        1306    10490413+  83  LinuxCommand (m for help):Command (m for help): w       //保存退出The partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@weekend110 ~]#

 

 

3、创建扩展分区

Command (m for help): nCommand action   e   extended   p   primary partition (1-4)ePartition number (1-4): 2First cylinder (1307-2610, default 1307): 1307Last cylinder, +cylinders or +size{K,M,G} (1307-2610, default 2610): 2610Command (m for help): p        //查看当前的分区表Disk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xc0585a2e   Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1        1306    10490413+  83  Linux/dev/sdb2            1307        2610    10474380    5  Extended Command (m for help):

  图片上通过红色标注了操作步骤。可以看到当前已创建了sdb2扩展分区,柱面从1037-2610,即将剩下的所有空间创建为扩展分区。

 

 

Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@weekend110 ~]#

 

 

 

4.创建逻辑分区

Command (m for help): nCommand action   l   logical (5 or over)   p   primary partition (1-4)lFirst cylinder (1307-2610, default 1307): 1307Last cylinder, +cylinders or +size{K,M,G} (1307-2610, default 2610): +2GCommand (m for help): nCommand action   l   logical (5 or over)   p   primary partition (1-4)lFirst cylinder (1569-2610, default 1569): 1560^HValue out of range.First cylinder (1569-2610, default 1569): 1569Last cylinder, +cylinders or +size{K,M,G} (1569-2610, default 2610): 2610 Command (m for help): pDisk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xc0585a2e    Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1        1306    10490413+  83  Linux/dev/sdb2            1307        2610    10474380    5  Extended/dev/sdb5            1307        1568     2104483+  83  Linux/dev/sdb6            1569        2610     8369833+  83  LinuxCommand (m for help):

    总共创建了两个逻辑分区,逻辑分区默认从5开始,第一个逻辑分区大小2G,用来做交换分区用,剩下全部给sdb6.

 

Command (m for help): pDisk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xace34bc7Device Boot Start End Blocks Id System/dev/sdb1 1 1306 10490413+ 83 Linux/dev/sdb2 1307 2610 10474380 5 Extended/dev/sdb5 1307 1568 2104483+ 83 Linux/dev/sdb6 1569 2610 8369833+ 83 LinuxCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@weekend110 ~]#

 

 

 

5、修改文件类型ID

  因为默认分区id都是83即linux文件类型,现在将sdb5的文件类型ID改成82即交换分区。

Command (m for help): tPartition number (1-6): 5Hex code (type L to list codes): 82Changed system type of partition 5 to 82 (Linux swap / Solaris) Command (m for help): pDisk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xc0585a2e    Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1        1306    10490413+  83  Linux/dev/sdb2            1307        2610    10474380    5  Extended/dev/sdb5            1307        1568     2104483+  82  Linux swap / Solaris/dev/sdb6            1569        2610     8369833+  83  LinuxCommand (m for help):

 

 

6、保存退出

Command (m for help): mCommand action   a   toggle a bootable flag   b   edit bsd disklabel   c   toggle the dos compatibility flag   d   delete a partition   l   list known partition types   m   print this menu   n   add a new partition   o   create a new empty DOS partition table   p   print the partition table   q   quit without saving changes   s   create a new empty Sun disklabel   t   change a partition's system id   u   change display/entry units   v   verify the partition table   w   write table to disk and exit   x   extra functionality (experts only) Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@weekend110 ~]#

 

 

 

7.格式化分区

  接下来要对sdb的每一个分区进行格式化,
  注意:扩展分区不需要进行格式

[root@weekend110 ~]# mkfs.ext4 /dev/sdb1mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks655776 inodes, 2622603 blocks131130 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=268854886481 block groups32768 blocks per group, 32768 fragments per group8096 inodes per groupSuperblock backups stored on blocks:        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Writing inode tables: done                           Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 25 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.[root@weekend110 ~]#[root@weekend110 ~]# mkfs.ext4 /dev/sdb1或者[root@weekend110 ~]# mkfs -t ext4 /dev/sdb1是等价的。

 

 

[root@weekend110 ~]# mkfs -t ext4 /dev/sdb1mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks655776 inodes, 2622603 blocks131130 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=268854886481 block groups32768 blocks per group, 32768 fragments per group8096 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 23 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@weekend110 ~]#

 

 

 

 

[root@weekend110 ~]# mkfs.ext4 /dev/sdb6mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks523264 inodes, 2092458 blocks104622 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=214328934464 block groups32768 blocks per group, 32768 fragments per group8176 inodes per groupSuperblock backups stored on blocks:        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Writing inode tables: done                            Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 25 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.[root@weekend110 ~]#

 

 

swap分区格式化要使用

mkswap /dev/sdb5          mkswap,是mkdir swap。

 

[root@weekend110 ~]# mkswap /dev/sdb5Setting up swapspace version 1, size = 2104476 KiBno label, UUID=d28dfa28-7303-463a-ae0c-b1751786c656[root@weekend110 ~]#

 

 

加载文件
swapon /dev/sdb5
查看是否生效
swapon -s

[root@weekend110 ~]# swapon /dev/sdb5[root@weekend110 ~]# swapon -sFilename                                Type            Size    Used    Priority/dev/sda3                               partition       1023992 0       -1/dev/sdb5                               partition       2104472 0       -2[root@weekend110 ~]#

  可以看到sda3,和sdb5这两个swap分区。

 

 

8.挂载分区

   这里直接使用修改文件的方式永久挂载

创建挂载文件路径
mkdir sdb1 sdb6

[root@weekend110 ~]# mkdir sdb1 sdb6[root@weekend110 ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/sda5        16G  3.7G   12G  25% /tmpfs           931M   72K  931M   1% /dev/shm/dev/sda1       194M   30M  155M  16% /boot/dev/sda2       2.9G  2.8G     0 100% /home[root@weekend110 ~]#

 

 

## /etc/fstab# Created by anaconda on Mon Jul 18 18:45:01 2016## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#UUID=f664c4a8-f9ea-4999-b914-4071e8efdff2 /                       ext4    defaults        1 UUID=2da787fb-94f8-4f6a-8d75-15d66628c818 /boot                   ext4    defaults        1 2UUID=77fd7f45-c1e6-4014-a21e-75fe308e7edd /home                   ext4    defaults        1 2UUID=98519c68-56ea-450e-b2e7-ca329d379e05 swap                    swap    defaults        0 0tmpfs                   /dev/shm                tmpfs   defaults        0 0devpts                  /dev/pts                devpts  gid=5,mode=620  0 0sysfs                   /sys                    sysfs   defaults        0 0proc                    /proc                   proc    defaults        0 0/dev/sdb1               /sdb1                   ext4    defaults        0 0/dev/sdb5               swap                    swap    defaults        0 0/dev/sdb6               /sdb6                   ext4    defaults        0 0

 

 

 

9.立即生效

partprobe

[root@weekend110 ~]# partprobeWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Error: Invalid partition table - recursive partition on /dev/sr0.[root@weekend110 ~]#

 

  在我的虚拟机上面无法立即生效,重启机器。

shutdown -r now

[root@weekend110 ~]# shutdown -r nowBroadcast message from root@weekend110        (/dev/pts/0) at 23:58 ...The system is going down for reboot NOW![root@weekend110 ~]#

 

  没生效,那是因为,遇到了

  Error: Invalid partition table - recursive partition on /dev/sr0.

 

 

参考博客:

 

  决方法:执行partprobe 命令

  partprobe包含在parted的rpm软件包中。

  partprobe可以修改kernel中分区表,使kernel重新读取分区表。 

  因此,使用该命令就可以创建分区并且在不重新启动机器的情况下系统能够识别这些分区。

 

 

 

 

[root@weekend110 ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/sda5        16G  3.7G   12G  25% /tmpfs           931M   72K  931M   1% /dev/shm/dev/sda1       194M   30M  155M  16% /boot/dev/sda2       2.9G  2.8G     0 100% /home [root@weekend110 ~]# partprobeWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Error: Invalid partition table - recursive partition on /dev/sr0.[root@weekend110 ~]# rpm -q partedparted-2.1-21.el6.x86_64[root@weekend110 ~]# partprobeWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Error: Invalid partition table - recursive partition on /dev/sr0.[root@weekend110 ~]# mkfs -t ext4 /dev/sr0mke2fs 1.41.12 (17-May-2010)/dev/sr0 is entire device, not just one partition!Proceed anyway? (y,n) y/dev/sr0: Read-only file system while setting up superblock[root@weekend110 ~]# partprobeWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Error: Invalid partition table - recursive partition on /dev/sr0.[root@weekend110 ~]#

  出现这个问题,我查阅了一些资料,如

  主要是因为是使用的虚拟机,如果是直接在Linux系统上,不会出现这个问题。

 

  如:

  在虚拟机中把光驱移除后,重新进入虚拟机新建分区,并通过partprobe重载分区,就没有/dev/sr0 出现递归分区的错误信息了。

 

[root@weekend110 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda5 16G 3.7G 12G 25% /tmpfs 931M 72K 931M 1% /dev/shm/dev/sda1 194M 30M 155M 16% /boot/dev/sda2 2.9G 2.3G 524M 82% /home[root@weekend110 ~]# partprobeWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.

  但是仍然提示重载分区不成功,提示设备或资源忙,需要重启生效。

  直接格式化新建的分区,提示找不到新建的/dev/sdb分区。
  重启系统后,在格式化新建的分区/dev/sdb,成功。

 

[root@weekend110 ~]# partprobeWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.[root@weekend110 ~]# mkfs -t ext4 /dev/sdb        //分区格式化mke2fs 1.41.12 (17-May-2010)/dev/sdb is entire device, not just one partition!Proceed anyway? (y,n) y/dev/sdb is apparently in use by the system; will not make a filesystem here!

 

 

再次尝试,

[root@weekend110 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda5 16G 3.7G 12G 25% /tmpfs 931M 72K 931M 1% /dev/shm/dev/sda1 194M 30M 155M 16% /boot/dev/sda2 2.9G 2.3G 524M 82% /home[root@weekend110 ~]# partprobeWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.[root@weekend110 ~]# mkfs -t ext4 /dev/sdb1      //格式化主分区mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks655776 inodes, 2622603 blocks131130 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=268854886481 block groups32768 blocks per group, 32768 fragments per group8096 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 39 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@weekend110 ~]# mkfs -t ext4 /dev/sdb5mke2fs 1.41.12 (17-May-2010)/dev/sdb5 is mounted; will not make a filesystem here![root@weekend110 ~]# mkfs -t ext4 /dev/sdb6mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks523264 inodes, 2092458 blocks104622 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=214328934464 block groups32768 blocks per group, 32768 fragments per group8176 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 36 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@weekend110 ~]# partprobeWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.[root@weekend110 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda5 16G 3.7G 12G 25% /tmpfs 931M 72K 931M 1% /dev/shm/dev/sda1 194M 30M 155M 16% /boot/dev/sda2 2.9G 2.3G 524M 82% /home[root@weekend110 ~]#

 

  依然,还是解决不了。

    

 

 

[root@weekend110 ~]# mount /dev/sdb1 /home      //挂载分区/dev/sdb1到挂载点/home[root@weekend110 ~]# mount/dev/sda5 on / type ext4 (rw)proc on /proc type proc (rw)sysfs on /sys type sysfs (rw)devpts on /dev/pts type devpts (rw,gid=5,mode=620)tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")/dev/sda1 on /boot type ext4 (rw)/dev/sda2 on /home type ext4 (rw)none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)/dev/sdb1 on /home type ext4 (rw)[root@weekend110 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda5 16G 3.7G 12G 25% /tmpfs 931M 72K 931M 1% /dev/shm/dev/sda1 194M 30M 155M 16% /boot/dev/sda2 9.9G 151M 9.3G 2% /home/dev/sdb1 9.9G 151M 9.3G 2% /home[root@weekend110 ~]#

   至于,删除磁盘分区,为什么呢?

  答:在实际工作中,我们需要创建的分区来存放不同的数据和文件。当这些数据不再需要时,这个专门存储这些数据和文件的分区几乎没有存在的意义。而对于这些没有存在意义的分区,则需要将其删除,方便管理分区。

  删除磁盘分区,很简单,这里不多赘述。

 

 

 

 

 

 

 

      后面我在自己实验室里,尝试成功。如下

 

 

 

 

 

磁盘空间管理

  不论是操作系统的磁盘空间有多大,在使用过程中可用空间总会不断减小,虽然在磁盘空间已满的情况下可把数据另存到其他的磁盘,但在实际的生产环境下,数据是连续的,因此对于某个位置下的数据,是不能将其中的某些部分移到其他的磁盘中存放的。

  要保证数据的连续性,而磁盘的可用空间又不断减少,虽然可用加磁盘,但并不能保证数据的连续性。而且对于海量的数据,仅靠单个磁盘的空间是不能存储的,即使使用多块磁盘拼接在一起形成RIAD即廉价磁盘冗余阵列,固定的磁盘空间也并不能无限地存储不断增长的数据。

  对于这个问题,在Linux系统中可以使用逻辑卷的方式来解决。Linux系统支持对逻辑卷空间不断地扩展,并且实现在线的方式扩展。

 

 

1、磁盘分区扩容

2、扩展交换分区空间

 

 参考博客:  

        

        

         

        

 

 

 

 

 

 

 

欢迎大家,加入我的微信公众号:大数据躺过的坑        人工智能躺过的坑
 
 
 

同时,大家可以关注我的个人博客

   http://www.cnblogs.com/zlslch/   和     http://www.cnblogs.com/lchzls/      http://www.cnblogs.com/sunnyDream/   

   详情请见:http://www.cnblogs.com/zlslch/p/7473861.html

 

  人生苦短,我愿分享。本公众号将秉持活到老学到老学习无休止的交流分享开源精神,汇聚于互联网和个人学习工作的精华干货知识,一切来于互联网,反馈回互联网。

  目前研究领域:大数据、机器学习、深度学习、人工智能、数据挖掘、数据分析。 语言涉及:Java、Scala、Python、Shell、Linux等 。同时还涉及平常所使用的手机、电脑和互联网上的使用技巧、问题和实用软件。 只要你一直关注和呆在群里,每天必须有收获

 

      对应本平台的讨论和答疑QQ群:大数据和人工智能躺过的坑(总群)(161156071) 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的文章
龙芯将两款 CPU 核开源,这意味着什么?
查看>>
《51单片机应用开发从入门到精通》——导读
查看>>
iOS深拷贝与浅拷贝
查看>>
mysql5.6参数说明
查看>>
[转]线程安全的单例模式
查看>>
winfrom的打开窗口特效
查看>>
IOS(swift)-数据存储 · NSKeyedArchiver 归档
查看>>
TypeScript 入门指南
查看>>
mysql报错 Data truncated for column 'from' at row 1
查看>>
Monkey test确定package name的一种特殊方法
查看>>
ubuntu 12.04.4 安装 devstack
查看>>
windows10:一些虚拟化功能与vmware冲突
查看>>
JXL导出Excel数据表
查看>>
数据库字段加1
查看>>
GNOME是最好的!
查看>>
Nginx 的软件负载均衡详解
查看>>
往事两三则
查看>>
使用LiveData和DataBinding进行双向绑定
查看>>
Convert Url to InetAddress
查看>>
oracle 限制特定ip登录
查看>>