本篇文章给大家谈谈怎么在linux扩展分区,以及linux如何扩展分区对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
1、linux系统标准分区如何扩容
硬盘快满了,加硬盘扩容,不管是独立的服务器,还是云空间新买的硬盘,扩容方式一样。下面以阿里VPS为例,详细说一下,挂载硬盘扩容的2种方法。
阿里VPS,个人觉得有以下二个方面需要改进
1,默认不是lvm,所以系统盘/dev/xvda1是不能扩容的,所以如果有大数据的东西,一开始就要考虑到扩容的问题。数据量越大,操作风险越大。
2,不能实现无缝扩容,也就是说,在后台扩容一下,不用登录到VPS,进行调整。非专业人士,扩容困难
2、linux如何扩展主分区
这里以Red hat AS4 为例。当磁盘分区发现不够用时,能想道的第一个做法就是增加分区大小。但是一般Linux如果没有采用逻辑卷管理,则动态增加分区大小很困难,一个能想道的办法就是,备份分区文件系统数据,删除分区,然后再重新创建分区,恢复备份的文件系统,这个做法比较玄,可能删除分区后导致系统无法启动。
第二个做法就是,创建一个新的逻辑分区(当然必须有未使用的磁盘空间能分配),将文件系统从老分区拷贝到新分区,然后修改fstab,使用新分区/文件系统替换老的分区/文件系统
第三种做法是,创建一个新的逻辑分区,将新的逻辑分区格式化ext3(或其他类型)的文件系统,mount到磁盘空间不够的文件系统,就跟原来的分区/文件系统一样的使用。
这里采用的是第三种方式:
sdb为第二个SCSI硬盘。
[root@hdp0 hadoop]# /sbin/fdisk /dev/sdb
The number of cylinders for this disk is set to 8942.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sdb: 73.5 GB, 73557090304 bytes
255 heads, 63 sectors/track, 8942 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 130 1044193+ 83 Linux
/dev/sdb2 131 391 2096482+ 82 Linux swap
/dev/sdb3 392 521 1044225 83 Linux
/dev/sdb4 522 8942 67641682+ 5 Extended
/dev/sdb5 522 586 522081 83 Linux
/dev/sdb6 587 651 522081 83 Linux
/dev/sdb7 652 1173 4192933+ 83 Linux
可以看出sdb1,2,3为主分区,sdb4为扩展分区。后面的sdb5,6,7则为逻辑分区。柱面编号(Start,End)是连续的,sdb7只用道了1173,而从扩展分区看最大到8942,也就是说,还有7769个柱面是空闲的,一个柱面大小为8225280,约为8M大小。还剩7769*8225280bytes,约62G未使用。
新增加一个逻辑分区(注:若涉及到主分区和扩展分区,实际情况可能比这个复杂,这里4个主分区(包括扩展分区)都分过了,所以只能分逻辑分区)
Command (m for help): n
First cylinder (1174-8942, default 1174):
Using default value 1174
增加大小为10G
Last cylinder or +size or +sizeM or +sizeK (1174-8942, default 8942): +10240M
增加后看一下,多了一个逻辑分区/dev/sdb8
Command (m for help): p
Disk /dev/sdb: 73.5 GB, 73557090304 bytes
255 heads, 63 sectors/track, 8942 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 130 1044193+ 83 Linux
/dev/sdb2 131 391 2096482+ 82 Linux swap
/dev/sdb3 392 521 1044225 83 Linux
/dev/sdb4 522 8942 67641682+ 5 Extended
/dev/sdb5 522 586 522081 83 Linux
/dev/sdb6 587 651 522081 83 Linux
/dev/sdb7 652 1173 4192933+ 83 Linux
/dev/sdb8 1174 2419 10008463+ 83 Linux
可以看到,增加了一个sdb8的分区,柱面号从1174到2419.
写入分区表,执行分区操作
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: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
分区完后,是看不到文件系统的
[root@hdp0 hadoop]# df -m
Filesystem 1M-块 已用 可用 已用% 挂载点
/dev/sdb1 1004 582 372 62% /
none 1014 0 1014 0% /dev/shm
/dev/sdb3 1004 807 147 85% /home
/dev/sdb5 494 11 458 3% /opt
/dev/sdb7 4031 3272 554 86% /usr
/dev/sdb6 494 87 382 19% /var
重启机器
reboot
格式化文件系统
[root@hdp0 hadoop]#/sbin/mkfs.ext3 /dev/sdb8
mount文件系统,/home/develop 为/home下一目录
[root@hdp0 hadoop]#mount /dev/sdb8 /home/develop
查看文件系统,可以看到新建立的分区/文件系统已经挂载上,能够使用了。
[root@hdp0 hadoop]# df -m
Filesystem 1M-块 已用 可用 已用% 挂载点
/dev/sdb1 1004 582 372 62% /
none 1014 0 1014 0% /dev/shm
/dev/sdb3 1004 807 147 85% /home
/dev/sdb5 494 11 458 3% /opt
/dev/sdb7 4031 3272 554 86% /usr
/dev/sdb6 494 87 382 19% /var
/dev/sdb8 9621 54 9079 1% /home/develop
3、怎么给linux分区扩大容量'
这里以Red hat AS4 为例。当磁盘分区发现不够用时,能想道的第一个做法就是增加分区大小。但是一般Linux如果没有采用逻辑卷管理,则动态增加分区大小很困难,一个能想道的办法就是,备份分区文件系统数据,删除分区,然后再重新创建分区,恢复备份的文件系统,这个做法比较玄,可能删除分区后导致系统无法启动。
第二个做法就是,创建一个新的逻辑分区(当然必须有未使用的磁盘空间能分配),将文件系统从老分区拷贝到新分区,然后修改fstab,使用新分区/文件系统替换老的分区/文件系统
第三种做法是,创建一个新的逻辑分区,将新的逻辑分区格式化ext3(或其他类型)的文件系统,mount到磁盘空间不够的文件系统,就跟原来的分区/文件系统一样的使用。
这里采用的是第三种方式:
sdb为第二个SCSI硬盘。
[root@hdp0 hadoop]# /sbin/fdisk /dev/sdb
The number of cylinders for this disk is set to 8942.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sdb: 73.5 GB, 73557090304 bytes
255 heads, 63 sectors/track, 8942 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 130 1044193+ 83 Linux
/dev/sdb2 131 391 2096482+ 82 Linux swap
/dev/sdb3 392 521 1044225 83 Linux
/dev/sdb4 522 8942 67641682+ 5 Extended
/dev/sdb5 522 586 522081 83 Linux
/dev/sdb6 587 651 522081 83 Linux
/dev/sdb7 652 1173 4192933+ 83 Linux
可以看出sdb1,2,3为主分区,sdb4为扩展分区。后面的sdb5,6,7则为逻辑分区。柱面编号(Start,End)是连续的,sdb7只用道了1173,而从扩展分区看最大到8942,也就是说,还有7769个柱面是空闲的,一个柱面大小为8225280,约为8M大小。还剩7769*8225280bytes,约62G未使用。
新增加一个逻辑分区(注:若涉及到主分区和扩展分区,实际情况可能比这个复杂,这里4个主分区(包括扩展分区)都分过了,所以只能分逻辑分区)
Command (m for help): n
First cylinder (1174-8942, default 1174):
Using default value 1174
增加大小为10G
Last cylinder or +size or +sizeM or +sizeK (1174-8942, default 8942): +10240M
增加后看一下,多了一个逻辑分区/dev/sdb8
Command (m for help): p
Disk /dev/sdb: 73.5 GB, 73557090304 bytes
255 heads, 63 sectors/track, 8942 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 130 1044193+ 83 Linux
/dev/sdb2 131 391 2096482+ 82 Linux swap
/dev/sdb3 392 521 1044225 83 Linux
/dev/sdb4 522 8942 67641682+ 5 Extended
/dev/sdb5 522 586 522081 83 Linux
/dev/sdb6 587 651 522081 83 Linux
/dev/sdb7 652 1173 4192933+ 83 Linux
/dev/sdb8 1174 2419 10008463+ 83 Linux
可以看到,增加了一个sdb8的分区,柱面号从1174到2419.
写入分区表,执行分区操作
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: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
分区完后,是看不到文件系统的
[root@hdp0 hadoop]# df -m
Filesystem 1M-块 已用 可用 已用% 挂载点
/dev/sdb1 1004 582 372 62% /
none 1014 0 1014 0% /dev/shm
/dev/sdb3 1004 807 147 85% /home
/dev/sdb5 494 11 458 3% /opt
/dev/sdb7 4031 3272 554 86% /usr
/dev/sdb6 494 87 382 19% /var
重启机器
reboot
格式化文件系统
[root@hdp0 hadoop]#/sbin/mkfs.ext3 /dev/sdb8
mount文件系统,/home/develop 为/home下一目录
[root@hdp0 hadoop]#mount /dev/sdb8 /home/develop
查看文件系统,可以看到新建立的分区/文件系统已经挂载上,能够使用了。
[root@hdp0 hadoop]# df -m
Filesystem 1M-块 已用 可用 已用% 挂载点
/dev/sdb1 1004 582 372 62% /
none 1014 0 1014 0% /dev/shm
/dev/sdb3 1004 807 147 85% /home
/dev/sdb5 494 11 458 3% /opt
/dev/sdb7 4031 3272 554 86% /usr
/dev/sdb6 494 87 382 19% /var
/dev/sdb8 9621 54 9079 1% /home/develop
4、linux怎么创建扩展分区
比如给sdb硬盘扩展分区:(前提硬盘小于2T)
fdisk /dev/sdb
n
p
1(如果已经有了sdb1 就可以写个2)
回车
+(你要的分区大小)比如+10G
w(保存退出)
5、Linux 已有四个主分区,怎么新增扩展分区?
linux下一块硬盘最多有四个主分区,所以需要删除一个分区,才能新增扩展分区。
fdisk
命令:
如fdisk
/dev/sda
删除分区:command(m
for
help):
d
删除一个分区,删除请备份数据
新增分区:command(m
for
help):
n
p---检查是否生效
w---保存
q---离开
关于怎么在linux扩展分区和linux如何扩展分区的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。