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. 安装虚拟机 下载虚拟机链接以及激 ...
随机推荐
- 使用REST风格架构您需要知道的一些事
1. REST的由来 2. REST的构成 2.1. 资源 2.2. 资源的表述 2.2.1. MIME(Multipurpose Internet Mail Extensions) 2.2.2. 缓 ...
- Tomcat 源码分析(一)——启动与生命周期组件
写在前面的话:读Tomcat源码也有段时间了,大领悟谈不上.一些小心得记录下来,供大家参考相护学习. 一.启动流程 Tomcat启动首先需要熟悉的是它的启动流程.和初学者第一天开始写Hello Wor ...
- Code Kata:螺旋矩阵 javascript实现
1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 如图所示,就是一个5*5的螺旋矩阵 我的思路如下: 第一步:拆分 ...
- 对datatable进行简单的操作
筛选出datatable中c_level=1的数据 dataRow[] rows = dt.Select("c_level=0"); 克隆表dt的结构到表dt,并将dt的数据复制到 ...
- Android系统匿名共享内存(Anonymous Shared Memory)Java调用接口分析
一.Ashmem驱动程序 ~/Android/kernel/goldfish ----include ----linux ----ashmem.h ----mm ----ashmem.c 驱动程序具体 ...
- .Net 5分钟搞定网页实时监控
一.为什么会用到网页实时监控 LZ最近在无锡买房了,虽然在上海工作,但是上海房价实在太高无法承受,所以选择还可以接受的无锡作为安身之地.买过房的小伙伴可能知道买房的流程,买房中间有一步很重要的就是需要 ...
- ASP.MVC当URL跳转时候参数的安全性
一个页面跳转到另外一个页面直接将参数写在URL上面并不安全比如 http://XXXXXXXXXXX/meeting/shakeGroup?id=5381&uid=o0En_sj1J0bFgI ...
- 传统controller与controllerAs
传统controller与controllerAs(前面为传统,后面为controllerAs,分割线分隔): 路由模块: .state('home.packing', { url: '/packin ...
- 0基础手把手教你搭建webpack运行打包项目(未完待续)
这些天在项目之余的时间学习了webpack打包项目的东西,非常荣幸的找到一些大神的文章来学习,死劲嚼了几天,终于略知一二.在以后的工作上还需继续学习,下面我将分享我这几天学到的一点东西,希望能让我一个 ...
- Redis命令与配置
命令 开启服务端 redis-server.exe redis.conf 客户端连接 redis-cli.exe -h 127.0.0.1 -p 6379 1.连接操作相关的命令 quit:关闭连接( ...