注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

心情挺好的博客

正在等你光临呢 呵呵

 
 
 

日志

 
 
关于我

喜欢摄影的朋友看过来:) 有时间就跟我一起去拍照去吧. QQ272751 上海圣玛丽摄影化妆培训学校 16年专业摄影培训化妆培训学校 电话:15900513500。 http://www.smlsh.com

网易考拉推荐

wubi安装ubuntu后,想增加linux系统空间的方法 (分离、迁移分区文件夹)  

2009-01-12 00:40:53|  分类: 技术 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

 Posted in ubuntu, wubi by 20sanguo on the 6月 9th, 2008

如果安装时只有一个单独的root.disk文件,现在想利用剩余硬盘空间加大linux的空间
用wubi的官方脚本举个例子,这个脚本功能就是把原root.disk中的一个文件夹分离成一个单独的disk文件。
https://wiki.ubuntu.com/WubiGuide
在这下载https://wiki.ubuntu.com/WubiGuide?action=AttachFile&do=get&target=wubi-add-virtual-disk

下面已迁移分离home为例

#!/bin/sh
usage="\nWrong arguments. The function should be invokes as follow:\n\n\t$0 target_directory size_mb\n\nFor instance, in order to move /home to a dedicated virtual disk of 15000MB use:\n\n\t$0 /home 15000\n"


if [ -z "$1" ] || [ -z "$2" ] || [ ! -d "$1" ] || [ ! "$2" -eq "$2" ]; then
echo $usage
exit 1
fi
target=”$1″
#home or usr 填入要分离文件夹的名字,一般就是 home 、usr 或者var
virtual_disk="$(echo ${target#/}|sed 's:/:_:')".disk
size_mb="$2" #new virtual disk size in MB
free_space=$(df -B 1M /host|tail -n 1|awk '{print $4}')
if [ $size_mb -lt 2000 ]; then
#可以修改2000为一个适合你自己硬盘剩余空间的大小
echo "The size $size_mb is too small, 2000MB minimum are required."
exit 1
fi
if [ -e "/host/ubuntu/disks/$virtual_disk" ]; then
echo “The target virtual disk /host/ubuntu/disks/$virtual_disk already exists, aborting.”
exit 1
if [ $free_space -lt $size_mb ]; then
echo “Not enough free space ($free_space MB < $size_mb MB), aborting.”
exit 1
fi

cd /host/ubuntu/disks
dd if=/dev/zero of=”$virtual_disk” bs=1MB count=1 seek=”$size_mb” #建立一个分区文件
mkfs.ext3 -F "$virtual_disk" #格式化该分区文件,可以是mkfs.reiserfs或 mkfs.xfs(需要XFSprogs),也许-F要改为-f
mv ${target} ${target}.backup #把要分离文件夹改名
mkdir ${target}
echo "/host/ubuntu/disks/$virtual_disk ${target} ext3 loop 0 0" >> /etc/fstab
#修改 /etc/fstab文件 ext3改为你之前格式化的
mount ${target} #加载格式化好的文件
cp -a ${target}.backup/* ${target} #原需要分离的所有文件到新的系统分区里
echo "\nOperation completed successfully, if all is good feel free to remove ${target}.backup\n\nRebooting is recommended."

按自己需要修改好 在终端中执行sudo sh wubi-add-virtual-disk /home 15000
这/home 15000 参数按自己需要修改
提示完成,重启机器。如果有问题把备份文件夹名改回如: /home.backup改为/home ,删除 /etc/fstab里新加得那行删除/host/ubuntu/disks/home.disk /home ext3 loop 0 0

重启即可

运行测试没问题可以把 那个备份文夹 (如上面的 /home.backup)删除。

把其他windows分区的剩余空间做一个disk文件也应该是一样的。在linux熟悉后想添加一个真实磁盘分区,操作上也是差不多的。把dd那行的操作改为用fdisk创建分区,home.disk 换成/dev/sdax就行了。
就算以后想要个“真实安装的”linux,也无须重装,保留双系统直接照上面个干。单系统,在引导部分做文章就行了。

非wubi安装的基本上也差不多这样操作吧。

wubi官方的移动至真实磁盘脚本出了
https://wiki.ubuntu.com/WubiGuide
https://wiki.ubuntu.com/WubiGuide?action=AttachFile&do=get&target=wubi-move-to-partition

As an alternative, the following script can be used with Wubi 8.04.

Download wubi-move-to-partition

Open a terminal and run:

sudo sh wubi-move-to-partition /dev/sda9 /dev/sda10

Replace /dev/sda9 with the partition where you would like to migrate the Wubi installation to, and /dev/sda10 with the appropriate swap partition (you can omit the second argument completely, in which case no swap will be setup). The two partitions must already exist and be empty (you can use any partitioning tool such as gparted to create them in advance). Note that the script will install grub as main bootloader replacing the existing bootloader, and it may not be easy to undo the changes (if things do not work as expected you will have to boot from a Live CD and replace/edit the bootloader manually). Also note that if you have multiple hard-disks, the disk order might have to be adjusted manually.

1、先用你喜欢的工具建两个大小合适的分区。
2、mkfs.ext3 $dev 可以改成你需要的格式
3、没有用cp而用的是rsync同步命令, exclude是忽略参数
4、如果没有修改这个脚本直接运行,bootloader会被修改,有问题后只能用 Live CD,所以之前先备份下。把ubuntu那个目录备份好就行了,刻张盘费不了啥事,swap不用刻,文件还可以压缩。我还是觉得/boot留在win分区 里方便些,ubuntu升级很容易搞死img文件。

2 Responses to 'wubi安装ubuntu后,想增加linux系统空间的方法 (分离、迁移分区文件夹)'

Subscribe to comments with RSS or TrackBack to 'wubi安装ubuntu后,想增加linux系统空间的方法 (分离、迁移分区文件夹)'.

  1. 匿名 said,

    on 7月 26th, 2008 at 9:43 下午

    小心使用!!!!
    文件 home.disk制作出的文件大小已超过我电脑此分区的实际大小.不知道重要文件会不会丢失!

    D:盘实际大小:30G
    放在D盘的所有文件合计大小:40G!!
    为什么?

  2. 20sanguo said,

    on 7月 26th, 2008 at 11:41 下午

    任何操作都要小心,不仅仅是这个脚本。
    为什么,应该问下自己哟。注意文章第一句说明了利用剩余空间,下面的说明也有,我估计
    你的 wubi-add-virtual-disk /home 15000<<-这个数字一定大于你的剩余空间。究竟应该是多少,谁能比你自己更清楚呢?

 

 

 

 

 

 

 

 

 

############################

 

 

#!/bin/sh -e    # Moves the specified directory to a new virtual disk.    # Copyright (C) 2008 Agostino Russo <agostino.russo@gmail.com>    # This program is free software; you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by  # the Free Software Foundation; either version 2, or (at your option) any  # later version.  #  # This program is distributed in the hope that it will be useful,  # but WITHOUT ANY WARRANTY; without even the implied warranty of  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  # GNU General Public License for more details.  #  # You should have received a copy of the GNU General Public License  # along with this program; if not, write to the Free Software  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA    usage="\nWrong arguments. The function should be invokes as follow:\n\n\t$0 target_directory size_mb\n\nFor instance, in order to move /home to a dedicated virtual disk of 15000MB use:\n\n\t$0 /home 15000\n"    if [ -z "$1" ] || [ -z "$2" ] || [ ! -d "$1" ] || [ ! "$2" -eq "$2" ]; then       echo $usage      exit 1  fi  if [ "$(whoami)" != root ]; then      echo "Admin rights are required to run this program."      exit 1  fi     target="$1" #home or usr  virtual_disk="$(echo ${target#/}|sed 's:/:_:')".disk  size_mb="$2" #new virtual disk size in MB  free_space=$(df -B 1M /host|tail -n 1|awk '{print $4}')  if [ $size_mb -lt 2000 ]; then      echo "The size $size_mb is too small, 2000MB minimum are required."      exit 1  fi  if [ -e "/host/ubuntu/disks/$virtual_disk" ]; then      echo "The target virtual disk /host/ubuntu/disks/$virtual_disk already exists, aborting."      exit 1  fi   if [ $free_space -lt $size_mb ]; then      echo "Not enough free space ($free_space MB < $size_mb MB), aborting."      exit 1  fi    cd /host/ubuntu/disks  dd if=/dev/zero of="$virtual_disk" bs=1MB count=1 seek="$size_mb"  mkfs.ext3 -F "$virtual_disk"  mv ${target} ${target}.backup  mkdir ${target}  echo "/host/ubuntu/disks/$virtual_disk    ${target}    ext3    loop    0    0" >> /etc/fstab  mount ${target}  rsync -av --exclude=${target}.backup/.gvfs ${target}.backup/* ${target}  echo "\nOperation completed successfully, if all is good feel free to remove ${target}.backup\n\nRebooting is recommended."    
  评论这张
 
阅读(908)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017