Linux使用LVM管理磁碟分割

來源:互聯網
上載者:User

   傳統分區管理一旦確定分區的大小就很難改變,即使有些軟體工具可以做到,但是難免會讓一些資料丟失,也很靠譜。

   使用LVM LogicalVolumeManager(邏輯卷管理)管理我們的分區後,我們可以任意的修改分區大小,不用擔心資料的丟失,這種動態分配分區的大小是我們最需要的。從此以後我們不必擔心分區滿了所帶來的困惑。

使用隨身碟或CD啟動Linux安裝程式

http://www.bjwilly.com/archives/325.html

啟動Linux安裝程式之後,選擇“try to ubuntu”,開啟終端執行一下命令安裝lvm2

$ sudo apt-get install lvm2

接下來就是對磁碟分割

sudo fdisk -l #查看磁碟號


可以看到我有兩塊磁碟,分別是:sda和sdb,我們將dev/sdb這塊磁碟作為要分區的對象

$ sudo fdisk /dev/sdbThe number of cylinders for this disk is set to 9729.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)Command (m for help): n #建立新分區命令Command actione extendedp primary partition (1-4)pPartition number (1-4): 2 #分區號First cylinder (1033-9729, default 1033):Using default value 1033Last cylinder or +size or +sizeM or +sizeK (1033-9729, default 9729): +100M #設定分區大小Command (m for help): nCommand actione extendedp primary partition (1-4)pPartition number (1-4): 3First cylinder (1058-9729, default 1058):Using default value 1058Last cylinder or +size or +sizeM or +sizeK (1058-9729, default 9729):Using default value 9729Command (m for help):tPartition number (1-4): 3Hex code (type L to list codes): 8e #修改分區code,為LVM格式Command (m for help):w #執行操作The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table.The new table will be used at the next reboot.Syncing disks.$ sudo partprobe #重新整理磁碟

通過上面的命令我們將dev/sdb 分了兩個區,分別為100M和磁碟剩下的空間,接下來就是建立我們的LVM

$ sudo mke2fs -j /dev/sd2$ sudo pvcreate /dev/sdb3 #在sdb3建立一個物理塊(物理塊可以為多個)Physical volume “/dev/sdb3″ successfully created$ sudo vgcreate lvmvolume /dev/sdb3 #在這個物理塊上建立一個名為lvmvolume的卷組,(卷組可以為多個)Volume group “lvmvolume” successfully created$ sudo lvcreate -n root -L 5G lvmvolume #在名為lvmvolume的卷組中建立一個名為root,大小5G的邏輯卷Logical volume “root” created$ sudo lvcreate -n home -L 10G lvmvolume #create a logical volume of 10G named “home” in lvmvolumeLogical volume “home” created$ sudo lvcreate -n swap -L 2G lvmvolume #create a logical volume of 2G named “swap” in lvmvolumeLogical volume “swap” created$ sudo mkfs -j /dev/lvmvolume/root -L root #format root as ext3$ sudo mkfs -j /dev/lvmvolume/home -L home #format home as ext3$ sudo mkswap -L swap /dev/lvmvolume/swap #format swap as swap filesystem, labelled swap

通過上面的步驟就可以安裝linux了,到時候把檔案系統掛在到邏輯卷上就可以了

原文獻地址:

http://www.debuntu.org/how-to-install-ubuntu-on-lvm-partitions/

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.