在Linux中扩展磁盘容量(1)
2010-11-11 10:18
489 查看
对于linux系统管理员来说,随着业务的发展,磁盘容量不足是需要面对的一个难题。这里通过两种方式来说明如果添加新的磁盘到linux系统当中去。一是连接新的disk,对disk分区和格式化,然后合并以存在的filesystem和新增加的disk的filesystem。二是通过linux logical volumn manager 来管理磁盘。
假设现在linux system中的filesystem的使用情况大致是:
可以看到/var挂载点挂载的/dev/hda2 partition已经使用了99%。需要增加新的磁盘容量。
通过查看/proc/partitions proc 文件,可以查看当前linux系统中所有已知的partitions
可以看到minor 值为0表示是整块磁盘, 磁盘上的分区的major同一样,minor是根据parition的增加而增加,这里hda1 hda2 … hda6的minor分别为1,2,…,6
Linux系统中hard disk命名规则, scsi磁盘以sd开头,ide磁盘以hd开头,scsi的第一个磁盘为sda, 依次其它的为sdb,sdc,sdd, IDE同样如此,hda, hdb.
sda上第一个parition为sda1,剩余的以此类推。
接下来,为新增加的disk hdb建立分区。
如果你在新建partition的时候出错,则你可以使用d命令来删除该parition,然后重新来过。 另外,linux最多允许四个primary partition, 如果你需要建立更多的分区,使用建立extended partition. 建立完extended partition之后,可以在extended partition上建立新的logical partition。
如
当你完成对hdb分区后, 查看下分区表分区是否正确 : 通过cat /proc/partitions 或 fdisk -l
接下来就需要对新增的disk hdb进行格式化,为其建立新的目录结构。
mkfs –t ext3 /dev/hdb1
然后为/dev/hdb1 建立挂载点,这里是/mnt/hdb1
修改/etc/fstab 将/dev/hdb1 挂载到/mnt/hdb1
最后别忘记挂载,挂载完成后就可以使用新增的disk了。
小结:新增disk基本需要:连接好disk,对disk分区, 格式化,最后建立挂载点,挂载
关于LVM,在Linux中扩展磁盘容量(2)—LVM 中总结。
添加新的disk到linux当中来
[完成的任务]将新增加的disk做出一个parition,然后将linux上已有磁盘上数据全部或部分迁移到新的磁盘上来假设现在linux system中的filesystem的使用情况大致是:
[root@bigboy tmp]# df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda3 505636 118224 361307 25% / /dev/hda1 101089 14281 81589 15% /boot none 63028 0 63028 0% /dev/shm /dev/hda5 248895 6613 229432 3% /tmp /dev/hda7 3304768 2720332 416560 87% /usr /dev/hda2 3304768 3300536 4232 99% /var
可以看到/var挂载点挂载的/dev/hda2 partition已经使用了99%。需要增加新的磁盘容量。
通过查看/proc/partitions proc 文件,可以查看当前linux系统中所有已知的partitions
[root@bigboy tmp]# cat /proc/partitions major minor #blocks name 3 0 7334145 hda 3 1 104391 hda1 3 2 1052257 hda2 3 3 2040255 hda3 3 4 1 hda4 3 5 3582463 hda5 3 6 554211 hda6 22 0 78150744 hdb [root@bigboy tmp]#
可以看到minor 值为0表示是整块磁盘, 磁盘上的分区的major同一样,minor是根据parition的增加而增加,这里hda1 hda2 … hda6的minor分别为1,2,…,6
Linux系统中hard disk命名规则, scsi磁盘以sd开头,ide磁盘以hd开头,scsi的第一个磁盘为sda, 依次其它的为sdb,sdc,sdd, IDE同样如此,hda, hdb.
sda上第一个parition为sda1,剩余的以此类推。
接下来,为新增加的disk hdb建立分区。
[root@bigboy tmp]# fdisk /dev/hdb The number of cylinders for this disk is set to 9729. 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):
============================================================
Command (m for help): p Disk /dev/hdb: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Command (m for help):
可以看到目前hdb 上没有建立parition。
Command (m for help): n Command action e extended p primary partition (1-4)
Partition number (1-4): 1 First cylinder (1-9729, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-9729, default 9729):
Command (m for help): p Disk /dev/hdb: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hdb1 1 9726 78148161 83 Linux Command (m for help):
如果你在新建partition的时候出错,则你可以使用d命令来删除该parition,然后重新来过。 另外,linux最多允许四个primary partition, 如果你需要建立更多的分区,使用建立extended partition. 建立完extended partition之后,可以在extended partition上建立新的logical partition。
如
Command (m for help): p Disk /dev/hda: 7510 MB, 7510164480 bytes 255 heads, 63 sectors/track, 913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 144 1052257+ 83 Linux /dev/hda3 145 398 2040255 82 Linux swap /dev/hda4 399 913 4136737+ 5 Extended /dev/hda5 399 844 3582463+ 83 Linux #logical parition on extended parition /dev/hda6 845 913 554211 83 Linux # ditto
当你完成对hdb分区后, 查看下分区表分区是否正确 : 通过cat /proc/partitions 或 fdisk -l
接下来就需要对新增的disk hdb进行格式化,为其建立新的目录结构。
mkfs –t ext3 /dev/hdb1
然后为/dev/hdb1 建立挂载点,这里是/mnt/hdb1
修改/etc/fstab 将/dev/hdb1 挂载到/mnt/hdb1
# # File: /etc/fstab # /dev/hdb1 /mnt/hdb1 ext3 defaults 1 2
最后别忘记挂载,挂载完成后就可以使用新增的disk了。
小结:新增disk基本需要:连接好disk,对disk分区, 格式化,最后建立挂载点,挂载
关于LVM,在Linux中扩展磁盘容量(2)—LVM 中总结。
相关文章推荐
- VMware下linux扩展磁盘容量
- Linux如何更改VirtualBox虚拟机的磁盘容量--gparted合并分区(不能扩展主分区不足点,需要配置LiveCD使用)
- 在linux中扩展磁盘容量(2)--LVM
- 在Linux中扩展磁盘容量(1)
- 在linux中扩展磁盘容量(2)--LVM
- Linux下使用fdisk扩展分区容量
- 扩展linux虚拟机磁盘
- LINUX扩展根目录磁盘空间(LINUX LVM )
- Linux上把新磁盘扩展到已有分区中(基于LVM)
- linux基础命令之磁盘与目录的容量查询
- 不损坏数据的情况下 linux磁盘如何扩展 LVM格式
- 扩展VirtualBox虚拟机磁盘容量
- 服务器磁盘扩展容量操作流程
- 如何扩展ESXi虚拟机磁盘容量
- VM虚拟机中Linux扩展磁盘空间的方法
- 扩展VirtualBox虚拟机磁盘容量
- linux 下分区xvdb有200G,只使用了20G,如何扩展容量?
- Linux中不关机扩展磁盘的命令汇总
- fedora 20(64位)虚拟机磁盘容量扩展
- Linux 磁盘扩展添加新分区+常用du