Trying out LVM2 on Ubuntu
来源:互联网 发布:加入淘宝客要多少钱 编辑:程序博客网 时间:2024/05/21 17:44
Environment:
Ubuntu 8.04 server LTS in VMware
Partitioned with installation guide, whole with LVM
Extra empty virtual disk 8GB added as second SCSI device
Steps:
1. Partition the new disk:
fdisk /dev/sdb
create 4 partitions. don't format.
2. create Physical Volumns for new partitions
pvcreate /dev/sdb1
pvcreate /dev/sdb2
...
Find out sizes for each PVs, in the unit "Physical Extends" (PEs)
$ pvdisplay /dev/sdb1 | grep 'Total PE'
Total PE: 490
Remember the value, say $TPE .
3. Find out Volumn group new PVs to be added in
vgdisplay
say we are adding to VG "ubuntu".
If there is NO VG AVAILABLE IN SYSTEM, create one:
vgcreate ubuntu /dev/sdb1
The second arg is a pvcreate-ed physical volumn.
4. Add new PV to VG
vgextend /dev/sdb1 ubuntu
to remove, use vgreduce
vgreduce ubuntu /dev/sdb4
5. Find Logic Volumn new space to be added into. LVs are the "actual partitions" to be mounted in the system.
lvdisplay
To create one,
lvcreate $VGNAME -l$TPE -n new_lv_name
Say the Volume Group name is /dev/ubuntu/, as $VGNAME
new_lv_name will be the name of new volume, e.g. /dev/ubuntu/new_lv_name
-l$TPE could be specified instead as -L size, e.g. -L 40G
6. Extend the target LV
lvextend -l+$TPE $LVNAME
where $TPE is found in step 2 and $LVNAME is found in step 5.
7. Resize filesystem accordingly.
resize2fs /dev/ubuntu/root
resize2fs will automatically resize the filesystem to fit the total size of underlying device (here the LV /dev/ubuntu/root). For ext3 / reiserfs, online resize can be performed where ext2 requires offline (umount first) resize.
Now you can df to see the new size.
Enjoy :)
Reference:
http://tldp.org/HOWTO/LVM-HOWTO/commontask.html
Extras:
1. Use large regular file as part of LVM PVs
Via loopback device / losetup
losetup /dev/loop0 $LARGEFILE ; associate $LARGEFILE with /dev/loop0
pvcreate /dev/loop0 ; use /dev/loop0 a.k.a. $LARGEFILE as a PV
; other normal PV / VG / LV operations
2. Remove an PV from VG
pvmove $PV
Move all PE (data blocks) on $PV to other free PEs in the $VG. See vgdisplay for "Free PE" and pvdisplay for "Total PE" - there must be more "Free PE" in vg than "Total PE" in target PV. If not, add a new PV to VG (don't assign to LVs). pvmove is supposed to move all data blocks around is supposed to be slow.
vgreduce $VG $PV
removes target $PV from $VG.
pvremove $PV
optionally removes the PV.
3. Running system deployment tests with fresh Ubuntu on LVM2
Sample setup: Ubuntu 10.10 fresh on VG srv20, root fs /dev/srv20/root
Mount script:
#!/bin/bash[ -z "$LV" ] && LV=mspmasterexport LV./umount.shlvremove /dev/srv20/$LVlvcreate -s -L 40G -n $LV /dev/srv20/root || exit 1[ -d /mnt/$LV ] || mkdir /mnt/$LVmount /dev/srv20/$LV /mnt/$LVpushd /mnt/$LVecho "srv20-$LV" > ./etc/hostnamesed -i "s/srv20/srv20-$LV/g" ./etc/hostsrm ./base-systemtouch ./$LVmount --bind /dev/pts /mnt/$LV/dev/ptsmount --bind /proc /mnt/$LV/procmount --bind /sys /mnt/$LV/sys
Then one may chroot into /mnt/$LV and use the system. By modifying ~/.bashrc, change "\h" in $PS1 to `cat /etc/hostname` and one can identify which level of dream he is in.
Umount script:
#!/bin/bash[ -z "$LV" ] && LV=mspmasterumount /mnt/$LV/dev/ptsumount /mnt/$LV/procumount /mnt/$LV/sysumount /mnt/$LVrm -rf /mnt/$LV
Reference:
http://tldp.org/HOWTO/LVM-HOWTO/removeadisk.html
- Trying out LVM2 on Ubuntu
- ORA-04030: out of process memory when trying to allocate
- process launch failed: timed out trying to launch app
- Xcode process launch failed: timed out trying to launch app
- process launch failed: timed out trying to launch app
- docker问题:Network timed out while trying to connect
- process launch failed:time out trying to launch app
- docker同步镜像报错Network timed out while trying to connect
- ssh: connect to host IPADDR port 22: Connection timed out on ubuntu
- ;; connection timed out; trying next origin ;; connection timed out; no servers could be reached
- couldn't open file on client side trying server side
- deepwalk遇到RuntimeError on windows trying python multiprocessing问题解决办法
- Ubuntu Access Out Net
- ubuntu svn checck out
- Linux中LVM2原理及制作LVM2
- PATH is different if login with same account but through different way on ubuntu(Not figure out yet)
- ORA-04030: out of process memory when trying to allocate 64544 bytes (sort subheap,sort key)
- Rational AppScan Standard has detected it is out-of-session and is trying to re-login
- 有一种人 不值得
- 希望这是公平的审判
- Oracle扩展PL/SQL简介(一)
- 火影探讨:佐助对决雷影
- redflag5.0安装Apache+MySQL+PHP实录
- Trying out LVM2 on Ubuntu
- ubuntu9.0.4 安装virtualbox
- Linux 系统的单用户模式、修复模式、跨控制台登录在系统修复中的运用
- MySQL常用的一些有效命令罗列
- virtualbox 下通过ghost安装xp
- WUBI高级应用篇
- 有很期待的人来了
- 用PHP写的DIV+CSS日历函数
- 我的技术博客索引