Ubuntu搬迁:从虚拟磁盘到真实的分区


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

    我当初也是直接在Windows下安装的,用了一段时间后,觉得Ubuntu8.04很不错,就想将它从虚拟文件中搬移出来,直接存放到我新建的分区下以提高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

    格式化完成后重启一次。

  • 1
  • 2
  • 3
  • 下一页

相关内容