07.06.2014 Views

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Allocation<br />

inherit<br />

Read ahead sectors auto<br />

- currently set to 256<br />

Block device 253:0<br />

# lvcreate -n lv_base -L 1G vg_critical<br />

Logical volume "lv_base" created<br />

# lvcreate -n lv_backups -L 12G vg_normal<br />

Logical volume "lv_backups" created<br />

# lvdisplay -C<br />

LV VG Attr LSize Origin Snap% Move Log Copy% Convert<br />

lv_base vg_critical -wi-a- 1.00G<br />

lv_files vg_critical -wi-a- 5.00G<br />

lv_backups vg_normal -wi-a- 12.00G<br />

Two parameters are required when creating logical volumes; they must be passed to the lvcre<br />

ate as options. The name of the LV to be created is specified with the -n option, and its size is<br />

generally given using the -L option. We also need to tell the command what VG to operate on,<br />

of course, hence the last parameter on the command line.<br />

GOING FURTHER<br />

lvcreate options<br />

The lvcreate command has several options to allow tweaking how the LV is<br />

created.<br />

Let's first describe the -l option, with which the LV's size can be given as a<br />

number of blocks (as opposed to the “human” units we used above). These<br />

blocks (called PEs, physical extents, in LVM terms) are contiguous units of<br />

storage space in PVs, and they can't be split across LVs. When one wants to<br />

define storage space for an LV with some precision, for instance to use the full<br />

available space, the -l option will probably be preferred over -L.<br />

It's also possible to hint at the physical location of an LV, so that its extents<br />

are stored on a particular PV (while staying within the ones assigned to the<br />

VG, of course). Since we know that sdb is faster than sdf, we may want to<br />

store the lv_base there if we want to give an advantage to the database server<br />

compared to the file server. The command line becomes: lvcreate -n lv_-<br />

base -L 1G vg_critical /dev/sdb2. Note that this command can fail if<br />

the PV doesn't have enough free extents. In our example, we would probably<br />

have to create lv_base before lv_files to avoid this situation – or free up<br />

some space on sdb2 with the pvmove command.<br />

Logical volumes, once created, end up as block device files in /dev/mapper/:<br />

# ls -l /dev/mapper<br />

total 0<br />

crw-rw---- 1 root root 10, 59 5 oct. 17:40 control<br />

lrwxrwxrwx 1 root root 7 5 oct. 18:14 vg_critical-lv_base -> ../dm-1<br />

lrwxrwxrwx 1 root root 7 5 oct. 18:14 vg_critical-lv_files -> ../dm-0<br />

lrwxrwxrwx 1 root root 7 5 oct. 18:14 vg_normal-lv_backups -> ../dm-2<br />

Chapter 12 — Advanced Administration<br />

313

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!