您的位置:首页 > 大数据

大数据实验增加,导致虚拟机的根目录/ 磁盘空间不够,会带来各种问题, 使用gpated工具解决!!

2016-03-04 20:13 771 查看
使用gpated给linux根目录增加空间

原来的空间:

[root@master ~]# df -k

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda2 5921544 4343912 1276832 78% /

tmpfs 515340 72 515268 1% /dev/shm

/dev/sda1 297485 31772 250353 12% /boot

[root@master ~]#

根目录扩容以后的空间

[root@master hadoop]#df -k

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda2 13102616 4347112 8089904 35% /

tmpfs 515340 72 515268 1% /dev/shm

/dev/sda1 297485 31772 250353 12% /boot

[root@master hadoop]#

[root@master ~]# fdisk -l

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 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: 0x000b2584

Device Boot Start End Blocks Id System

/dev/sda1 * 1 39 307200 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 39 1696 13312000 83 Linux

/dev/sda3 1696 1959 2108416 82 Linux swap / Solaris

[root@master ~]#

步骤:

1、下载

http://gparted.sourceforge.net/download.php

2、光驱加载到虚拟机 虚拟机设置-CD/DVD-使用ISO镜像文件

3、从bios启动虚拟机:虚拟机-电源-打开电源bios

4、boot 按+号将cd-rom drive放到最上面。F10重启

5、进入gpated 划分分区 增加空间完成





6、从bios启动虚拟机:虚拟机-电源-打开电源bios

4、boot 按+号将Hard drive放到最上面。F10重启

=================

下面手工来增加根目录的磁盘,折腾半天还有问题,使用工具gparted简单解决了问题。

1、 打开VMware,选择Edit Virtual mache settings,Utilities下拉框中找到Expand

2、虚拟机 删除快照

3、将磁盘空间扩大到15G,点击Expand即可,完成后这是新的空间已经增加,但linux环境下还不可见

4、启动VMware环境下的Linux操作系统,添加新分区,需要root账号身份。

[root@master ~]# id

uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

[root@master ~]# df -k

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda2 5921544 4343912 1276832 78% /

tmpfs 515340 72 515268 1% /dev/shm

/dev/sda1 297485 31772 250353 12% /boot

[root@master ~]#

5、

[root@master hadoop]#fdisk -l

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 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: 0x000b2584

Device Boot Start End Blocks Id System

/dev/sda1 * 1 39 307200 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 39 788 6016000 83 Linux

Partition 2 does not end on cylinder boundary.

/dev/sda3 788 1045 2064384 82 Linux swap / Solaris

[root@master hadoop]#

3.1 【fdisk -l】 最大分区为/dev/sda3,说明新创建的分区将会是sda4

3.2 输入【fdisk /dev/sda】

3.2.1命令行提示下输入【m】

3.2.2输入命令【n】添加新分区。

3.2.3输入命令【p】创建主分区。

3.2.4输入【回车】,选择默认大小,这样不浪费空间

3.2.5输入【回车】,选择默认的start cylinder。

3.2.6输入【w】,保持修改

3.3 输入【reboot】 重启linux,必须reboot,否则/dev/sda4无法格式化。

3.4 这时在/dev/目录下,才能看到了新的分区比如/dev/sda4

[root@master hadoop]#fdisk -l

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 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: 0x000b2584

Device Boot Start End Blocks Id System

/dev/sda1 * 1 39 307200 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 39 788 6016000 83 Linux

Partition 2 does not end on cylinder boundary.

/dev/sda3 788 1045 2064384 82 Linux swap / Solaris

/dev/sda4 1045 1958 7339027 83 Linux

[root@master hadoop]#

[root@master dev]#ls | grep sda

sda

sda1

sda2

sda3

sda4

[root@master dev]#pwd

/dev

[root@master dev]#ls | grep sda

sda

sda1

sda2

sda3

sda4

格式化

[root@master dev]#mkfs.ext2 /dev/sda4

mke2fs 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

458752 inodes, 1834756 blocks

91737 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1879048192

56 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

Writing inode tables: done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@master dev]#

[root@master dev]#mkdir /disk4

[root@master dev]#cd /

[root@master /]#ls

bin dev etc lib media opt root selinux sys usr

boot disk4 home lost+found mnt proc sbin srv tmp var

[root@master /]#chmod 777 disk4

[root@master /]#

【mount /dev/sda4 /disk4/】将分区mount到/disk4/上

[root@master /]#chmod 777 disk4

[root@master /]#mount /dev/sda4 /disk4/

[root@master /]#

[root@master hadoop]#umount /dev/sda4

[root@master hadoop]#df -k

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda2 5921544 4343924 1276820 78% /

tmpfs 515340 72 515268 1% /dev/shm

/dev/sda1 297485 31772 250353 12% /boot

[root@master hadoop]#fdisk -l

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 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: 0x000b2584

Device Boot Start End Blocks Id System

/dev/sda1 * 1 39 307200 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 39 788 6016000 83 Linux

Partition 2 does not end on cylinder boundary.

/dev/sda3 788 1045 2064384 82 Linux swap / Solaris

/dev/sda4 1045 1958 7339027 83 Linux

[root@master hadoop]#

/dev/sda4 /disk4 ext2 defaults 0 0

[root@master /]#vi /etc/fstab

#

# /etc/fstab

# Created by anaconda on Mon Sep 9 04:49:54 2013

#

# 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=6e428aef-f3cc-424a-bf48-e66a1a3e15fe / ext4 defaults 1 1

UUID=6379983d-c153-49a1-b689-e6184afa679d /boot ext4 defaults 1 2

UUID=2ebaf8ae-1ece-46a4-a73f-a06260c5f1dc swap swap defaults 0 0

tmpfs /dev/shm tmpfs defaults 0 0

devpts /dev/pts devpts gid=5,mode=620 0 0

sysfs /sys sysfs defaults 0 0

proc /proc proc defaults 0 0

/dev/sda4 /disk4 ext2 defaults 0 0

============================

回退

1、[root@master hadoop]#vi /etc/fstab 注释

#/dev/sda4 /disk4 ext2 defaults 0 0

2、卸载

3、删除分区dea4

[root@master hadoop]#fdisk /dev/sda

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): p

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 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: 0x000b2584

Device Boot Start End Blocks Id System

/dev/sda1 * 1 39 307200 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 39 788 6016000 83 Linux

Partition 2 does not end on cylinder boundary.

/dev/sda3 788 1045 2064384 82 Linux swap / Solaris

/dev/sda4 1045 1958 7339027 83 Linux

Command (m for help): d

Partition number (1-4): 4

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)

Syncing disks.

[root@master hadoop]#fidsk -l

bash: fidsk: command not found

[root@master hadoop]#dfisk -l

bash: dfisk: command not found

[root@master hadoop]#fdisk -l

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 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: 0x000b2584

Device Boot Start End Blocks Id System

/dev/sda1 * 1 39 307200 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 39 788 6016000 83 Linux

Partition 2 does not end on cylinder boundary.

/dev/sda3 788 1045 2064384 82 Linux swap / Solaris

[root@master hadoop]#

5、改成lvm

Command (m for help): ^H

Command (m for help): t

Partition number (1-4): 4

Hex code (type L to list codes): 8e

Changed system type of partition 4 to 8e (Linux LVM)

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)

Syncing disks.

[root@master hadoop]#

[root@master hadoop]#fdisk -l

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 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: 0x000b2584

Device Boot Start End Blocks Id System

/dev/sda1 * 1 39 307200 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 39 788 6016000 83 Linux

Partition 2 does not end on cylinder boundary.

/dev/sda3 788 1045 2064384 82 Linux swap / Solaris

/dev/sda4 1045 1958 7339027 8e Linux LVM

[root@master hadoop]#

格式化

[root@master hadoop]#mkfs.ext3 /dev/sda4

mke2fs 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

458752 inodes, 1834756 blocks

91737 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1879048192

56 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

Writing inode tables: done

Creating journal (32768 blocks):

done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 27 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@master hadoop]#

[root@master hadoop]#

http://www.linuxidc.com/Linux/2011-02/32083.htm

http://blog.sina.com.cn/s/blog_709919050100wap1.html

使用工具

http://www.linuxidc.com/Linux/2015-03/115027.htm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: