/ 中存储网

如何使用LVPM将Wubi-Ubuntu桌面版复制到专有分区的方法及命令

2015-01-21 00:00:00 来源:中存储网

如何使用LVPM将Wubi-Ubuntu桌面版复制到专有分区的方法及命令

Wubi是Windows Ubuntu-Based Installer的缩写,即在windows的分区(NTFS)中虚拟一段磁盘空间,作为独立于windows的loop分区,作为linux的根目录/。

使用LVPM(Loopmounted Virtual Partition Manager)可以扩展虚拟磁盘的空间(使用LVMP的resize功能),或者将linux系统从虚拟的磁盘拷贝到真实的分区下,实现真正的windows+linux双系统。

1.分区

在wubi-Ubuntu下,使用系统自带的磁盘实用工具,建议将空白的分区分出一个linux下的交换分区(SWAP),剩余的作为linux的分区(ext2,ext3或ext4格式)。

接下来是磁盘分区之后的数据

administrator@ubuntu:~$ sudo fdisk -l

[sudo] password for administrator:   Disk /dev/sda: 320.1 GB, 320072933376 bytes   255 heads, 63 sectors/track, 38913 cylinders   Units = cylinders of 16065 * 512 = 8225280 bytes   Sector size (logical/physical): 512 bytes / 512 bytes   I/O size (minimum/optimal): 512 bytes / 512 bytes  

Disk identifier: 0x00000001 

Device           Boot     Start    End           Blocks        Id       System

/dev/sda1      *          1       1275     10241406       7   HPFS/NTFS

/dev/sda2                1276   1397         979965     82   Linux swap / Solaris

/dev/sda3                1398   6123     37961595     83   Linux

/dev/sda4                6124  38913   263385675       f   W95 Ext'd (LBA)

/dev/sda5                6124  16723   85144468+       7  HPFS/NTFS

/dev/sda6              16724  27738     88477956       b  W95 FAT32

/dev/sda7              27739  38913     89763156       7  HPFS/NTFS

从上面的数据可以看出,主分区从/dev/sda1开始,扩展分区从/dev/sda4开始,第一个扩展分区为/dev/sda5. 不妨再看看分区容量。

administrator@ubuntu:~$ df -lh

文件系统 容量 已用 可用已用%% 挂载点

/dev/sda3 36G 4.1G 30G 12%/

none 999M 328K 999M 1%/dev

none 1004M 348K 1004M 1%/dev/shm

none 1004M 92K 1004M 1%/var/run

none 1004M 0 1004M 0% /var/lock

/dev/sda1 9.8G 4.6G 5.3G 47%/media/SYS

/dev/sda5 82G 75G 7.1G 92% /media/SOFT

/dev/sda6 85G 75G 9.9G 89% /media/WORK

/dev/sda7 86G 81G 4.9G 95% /media/BACK

分区的UUID(Universally Unique Identifier即唯一识别码)也是应该知道的。

administrator@ubuntu:~$ ls -al /dev/disk/by-uuid

总计 0 drwxr-xr-x 2 root root 160 2011-04-23 01:31 .

drwxr-xr-x 6 root root 120 2011-04-23 01:31 ..

lrwxrwxrwx 1 root root 10 2011-04-22 17:31 15fbe968-a73a-4b14-8315-ae841cf0d048 -> ../../sda3

lrwxrwxrwx 1 root root 10 2011-04-22 17:31 237D-1AF7 -> ../../sda6

lrwxrwxrwx 1 root root 10 2011-04-22 17:31 293d2cc0-614c-4b02-887d-354a29de1220 -> ../../sda2lrwxrwxrwx 1 root root 10 2011-04-22 17:31 9AC4BB30C4BB0D8F -> ../../sda7

lrwxrwxrwx 1 root root 10 2011-04-22 17:31 D028BF0728BEEB9A -> ../../sda5

lrwxrwxrwx 1 root root 10 2011-04-22 17:31 DE305BE6305BC3E5 -> ../../sda1

2.使用LVMP工具的transfer功能。

这一步,LVMP做三件事:格式化目标分区成ext4格式;复制文件;安装、复制grub。

注意修改bootgrub  下的grub. cfg   文件

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi

function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}

function recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}

function load_video {
}

if [ "${recordfail}" = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/10_lupin ###
menuentry "Ubuntu,grub.cfg Linux 2.6.35-22-generic on /dev/sda3" {
insmod part_msdos
insmod ext3
set root='(hd0,msdos3)'
search --no-floppy --fs-uuid --set 15fbe968-a73a-4b14-8315-ae841cf0d048
loopback loop0 /ubuntu/disks/root.disk
set root=(loop0)
linux /boot/vmlinuz-2.6.35-22-generic root=/dev/sda3 loop=/ubuntu/disks/root.disk ro quiet splash
initrd /boot/initrd.img-2.6.35-22-generic
}
menuentry "Ubuntu,grub.cfg Linux 2.6.35-22-generic on /dev/sda3 (recovery mode)" {
insmod part_msdos
insmod ext3
set root='(hd0,msdos3)'
search --no-floppy --fs-uuid --set 15fbe968-a73a-4b14-8315-ae841cf0d048
loopback loop0 /ubuntu/disks/root.disk
set root=(loop0)
linux /boot/vmlinuz-2.6.35-22-generic root=/dev/sda3  loop=/ubuntu/disks/root.disk ro single
initrd /boot/initrd.img-2.6.35-22-generic
}
### END /etc/grub.d/10_lupin ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional (on /dev/sda1)" {
insmod part_msdos
insmod ntfs
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set de305be6305bc3e5
drivemap -s (hd0) ${root}
chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
在这一步,应该注意,将分区的uuid和路径改成目标分区(即红色标注部分)。因为LVPM在复制grub的时候,没有将分区和路径改过来。

同时也要修改bootgrub 下的menu.lst

default=0
timeout=5
title Ubuntu-on-menu.lst/dev/sda3
insmod part_msdos
insmod ext3
set root='(hd0,msdos3)'
search --no-floppy --fs-uuid --set 15fbe968-a73a-4b14-8315-ae841cf0d048
loopback loop0 /ubuntu/disks/root.disk
set root=(loop0)
linux /boot/vmlinuz-2.6.35-22-generic root=/dev/sda3 loop=/ubuntu/disks/root.disk ro quiet splash
kernel /boot/vmlinuz-2.6.35-22-generic ro root=/dev/sda3
initrd /boot/initrd.img-2.6.35-22-generic

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root

title UnknownOS
root (hd0,4)
makeactive
chainloader +1
boot

title Microsoft Windows XP Professional
root (hd0,0)
makeactive
chainloader +1
boot