VMware虚拟机下为Ubuntu添加磁盘
20G的磁盘还是不够用啊,正好复习下磁盘分区和逻辑卷。
关闭虚拟机,打开VMware,右键虚拟机点击设置,点下下方的添加,就可以添加磁盘了。
进入虚拟机,查看:
root@ubuntu:/# fdisk -l
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe0f58c4a Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 39845887 39843840 19G 83 Linux
/dev/sda2 39847934 41940991 2093058 1022M 5 Extended
/dev/sda5 39847936 41940991 2093056 1022M 82 Linux swap / Solaris Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
新的磁盘/dev/sdb已添加。
创建分区
创建一个5G分区:
root@ubuntu:/# fdisk /dev/sdb
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 3
First sector (2048-20971519, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): +5G Created a new partition 3 of type 'Linux' and of size 5 GiB.
格式修改为8e(逻辑卷必须):
Command (m for help): t Selected partition 3
Partition type (type L to list all types): 8e
Changed type of partition 'Linux' to 'Linux LVM'. Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1df1b6c7 Device Boot Start End Sectors Size Id Type
/dev/sdb3 2048 10487807 10485760 5G 8e Linux LVM
保存:
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
创建物理卷PV
root@ubuntu:/# pvcreate /dev/sdb3
Physical volume "/dev/sdb3" successfully created
root@ubuntu:/# pvdisplay
"/dev/sdb3" is a new physical volume of "5.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb3
VG Name
PV Size 5.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 2rydZg-wXnl-vBlo-EhZ7-T2YC-CRoc-Gw3NyP root@ubuntu:/# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb3 lvm2 --- 5.00g 5.00g
创建卷组VG
root@ubuntu:/# vgcreate vgvg /dev/sdb3
Volume group "vgvg" successfully created
root@ubuntu:/# vgdisplay
--- Volume group ---
VG Name vgvg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.00 GiB
PE Size 4.00 MiB
Total PE 1279
Alloc PE / Size 0 / 0
Free PE / Size 1279 / 5.00 GiB
VG UUID t9Ehku-ALdl-FCjl-sakI-sqDe-vx4H-lLqmIz root@ubuntu:/# vgs
VG #PV #LV #SN Attr VSize VFree
vgvg 1 0 0 wz--n- 5.00g 5.00g
创建逻辑卷LV
root@ubuntu:/# lvcreate -L 4G -n lvlv vgvg
Logical volume "lvlv" created.
root@ubuntu:/# lvdisplay
--- Logical volume ---
LV Path /dev/vgvg/lvlv
LV Name lvlv
VG Name vgvg
LV UUID nP2sGc-KGyU-zJZ1-IFk7-aMjC-39tm-sdgkue
LV Write Access read/write
LV Creation host, time ubuntu, 2018-01-06 10:20:19 -0800
LV Status available
# open 0
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0 root@ubuntu:/# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lvlv vgvg -wi-a----- 4.00g
格式化并且挂载
root@ubuntu:/# mkfs.ext4 /dev/vgvg/lvlv
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 1048576 4k blocks and 262144 inodes
Filesystem UUID: fcffe231-a2b5-429c-b95c-1884cef6cfeb
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done root@ubuntu:/# mkdir /lvmdata
root@ubuntu:/# mount /dev/vgvg/lvlv /lvmdata
快照卷命令:
lvcreate
-s :指定快照卷;
-p r:限定快照卷为只读;
格式: lvcreate -L SIZE-s -p r -n LV_NAME /path/to/lv
创建快照卷:
lvcreate -L 100M -s -p r -n lvm-snap /dev/vgvg/lvlv
挂载:
mount -o ro /dev/vgvg/lvm-snap /media/
删除:
umount /media/
lvremove /dev/vgvg/lvm-snap
要恢复快照的话,首先卸载:
umount /lvmdata/
然后使用快照恢复:
root@ubuntu:~# lvconvert --merge /dev/vgvg/lvm-snap
Merging of volume lvm-snap started.
lvlv: Merged: 100.0%
lvlv: Merged: 100.0%
再挂载即可:
root@ubuntu:~# mount /dev/vgvg/lvlv /lvmdata/
内容已恢复快照内容。
VMware虚拟机下为Ubuntu添加磁盘的更多相关文章
- 【申嵌视频】基于VMWare虚拟机下安装ubuntu操作系统的详细步骤
[申嵌视频]基于VMWare虚拟机下安装ubuntu操作系统 适合搭建mini2440, Tiny6410, smart210,Tiny4412, NanoPC-T2, NanoPC-T3, Nano ...
- VMWare虚拟机下为Ubuntu 12.04.1配置静态IP(NAT连接方式)
背景 在虚拟机下运行操作系统,尤其是Linux系统已经是非常常见的做法.有时你想在虚拟机下搭建一个(模拟)服务器来供主机访问,比如搭建一个telnet/ssh.此时你会发现,每次启动虚拟机,VMWar ...
- VMWare虚拟机下为Ubuntu 12.04.1配置静态IP_转
转自:http://www.cnblogs.com/objectorl/archive/2012/09/27/vmware-ubuntu-nat-static-ip-settings.html 背景在 ...
- VMWare虚拟机下为Ubuntu 12.04.1配置静态IP(NAT方式)
背景 在虚拟机下运行操作系统,尤其是Linux系统已经是非常常见的做法.有时你想在虚拟机下搭建一个(模拟)服务器来供主机访问,比如搭建一个telnet/ssh.此时你会发现,每次启动虚拟机,VMWar ...
- VMWare虚拟机下为Ubuntu 12.04.1网络设置(NAT方式)
NAT方式: 虚拟机能够上外网,能够訪问宿主计算机所在网络的其它计算机(反之不行). 第一步:设置虚拟机vmware网络參数 (1)打开虚拟机,选择菜单"编辑">" ...
- VMWare虚拟机下为Ubuntu 12.04.2配置静态IP(NAT方式)
http://www.cnblogs.com/objectorl/archive/2012/09/27/vmware-ubuntu-nat-static-ip-settings.html 参考以上方式 ...
- VMware虚拟机下安装ubuntu操作系统
安装tools:
- 给虚拟机下面的ubuntu系统增加硬盘存储空间
给虚拟机下面的ubuntu系统增加硬盘存储空间 由于ubuntu系统是安装在vsphere上面的,所以可能会和vmware上面的有一点区别,打开exsi系统的配置页面,如下图所示. 选择添加存储器 ...
- 在虚拟机下安装Ubuntu
目录: 1.安装虚拟机 2.在虚拟下安装Ubuntu 本文将按照目录分两步来讲一下在虚拟机下安装Ubuntu.第一步是安装虚拟机,第二步是在虚拟机下安装Ubuntu. 安装虚拟机 下载虚拟机链接以及激 ...
随机推荐
- Azure ARM (19) 将传统的ASM VM迁移到ARM VM (2)
<Windows Azure Platform 系列文章目录> 因为我们在上一节中: Azure ARM (18) 将传统的ASM VM迁移到ARM VM (1) 已经创建了Azure V ...
- android动画介绍之 自己定义Animation动画实现qq抖一抖效果
昨天我们介绍了Animation的基本使用方法.小伙伴们了解的怎么样了?假设还没有了解过Animation的小伙伴能够看看这篇博客 android动画介绍--Animation 实现loading动画 ...
- Codeforces 149 E. Martian Strings
正反两遍扩展KMP,维护公共长度为L时.出如今最左边和最右边的位置. . .. 然后枚举推断... E. Martian Strings time limit per test 2 seconds m ...
- 我的GIS观
申明: 文章所述观点与不论什么组织或个人无关,仅代表我个人观点,如有不正确,还望批评指正. 概述: 从毕业到如今,在GIS这条路上也算是摸爬滚打4.5年了.说长也不长,说短也不短.在这4.5年的时间里 ...
- 【SqlServer】【问题收集】必须声明标量变量
1 问题概述 在DAL层,通过标量给变量赋值时,出现如下异常 我们来看看在数据访问层的SQL语句: //根据EmployeeName条件获取数据 public DataTable GetEmplo ...
- mybatis插入实体到数据库后获取自增的主键
话不多说,直接说方法. 1.在insert语句中加入如下的代码. <insert id="insertSelective" parameterType="com.q ...
- Fragment多重嵌套实现电影,影院展示页
转载请标明出处: http://www.cnblogs.com/dingxiansen/p/8135888.html 本文出自:丁先森-博客园 公司以前的app是用H5封的,由于一个模块效果用H5实现 ...
- PHP是干什么用?
掌握PHP就是使用电脑制定规则.框架tp3.2/5.2 在结构化编程中,程序围绕着要解决的任务来设计. 面向对象编程中,程序围绕着问题域中的对象来设计. 面对对象的识别事物的方式: ●类比----&g ...
- 【java设计模式】【行为模式Behavioral Pattern】模板方法模式Template Method Pattern
package com.tn.pattern; public class Client { public static void main(String[] args) { AbstractClass ...
- 【java】java.util.Arrays类常用方法
package Arrays类; import java.util.Arrays; public class TestArrays { public static void main(String[] ...