Linux中对VPS的硬盘扩容后的分区记录
2015-01-06 12:53
381 查看
对新硬盘的分区,相对来说比较方便,也比较容易,因为不用担心原来的数据丢失等等问题,操作失败了,大不了重来,就这么简单,如果不清楚如何对新硬盘进行分区,可以查看一下这篇文章:Linux中对VPS新硬盘的分区示例以及如何进行分区的教程,我这里记录的是如何对原来已经存在的硬盘,对扩容部分进行的分区及挂载的记录。
linux中进行分区主要使用到三个工具:
fdisk:对分区信息进行查看,以及对分区进行操作;
mkfs:对新分区进行格式化;
mount:这个就是对分区后的硬盘进行挂载,只有挂载到指定的目录后,才可以被正常使用。
因为是对已经存在的硬盘进行再分区,那操作就相对要小心、仔细一点,首先通过命令 “fdisk -l”查看所有的分区信息,显示如下:
root@MyVPS2282:/dev# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x000a5e58
Device Boot Start End Blocks Id System
/dev/sda1 * 1 32 248832 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 32 1045 8136705 5 Extended
/dev/sda3 1045 1305 2094828+ 8e Linux LVM
/dev/sda5 32 1045 8136704 8e Linux LVM
Disk /dev/sdb: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x9d47bcdd
Device Boot Start End Blocks Id System
/dev/sdb1 1 3916 31455238+ 83 Linux
从列出来的结果可以看到,当前两块磁盘sda和sdb,sda的空间大小是10.7G,分了5个区,基本上是使用完了;第二块磁盘sdb有64.4G,而我们看到标红字的显示只使用了30个G,那说明还有30个G没有使用,那这没有使用的30个G就是新增加的30个G硬盘空间了,这时我们要做的就是把sdb中剩余的30个G给分出来。打入命令:
root@MyVPS2282:/dev# fdisk /dev/sdb
Command (m for help): n (n表示新创建新区,如果不知道命令如何使用,先打入m先查看帮助)
Command action
e extended
p primary partition (1-4)
(以上是让选择创建主分区还是扩展,我这里刚开始选择创建的是扩展分区,因为原来的30个G我创建的主分区,但是后面通过mkfs创建文件系统的时候会报错,所以这里我后来是删除了创建的扩展分区,重新选择创建主分区才成功)
p (选择创建主分区)
Partition number (1-4): 2 (通过命令fdisk -l例出来的分区信息可以看到,已经sdb已经分了第一个区sdb1,因而这里必须输入大于1的数字,否则系统会提示你输入的分区号已经存在,要求重新输入)
First cylinder (3917-7832, default 3917): (让选择是从磁盘的那个位置开始创建,这里可以不需要输入,直接回车即可,默认为从上个分区的结束位置开始)
Using default value 3917
Last cylinder, +cylinders or +size{K,M,G} (3917-7832, default 7832):(选择硬盘结束位置,如果不想再分其它区了,直接回车即可,默认为剩余的所有磁盘空间)
Using default value 7832
Command (m for help): w (保存分区信息并退出,下面是一些提示信息)
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
最后这一行的提示是说,需要重新启动系统,分区才可以生效,如果这个时候不重启系统,直接通过mkfs创建文件系统,系统会报错:
mke2fs 1.41.12 (17-May-2010)
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).
那就乖乖的重启系统吧。
重启后,再通过:
mkfs -t exts /dev/sdb2
对新分区创建文件系统,分有如下提示:
ke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1966080 inodes, 7863817 blocks
393190 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
240 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
到此,分区就创建成功了,这个需要只需要将其挂载到指定的目录即可:
mount /dev/sdb2 /aaa
当然为了能够在下次启动的时候,让其自动挂载,我们需要在分区表中加入如下信息:
/dev/sdb2 /aaa ext3 defaults 1 2
分区表的文件位于:/etc/fstab
通过df命令就可以看到我们挂载后的分区了,至此分区成功完成。
本文出自:冯立彬的博客
linux中进行分区主要使用到三个工具:
fdisk:对分区信息进行查看,以及对分区进行操作;
mkfs:对新分区进行格式化;
mount:这个就是对分区后的硬盘进行挂载,只有挂载到指定的目录后,才可以被正常使用。
因为是对已经存在的硬盘进行再分区,那操作就相对要小心、仔细一点,首先通过命令 “fdisk -l”查看所有的分区信息,显示如下:
root@MyVPS2282:/dev# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x000a5e58
Device Boot Start End Blocks Id System
/dev/sda1 * 1 32 248832 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 32 1045 8136705 5 Extended
/dev/sda3 1045 1305 2094828+ 8e Linux LVM
/dev/sda5 32 1045 8136704 8e Linux LVM
Disk /dev/sdb: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x9d47bcdd
Device Boot Start End Blocks Id System
/dev/sdb1 1 3916 31455238+ 83 Linux
从列出来的结果可以看到,当前两块磁盘sda和sdb,sda的空间大小是10.7G,分了5个区,基本上是使用完了;第二块磁盘sdb有64.4G,而我们看到标红字的显示只使用了30个G,那说明还有30个G没有使用,那这没有使用的30个G就是新增加的30个G硬盘空间了,这时我们要做的就是把sdb中剩余的30个G给分出来。打入命令:
root@MyVPS2282:/dev# fdisk /dev/sdb
Command (m for help): n (n表示新创建新区,如果不知道命令如何使用,先打入m先查看帮助)
Command action
e extended
p primary partition (1-4)
(以上是让选择创建主分区还是扩展,我这里刚开始选择创建的是扩展分区,因为原来的30个G我创建的主分区,但是后面通过mkfs创建文件系统的时候会报错,所以这里我后来是删除了创建的扩展分区,重新选择创建主分区才成功)
p (选择创建主分区)
Partition number (1-4): 2 (通过命令fdisk -l例出来的分区信息可以看到,已经sdb已经分了第一个区sdb1,因而这里必须输入大于1的数字,否则系统会提示你输入的分区号已经存在,要求重新输入)
First cylinder (3917-7832, default 3917): (让选择是从磁盘的那个位置开始创建,这里可以不需要输入,直接回车即可,默认为从上个分区的结束位置开始)
Using default value 3917
Last cylinder, +cylinders or +size{K,M,G} (3917-7832, default 7832):(选择硬盘结束位置,如果不想再分其它区了,直接回车即可,默认为剩余的所有磁盘空间)
Using default value 7832
Command (m for help): w (保存分区信息并退出,下面是一些提示信息)
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
最后这一行的提示是说,需要重新启动系统,分区才可以生效,如果这个时候不重启系统,直接通过mkfs创建文件系统,系统会报错:
mke2fs 1.41.12 (17-May-2010)
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).
那就乖乖的重启系统吧。
重启后,再通过:
mkfs -t exts /dev/sdb2
对新分区创建文件系统,分有如下提示:
ke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1966080 inodes, 7863817 blocks
393190 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
240 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
到此,分区就创建成功了,这个需要只需要将其挂载到指定的目录即可:
mount /dev/sdb2 /aaa
当然为了能够在下次启动的时候,让其自动挂载,我们需要在分区表中加入如下信息:
/dev/sdb2 /aaa ext3 defaults 1 2
分区表的文件位于:/etc/fstab
通过df命令就可以看到我们挂载后的分区了,至此分区成功完成。
本文出自:冯立彬的博客
相关文章推荐
- Linux中对VPS的硬盘扩容后的分区记录
- CentOS 6.3 卷组挂载硬盘教程 linux的VPS如何分区
- 给Vmware进行硬盘(分区)无损扩容 (linux)
- 新增硬盘扩容Linux下的分区大小
- Linux LVM硬盘管理及LVM分区扩容
- 在Linux系统的VPS上对硬盘进行分区、格式化和挂载的方法
- Linux 入门记录:六、Linux 硬件相关概念(硬盘、磁盘、磁道、柱面、磁头、扇区、分区、MBR、GPT)
- linux ext3支持2T以上大硬盘分区
- Linux下添加新硬盘及分区格式化要点
- linux下恢复硬盘分区数据
- linux下分区、格式化、挂载新硬盘的详细过程
- 如何在Linux中访问硬盘DOS分区、软盘和光盘
- Linux下添加新硬盘及分区格式化要点
- Linux下添加硬盘,分区,格式化详解
- linux -- 备份硬盘mbr记录
- linux 中新增加硬盘及扩展SWAP交换分区
- Ubuntu/Fedora linux加载硬盘及备份硬盘记录
- Linux下添加硬盘,分区,格式化
- 硬盘第一个基本分区c 的 ntfs格式的XP上 安装 windows和linux 双引导 设置grub(安装WINGRUB),
- 新手学堂:Linux操作系统下进行硬盘扩容