<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML ><HEAD ><TITLE >Initializing disks or disk partitions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="LVM HOWTO" HREF="index.html"><LINK REL="UP" TITLE="Common Tasks" HREF="commontask.html"><LINK REL="PREVIOUS" TITLE="Common Tasks" HREF="commontask.html"><LINK REL="NEXT" TITLE="Creating a volume group" HREF="createvgs.html"></HEAD ><BODY CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >LVM HOWTO</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="commontask.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 11. Common Tasks</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="createvgs.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="initdisks" ></A >11.1. Initializing disks or disk partitions</H1 ><P > Before you can use a disk or disk partition as a physical volume you will have to initialize it: </P ><P > For entire disks: <P ></P ><UL ><LI ><P > Run pvcreate on the disk: <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="screen" > <B CLASS="command" ># pvcreate /dev/hdb</B > </PRE ></FONT ></TD ></TR ></TABLE > This creates a volume group descriptor at the start of disk. <DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/warning.gif" HSPACE="5" ALT="Warning"></TD ><TH ALIGN="LEFT" VALIGN="CENTER" ><B >Not Recommended</B ></TH ></TR ><TR ><TD > </TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P > Using the whole disk as a PV (as opposed to a partition spanning the whole disk) is not recommended because of the management issues it can create. Any other OS that looks at the disk will not recognize the LVM metadata and display the disk as being free, so it is likely it will be overwritten. LVM itself will work fine with whole disk PVs. </P ></TD ></TR ></TABLE ></DIV > </P ></LI ><LI ><P > If you get an error that LVM can't initialize a disk with a partition table on it, first make sure that the disk you are operating on is the correct one. If you are very sure that it is, run the following: <DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/warning.gif" HSPACE="5" ALT="Warning"></TD ><TH ALIGN="LEFT" VALIGN="CENTER" ><B >DANGEROUS</B ></TH ></TR ><TR ><TD > </TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P > The following commands will destroy the partition table on the disk being operated on. Be very sure it is the correct disk. </P ></TD ></TR ></TABLE ></DIV > <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="screen" > # dd if=/dev/zero of=/dev/diskname bs=1k count=1 # blockdev --rereadpt /dev/diskname </PRE ></FONT ></TD ></TR ></TABLE > </P ></LI ></UL > For partitions: <P ></P ><UL ><LI ><P > When using LVM 1 on PCs with DOS partitions, set the partition type to 0x8e using fdisk or some other similar program. This step is unnecessary on PPC systems or when using LVM 2. </P ></LI ><LI ><P > Run pvcreate on the partition: <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="screen" > <B CLASS="command" ># pvcreate /dev/hdb1</B > </PRE ></FONT ></TD ></TR ></TABLE > This creates a volume group descriptor at the start of the /dev/hdb1 partition. </P ></LI ></UL > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="commontask.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="createvgs.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Common Tasks</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="commontask.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Creating a volume group</TD ></TR ></TABLE ></DIV ></BODY ></HTML >