最新消息:阿啰哈,本人90后,目前单身,欢迎妹子们来撩!.(。→‿←。)

在LVM分区上安装Xubuntu

Xubuntu 林志斌 603浏览

在LVM分区上安装Xubuntu

为何要使用LVM(有何优点)?

https://wiki.archlinux.org/index.php/LVM#Advantages

为何要在安装系统前来设置LVM?

当然,你也可以使用系统安装过程中默认的LVM分区格局。但是,手动先把LVM分区建立好后再把系统安装在上面,这样所有分区对自己来说都井然有序了,不是吗?

以下记录的是我操作时的一些关键步骤。

[email protected]:~$ sudo su -

#1.分区的创建过程
[email protected]:~# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc0e6870f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-41943039, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +200M

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc0e6870f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 
Using default value 2
First sector (411648-41943039, default 411648): 
Using default value 411648
Last sector, +sectors or +size{K,M,G} (411648-41943039, default 41943039): 
Using default value 41943039

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc0e6870f

   Device Boot      Start         End      Blocks   Id  System
#创建一个200MB大小的分区给/boot使用(注,设置为可启动分区,后面格式化类型为ext2)
/dev/sda1   *        2048      411647      204800   83  Linux
#创建一个LVM类型(类型为83)的分区,所有剩余空间全部给它
/dev/sda2          411648    41943039    20765696   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

#2.LVM的创建过程
#把sda2分区创建为pv
[email protected]:~# pvcreate /dev/sda2
  Physical volume "/dev/sda2" successfully created
[email protected]:~# pvdisplay 
  "/dev/sda2" is a new physical volume of "19.80 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda2
  VG Name               
  PV Size               19.80 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               aylPwt-ydGZ-Lk80-u1ju-x8eb-QRV7-Q9tqUI

#把/dev/sda2创建为vg,名字为kashuVG
[email protected]:~# vgcreate kashuVG /dev/sda2
  Volume group "kashuVG" successfully created
[email protected]:~# vgdisplay 
  --- Volume group ---
  VG Name               kashuVG
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               19.80 GiB
  PE Size               4.00 MiB
  Total PE              5069
  Alloc PE / Size       0 / 0   
  Free  PE / Size       5069 / 19.80 GiB
  VG UUID               sCofPI-6nM2-SyU7-xseh-NfUb-7nmt-6BtiWE

#创建一个1GB大小的LV给swap使用
[email protected]:~# lvcreate -L 1G -n kashuSwap kashuVG
  Logical volume "kashuSwap" created
[email protected]:~# lvdisplay /dev/kashuVG/kashuSwap 
  --- Logical volume ---
  LV Path                /dev/kashuVG/kashuSwap
  LV Name                kashuSwap
  VG Name                kashuVG
  LV UUID                A7WN9U-1beh-dv6G-Zv4I-m4Ey-c0lR-2l1IRQ
  LV Write Access        read/write
  LV Creation host, time xubuntu, 2015-07-02 09:52:10 +0000
  LV Status              available
  # open                 0
  LV Size                1.00 GiB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

#创建一个10GB大小的LV给/使用
[email protected]:~# lvcreate -L 10G -n kashuRoot kashuVG 
  Logical volume "kashuRoot" created
#剩余空间全部给/home使用
[email protected]:~# lvcreate -l 100%FREE -n kashuHome kashuVG
  Logical volume "kashuHome" created
[email protected]:~# lvs
  LV        VG      Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert
  kashuHome kashuVG -wi-a----  8.80g                                           
  kashuRoot kashuVG -wi-a---- 10.00g                                           
  kashuSwap kashuVG -wi-a----  1.00g                                           
[email protected]:~# vgs
  VG      #PV #LV #SN Attr   VSize  VFree
  kashuVG   1   3   0 wz--n- 19.80g    0 

#3.创建文件系统(格式化)
[email protected]:~# mkfs.ext2 /dev/sda1
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
    8193, 24577, 40961, 57345, 73729

Allocating group tables: done                            
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done 

[email protected]:~# for i in /dev/kashuVG/kashuHome /dev/kashuVG/kashuRoot; do mkfs.ext4 $i; done
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
577088 inodes, 2307072 blocks
115353 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2365587456
71 block groups
32768 blocks per group, 32768 fragments per group
8128 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

转载请注明:林志斌 » 在LVM分区上安装Xubuntu

发表评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址