C. VMware下LINUX的虚拟机增加磁盘空间

先关闭虚拟机电源,做如下设置:“ 虚拟机”--“虚拟机设置”--“磁盘”--“扩展”


C. VMware下LINUX的虚拟机增加磁盘空间_第1张图片
image.png
一,显示分区:
[root@hadoop01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_hadoop01-lv_root
                      8.3G  1.7G  6.2G  22% /
tmpfs                 491M     0  491M   0% /dev/shm
/dev/sda1             477M   34M  418M   8% /boot

二,开始分区:
[root@hadoop01 ~]# 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: 0x0003f262

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM

四,分区:
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1306-1958, default 1306): 
Using default value 1306
Last cylinder, +cylinders or +size{K,M,G} (1306-1958, default 1958): 2G
Value out of range.
Last cylinder, +cylinders or +size{K,M,G} (1306-1958, default 1958): +2G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (1568-1958, default 1568): 4
Value out of range.
First cylinder (1568-1958, default 1568): 
Using default value 1568
Last cylinder, +cylinders or +size{K,M,G} (1568-1958, default 1958): 
Using default value 1958

五,保存:
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 or after you run partprobe(8) or kpartx(8)
Syncing disks.

六,重启:
[root@hadoop01 ~]# reboot

Broadcast message from root@hadoop01
    (/dev/pts/0) at 17:44 ...

The system is going down for reboot NOW!
[root@hadoop01 ~]# Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(Zhu) at 09:44:02.

Type `help' to learn how to use Xshell prompt.
[c:\~]$ 

Connecting to 192.168.190.134:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Thu Aug 30 17:41:00 2018 from 192.168.190.1

七,格式化:
[root@hadoop01 ~]# mkfs.ext3 /dev/sda3
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131376 inodes, 525291 blocks
26264 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=541065216
17 block groups
32768 blocks per group, 32768 fragments per group
7728 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912

正在写入inode表: 完成                            
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@hadoop01 ~]# mkfs.ext3 /dev/sda4
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 785176 blocks
39258 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912

正在写入inode表: 完成                            
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


[root@hadoop01 ~]# cd /
[root@hadoop01 /]# ll
总用量 90
dr-xr-xr-x.   2 root root  4096 7月  16 19:31 bin
dr-xr-xr-x.   5 root root  1024 7月  16 19:32 boot
drwxr-xr-x.  21 root root  3820 8月  30 17:44 dev
drwxr-xr-x.  76 root root  4096 8月  30 17:44 etc
drwxr-xr-x.   2 root root  4096 9月  23 2011 home
dr-xr-xr-x.   8 root root  4096 7月  16 19:31 lib
dr-xr-xr-x.   9 root root 12288 7月  16 22:10 lib64
drwx------.   2 root root 16384 7月  16 19:28 lost+found
drwxr-xr-x.   2 root root  4096 9月  23 2011 media
drwxr-xr-x.   2 root root  4096 9月  23 2011 mnt
drwxr-xr-x.   4 root root  4096 7月  16 23:32 opt
dr-xr-xr-x. 103 root root     0 8月  30 17:44 proc
dr-xr-x---.   3 root root  4096 8月  29 01:06 root
dr-xr-xr-x.   2 root root 12288 7月  16 22:10 sbin
drwxr-xr-x.   7 root root     0 8月  30 17:44 selinux
drwxr-xr-x.   2 root root  4096 9月  23 2011 srv
drwxr-xr-x   13 root root     0 8月  30 17:44 sys
drwxrwxrwt.   3 root root  4096 8月  30 17:44 tmp
drwxr-xr-x.  13 root root  4096 7月  16 19:30 usr
drwxr-xr-x.  18 root root  4096 7月  16 19:32 var
[root@hadoop01 /]# cd mnt
[root@hadoop01 mnt]# ll
总用量 0
[root@hadoop01 mnt]# mkdir music
[root@hadoop01 mnt]# mkdir movie
[root@hadoop01 mnt]# ll
总用量 8
drwxr-xr-x. 2 root root 4096 8月  30 17:48 movie
drwxr-xr-x. 2 root root 4096 8月  30 17:48 music

八,挂载:
[root@hadoop01 mnt]# mount /dev/sda3 /mnt/music/
[root@hadoop01 mnt]# mount /dev/sda4 /mnt/movie/

九,显示:
[root@hadoop01 mnt]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_hadoop01-lv_root
                      8.3G  1.7G  6.2G  22% /
tmpfs                 491M     0  491M   0% /dev/shm
/dev/sda1             477M   34M  418M   8% /boot
/dev/sda3             2.0G   68M  1.9G   4% /mnt/music
/dev/sda4             3.0G   69M  2.8G   3% /mnt/movie

设置开机自动加载:

#
# /etc/fstab
# Created by anaconda on Mon Jul 16 19:29:55 2018
#
# 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
#
/dev/mapper/vg_hadoop01-lv_root /                       ext4    defaults        1 1
UUID=25a8ff10-0622-438c-a4ed-5e84424e2a84 /boot                   ext4    defaults        1 2
/dev/mapper/vg_hadoop01-lv_swap 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/sda3       /mnt/music      ext3    defaults        0       0
/dev/sda4       /mnt/movie      ext3    defaults        0       0
~                                                                                                                 
~                                                                                                                 
~                                                                                                                 
~                                                                                                                 
~                                                                                                                 
~                                                                                                                 
~                                                                                                                 
~                                                                                                                 
~                                                                                                                 
:wq

重启reboot

扩展分区的设立:

Command (m for help): p

Disk /dev/sda: 14.0 GB, 13958643712 bytes
255 heads, 63 sectors/track, 1697 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: 0x00079ba6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1306-1697, default 1306): +1G
Value out of range.
First cylinder (1306-1697, default 1306): 
Using default value 1306
Last cylinder, +cylinders or +size{K,M,G} (1306-1697, default 1697): +1G

Command (m for help): p

Disk /dev/sda: 14.0 GB, 13958643712 bytes
255 heads, 63 sectors/track, 1697 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: 0x00079ba6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
/dev/sda3            1306        1437     1056942+  83  Linux

Command (m for help): p

Disk /dev/sda: 14.0 GB, 13958643712 bytes
255 heads, 63 sectors/track, 1697 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: 0x00079ba6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
/dev/sda3            1306        1437     1056942+  83  Linux

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
4
Invalid partition number for type `4'
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First cylinder (1438-1697, default 1438): 
Using default value 1438
Last cylinder, +cylinders or +size{K,M,G} (1438-1697, default 1697): 
Using default value 1697

Command (m for help): p

Disk /dev/sda: 14.0 GB, 13958643712 bytes
255 heads, 63 sectors/track, 1697 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: 0x00079ba6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
/dev/sda3            1306        1437     1056942+  83  Linux
/dev/sda4            1438        1697     2088450    5  Extended

Command (m for help): n
First cylinder (1438-1697, default 1438): 
Using default value 1438
Last cylinder, +cylinders or +size{K,M,G} (1438-1697, default 1697): +1G

Command (m for help): p

Disk /dev/sda: 14.0 GB, 13958643712 bytes
255 heads, 63 sectors/track, 1697 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: 0x00079ba6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
/dev/sda3            1306        1437     1056942+  83  Linux
/dev/sda4            1438        1697     2088450    5  Extended
/dev/sda5            1438        1569     1060258+  83  Linux

Command (m for help): p

Disk /dev/sda: 14.0 GB, 13958643712 bytes
255 heads, 63 sectors/track, 1697 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: 0x00079ba6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
/dev/sda3            1306        1437     1056942+  83  Linux
/dev/sda4            1438        1697     2088450    5  Extended
/dev/sda5            1438        1569     1060258+  83  Linux

Command (m for help): n
First cylinder (1570-1697, default 1570): 
Using default value 1570
Last cylinder, +cylinders or +size{K,M,G} (1570-1697, default 1697): 
Using default value 1697

Command (m for help): p

Disk /dev/sda: 14.0 GB, 13958643712 bytes
255 heads, 63 sectors/track, 1697 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: 0x00079ba6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
/dev/sda3            1306        1437     1056942+  83  Linux
/dev/sda4            1438        1697     2088450    5  Extended
/dev/sda5            1438        1569     1060258+  83  Linux
/dev/sda6            1570        1697     1028128+  83  Linux

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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@hadoop01 ~]# reboot

U盘挂载:

[root@hadoop01 /]# mount /dev/sdb1 /mnt/udisk/ -o iocharset=utf8
[root@hadoop01 /]# cd /mnt/udisk/
[root@hadoop01 udisk]# ll
总用量 47392
drwxr-xr-x.  2 root root    32768 8月  30 17:10 20100830
drwxr-xr-x.  7 root root    32768 8月   8 11:17 20160807
drwxr-xr-x.  2 root root    32768 8月   8 08:55 20160808
drwxr-xr-x.  4 root root    32768 8月   9 17:30 20160809
drwxr-xr-x.  4 root root    32768 8月   6 16:07 20180806
drwxr-xr-x.  5 root root    32768 8月  10 17:09 20180810
drwxr-xr-x.  4 root root    32768 8月  16 17:22 20180816
drwxr-xr-x.  8 root root    32768 8月  21 17:03 20180820
drwxr-xr-x.  4 root root    32768 8月  22 11:53 20180822
drwxr-xr-x.  6 root root    32768 8月  23 17:05 20180823
drwxr-xr-x.  7 root root    32768 8月  24 16:47 20180824
drwxr-xr-x.  3 root root    32768 8月  27 17:07 20180827
drwxr-xr-x.  2 root root    32768 8月  29 11:53 20180829
drwxr-xr-x.  2 root root    32768 8月  28 17:05 21080828
drwxr-xr-x.  3 root root    32768 3月  12 2016 before
drwxr-xr-x.  5 root root    32768 5月  26 15:06 com
drwxr-xr-x.  2 root root    32768 6月  17 10:46 company
drwxr-xr-x.  2 root root    32768 5月  18 00:34 guessword
-rwxr-xr-x.  1 root root    26411 6月   5 19:38 java基础复习题含解答.docx
drwxr-xr-x. 14 root root    32768 7月  13 07:56 my project
drwxr-xr-x.  2 root root    32768 4月  28 10:15 phpStudy
-rwxr-xr-x.  1 root root 34631350 6月  30 2017 phpStudy.zip
drwxr-xr-x.  2 root root    32768 5月  10 00:40 scott20180510
-rwxr-xr-x.  1 root root   534566 8月  15 11:32 ssm复习题2.docx
-rwxr-xr-x.  1 root root   533829 8月  14 15:04 ssm复习题.docx
drwxr-xr-x.  2 root root    32768 3月  16 2016 System Volume Information
-rwxr-xr-x.  1 root root  4851261 6月  30 2017 vc9_x64(1).zip
-rwxr-xr-x.  1 root root   763043 7月   4 00:25 web前台复习题含解答.docx
drwxr-xr-x.  5 root root    32768 8月  27 00:36 wukongmaven
drwxr-xr-x.  5 root root    32768 6月  20 20:04 youluwangproject
drwxr-xr-x.  5 root root    32768 4月  27 17:08 大数据
-rwxr-xr-x.  1 root root    82432 4月  26 21:49 大数据课程体系(终).doc
-rwxr-xr-x.  1 root root    69777 4月  26 21:49 人工智能课程方案.xlsx
-rwxr-xr-x.  1 root root  5971952 5月   3 2016 深入浅出MySQL全文.pdf
drwxr-xr-x. 28 root root    32768 4月  27 17:08 文件
-rwxr-xr-x.  1 root root     7932 8月  15 13:26 新建文本文档.txt
[root@hadoop01 udisk]# cat java基础复习题含解答.docx 

(二) 解决mount: unknown filesystem type ‘ntfs’ 问题
问题:

  # mount –t ntfs /dev/sdb1 /mnt/
  mount: unknown filesystem type ‘ntfs’ 
  这是由于CentOS release 5.5(Final)上无法识别NTFS格式的分区。 

解决办法:
通过使用 ntfs-3g 来解决。
打开ntfs-3g的下载点http://www.tuxera.com/community/ntfs-3g-download/ ,将最新稳定(当前最新版本为ntfs-3g-2011.1.15)下载到CentOS,执行以下命令安装:

  1. 编译安装 ntfs-3g:

tar zxvf ntfs-3g-2011.1.15.tgz

cd ntfs-3g-2011.1.15

./configure

make

make install

在网上找了,方法一样安上 还是不能挂载,最后在官方站 找到方法了,如下:

mount -t ntfs-3g /dev/sda5 /mnt/windows

磁盘分区

给虚拟机加1块10G大小的虚拟磁盘(中间无截图,选择默认选项即可)


C. VMware下LINUX的虚拟机增加磁盘空间_第2张图片
image.png

C. VMware下LINUX的虚拟机增加磁盘空间_第3张图片
image.png

C. VMware下LINUX的虚拟机增加磁盘空间_第4张图片
image.png

你可能感兴趣的:(C. VMware下LINUX的虚拟机增加磁盘空间)