0
|
1 |
-*- outline -*-
|
|
2 |
|
|
3 |
* Debian package.
|
|
4 |
|
|
5 |
$ sudo apt-get --install lvm
|
|
6 |
|
|
7 |
* See partitions.
|
|
8 |
|
|
9 |
$ sudo sfdisk -l
|
|
10 |
|
|
11 |
or use gparted(1).
|
|
12 |
|
|
13 |
* Setup physical volume.
|
|
14 |
|
|
15 |
$ sudo pvcreate /dev/sdc3
|
|
16 |
Physical volume "/dev/sdc3" successfully created
|
|
17 |
|
|
18 |
* Setup volume group.
|
|
19 |
|
|
20 |
$ sudo vgcreate vg0 /dev/sdc3
|
|
21 |
Volume group "vg0" successfully created
|
|
22 |
|
|
23 |
$ sudo vgdisplay
|
|
24 |
--- Volume group ---
|
|
25 |
VG Name vg0
|
|
26 |
System ID
|
|
27 |
Format lvm2
|
|
28 |
Metadata Areas 1
|
|
29 |
Metadata Sequence No 1
|
|
30 |
VG Access read/write
|
|
31 |
VG Status resizable
|
|
32 |
MAX LV 0
|
|
33 |
Cur LV 0
|
|
34 |
Open LV 0
|
|
35 |
Max PV 0
|
|
36 |
Cur PV 1
|
|
37 |
Act PV 1
|
|
38 |
VG Size 77.22 GB
|
|
39 |
PE Size 4.00 MB
|
|
40 |
Total PE 19769
|
|
41 |
Alloc PE / Size 0 / 0
|
|
42 |
Free PE / Size 19769 / 77.22 GB
|
|
43 |
VG UUID ZOQvrP-PnJ2-kKsH-7aLU-eOa3-K5M2-sRstJH
|
|
44 |
|
|
45 |
|
|
46 |
* Create logical volume.
|
|
47 |
|
|
48 |
$ sudo lvcreate -L 10G -n home vg0
|
|
49 |
Logical volume "home" created
|
|
50 |
|
|
51 |
* Create fs on logical volume.
|
|
52 |
|
|
53 |
$ sudo mke2fs -j /dev/vg0/home
|
|
54 |
mke2fs 1.40-WIP (14-Nov-2006)
|
|
55 |
Filesystem label=
|
|
56 |
OS type: Linux
|
|
57 |
Block size=4096 (log=2)
|
|
58 |
Fragment size=4096 (log=2)
|
|
59 |
1310720 inodes, 2621440 blocks
|
|
60 |
131072 blocks (5.00%) reserved for the super user
|
|
61 |
First data block=0
|
|
62 |
Maximum filesystem blocks=2684354560
|
|
63 |
80 block groups
|
|
64 |
32768 blocks per group, 32768 fragments per group
|
|
65 |
16384 inodes per group
|
|
66 |
Superblock backups stored on blocks:
|
|
67 |
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
|
|
68 |
|
|
69 |
Writing inode tables: done
|
|
70 |
Creating journal (32768 blocks): done
|
|
71 |
Writing superblocks and filesystem accounting information: done
|
|
72 |
|
|
73 |
* Remove logical volume.
|
|
74 |
|
|
75 |
$ lvremove /dev/vg0/home
|
|
76 |
|
|
77 |
* Move home dir to lvm.
|
|
78 |
|
|
79 |
$ su
|
|
80 |
...
|
|
81 |
$ mv /home /home2
|
|
82 |
$ lvcreate -L 10G -n home vg0
|
|
83 |
$ mke2fs -j /dev/vg0/home
|
|
84 |
$ emacs /etc/fstab
|
|
85 |
...
|
|
86 |
$ cat /etc/fstab
|
|
87 |
...
|
|
88 |
/dev/vg0/home /home ext3 defaults 0 2
|
|
89 |
...
|
|
90 |
$ mount -a
|
|
91 |
$ (cd /home2; tar -cf - .) | (cd /home; tar -xpf -)
|
|
92 |
$ rm -r /home2
|
|
93 |
|
|
94 |
* Creating swap on lvm.
|
|
95 |
|
|
96 |
$ su
|
|
97 |
...
|
|
98 |
$ lvcreate -L 1G -n swap vg0
|
|
99 |
$ mkswap -v1 /dev/vg0/swap
|
|
100 |
$ emacs /etc/fstab
|
|
101 |
...
|
|
102 |
$ cat /etc/fstab
|
|
103 |
...
|
|
104 |
/dev/vg0/swap swap swap defaults 0 0
|
|
105 |
...
|
|
106 |
$ swapon -a
|
|
107 |
|