幼教 | 试题 | 电脑 | 作文 | 常识 | 加入收藏 | 网站地图

您当前位置:多思学习网文章资讯考试频道计算机考试Linux认证详解如何从虚拟磁盘到真实的分区(1)

详解如何从虚拟磁盘到真实的分区(1)

01-23 15:56:59Linux认证
浏览次数:127次 
标签:linux认证考试,linux,su,认证失败,http://www.duosi8.com 详解如何从虚拟磁盘到真实的分区(1),

    ubuntu为了增强windows用户的体验,拉拢windows用户加入到linux阵营,做了一些重要改进:允许直接在windows下安装ubuntu,就是运行安装盘中那个叫做wubi.exe的windows执行程序;允许 windows用户在没有剩余未分区磁盘空间的情况下,将ubuntu安装在windows分区的一个文件内(类似vmware的虚拟硬盘)。

    我当初也是直接在windows下安装的,用了一段时间后,觉得ubuntu8.04很www.duosi8.com,就想将它从虚拟文件中搬移出来,直接存放到我新建的分区下以提高ubuntu的磁盘访问性能。毕竟虚拟磁盘没有真正的磁盘快。经过了一天的研究,最终搬迁成功了,拿出来和大家一起分享。写此文的目的不是鼓励大家也和我一样也进行类似的搬迁行为,只是和大家一起学习,更能认识到linux操作系统的一些特长和技术。

步骤如下:

一、创建新分区

( 因为本人安装windows时将磁盘的最后50G没有分区,留作以后它用,所以有剩余空间创建新分区)

创建分区需要在ubuntu操作系统下进行,命令为:
sudo fdisk /dev/sda

具体操作见下边:
administrator@administrator-desktop:~$ sudo fdisk /dev/sda

The number of cylinders for this disk is set to 19457.
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): p

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x1e851e84

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1275 10241406 7 HPFS/NTFS
/dev/sda2 1276 18355 137195100 f W95 Ext'd (LBA)
/dev/sda5 1276 2550 10241406 7 HPFS/NTFS
/dev/sda6 2551 6374 30716248+ 7 HPFS/NTFS
/dev/sda7 6375 8924 20482843+ b W95 FAT32

Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (10750-18355, default 10750):
Using default value 10750
Last cylinder or +size or +sizeM or +sizeK (10750-18355, default 18355): +14G

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.
administrator@administrator-desktop:~$

说明:
进入fdisk后,出现提示符Command (m for help):要求输入命令,常用命令如下:
p 显示已有分区
n 创建新分区
m 显示帮助
w 将改动写入磁盘

二、格式化新建分区
创建分区后使用fdisk 的p命令再次显示分区情况,如下:
/dev/sda1 * 1 1275 10241406 7 HPFS/NTFS
/dev/sda2 1276 18355 137195100 f W95 Ext'd (LBA)
/dev/sda5 1276 2550 10241406 7 HPFS/NTFS
/dev/sda6 2551 6374 30716248+ 7 HPFS/NTFS
/dev/sda7 6375 8924 20482843+ b W95 FAT32
/dev/sda8 8925 10749 14659281 83 Linux

可以看到新分区的设备号为/dev/sda8 ,格式化它!命令为 sudo mkfs -j /dev/sda8

格式化完成后重启一次。

三、拷贝ubuntu操作系统的文件到新分区.
以下操作最好在维护模式下进行,就是进入ubuntu系统时在grub下选择recovery mode。本人在一般模式下试过,拷贝某些目录时报了一些错误,但是没有验证这些错误对搬迁后的系统有没有影响,就直接进入了维护模式进行搬迁。

我们看一下都有那些文件和目录需要拷贝,执行命令ls -l /,显示如下:
drwxr-xr-x 2 root root 4096 20xx-06-06 08:48 bin
drwxrwxrwx 3 root root 4096 20xx-06-17 09:00 boot
lrwxrwxrwx 1 root root 11 20xx-06-13 18:09 cdrom -> media/cdrom
drwxr-xr-x 13 root root 14420 20xx-06-17 08:29 dev
drwxr-xr-x 133 root root 12288 20xx-06-17 10:18 etc
drwxr-xr-x 3 root root 4096 20xx-04-28 16:51 home
drwxrwxrwx 2 root root 4096 20xx-06-16 17:10 host
drwxr-xr-x 2 root root 4096 20xx-04-23 01:48 initrd
lrwxrwxrwx 1 root root 33 20xx-06-13 18:11 initrd.img -> boot/initrd.img-2.6.24-19-generic
drwxr-xr-x 16 root root 4096 20xx-06-11 15:01 lib
drwx------ 2 root root 16384 20xx-06-13 18:08 lost+found
drwxr-xr-x 5 root root 4096 20xx-06-17 10:18 media
drwxr-xr-x 2 root root 4096 20xx-06-13 18:12 mnt
drwxr-xr-x 5 root root 4096 20xx-05-22 17:50 opt
drwxr-xr-x 2 oracle dba 4096 20xx-05-05 09:45 oracle
dr-xr-xr-x 137 root root 0 20xx-06-17 16:29 proc
drwxr-xr-x 18 root root 4096 20xx-06-13 17:57 root
drwxr-xr-x 2 root root 4096 20xx-06-13 18:55 sbin
drwxr-xr-x 2 root root 4096 20xx-04-23 01:48 srv
drwxr-xr-x 12 root root 0 20xx-06-17 16:29 sys
drwxrwxrwt 16 root root 4096 20xx-06-17 10:55 tmp
drwxr-xr-x 13 root root 4096 20xx-05-05 09:05 usr
drwxr-xr-x 15 root root 4096 20xx-04-23 02:07 var
lrwxrwxrwx 1 root root 30 20xx-06-13 18:13 vmlinuz -> boot/vmlinuz-2.6.24-19-generic

,详解如何从虚拟磁盘到真实的分区(1)

《详解如何从虚拟磁盘到真实的分区(1)》相关文章

tag: Linux认证,linux认证考试,linux,su,认证失败,考试频道 - 计算机考试 - Linux认证

联系我们 | 网站地图 | 幼教大全 | 试题下载 | 电脑学习 | 加入收藏


幼儿园教案_ 教案模板_ 课件模板_ 教学反思_ 教学计划


多思学习网 1 2 3 4 5 6