gparted and how to change /home directory to a new partition

First,you should install gparted.

sudo apt-get install gparted.

and then type

second:sudo gparted

Third:you can use gparted to change the filesystem and size of every partition.

Note:you should umount the partitions to enable the third operations.

Fourth:you can use the following tutors to move the /home diretory to the new partitions.

Having the “/home” directory tree on it’s own partition has several advantages, the biggest perhaps being that you can reinstall the OS (or even a different distro of Linux) without losing all your data. You can do this by keeping the /home partition unchanged and reinstalling the OS which goes in the “/” (root) directory, which can be on a seperate partition.

   But you, like me, did not know this when you first installed Ubuntu, and have not created a new partition for “/home” when you first installed Ubuntu. Despair not, it is really simple to move “/home” to its own partition.


  First, create a partition of sufficient size for your “/home” directory. You may have to use that new hard drive, or adjust/resize the existing partition on your current hard-drive to do this. Let me skip those details.


  Next, mount the new partition:

 

  $mkdir /mnt/newhome

  $sudo mount -t ext3 /dev/hda5 /mnt/newhome

  (You have to change the “hda5″ in the above to the correct partition label for the new partition. Also, the above assumes that the new partition you created is formatted as an ext3 partition. Change the “ext3″ to whatever filesystem the drive is formatted to.)

 

  Now, Copy files over: Since the “/home” directory will have hardlinks, softlinks, files and nested directories, a regular copy (cp) may not do the job completely. Therefore, we use something we learn from the Debian archiving guide:

 

  $cd /home/

  $find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/

  Make sure everything copied over correctly. You might have to do some tweaking and honing to make sure you get it all right, just in case.

  

  Next, unmount the new partition:


  $sudo umount /mnt/newhome

  Make way for the new “home”

 

  $sudo mv /home /old_home

  Since we moved /home to /old_home, there is no longer a /home directory. So first we should recreate a new /home by:


  sudo mkdir /home

  Mount the new home:

 

  $sudo mount /dev/hda5 /home

  (Again, you have to change “hda5″ to whatever the new partition’s label is.)

  

  Cursorily verify that everything works right.

  Cursorily确认一切运行正确。

  Now, you have to tell Ubuntu to mount your new home when you boot. Add a line to the “/etc/fstab” file that looks like the following:

 

  /dev/hda5 /home ext3 nodev,nosuid 0 2

  (Here, change the partition label “hda5″ to the label of the new partition, and you may have to change “ext3″ to whatever filesystem you chose for your new “home”)

  

  Once all this is done, and everything works fine, you can delete the “/old_home” directory by using:

 

  $sudo rm -r /old_home

  Michael, Russ and Magnus posted this solution on the ubuntu-users mailing list a few months ago.

  

  

 

  这张图已经是调整后的图了。我来说一下调整的过程。用live CD启动电脑,让硬盘里的系统不被占用。先把swap分区删掉。释放出2G的空闲空间,再新建一个swap,大小与我的内存相当就可以了。但把这一个G的空间挂载为/home又有点捉襟见肘。反正给ubuntu的可用空间只有10个G多一点。而其它的分区都是NTFS的,装着XP系统。现在的ubuntu已经可以很好的支持NTFS分区格式。所以,现有的NTFS分区不必做任何的调整。10G的UBUNTU分区如果不够用,就可以把文档放到NTFS分区上。但同为ext3格式的/home则应该尽量大一点。想到/目录不用8.6个G那么大,只是装个系统而已,而且该装的软件也装得差不多了。只有/home目录在不断扩大。所以应该把/目录的容量调整一点到/home目录。现在我的/home目录经过整理后为350M.至少要从/目录调整一个G到/home目录。也是用liveCD启动进行操作。因为此时,硬盘的所有分区都处于释放状态,很方便做调整。在LIVE系统下启动分区管理器,可以很方便在调整分区的大小。先把/目录调整为7个G.这样就释放出1.6G的空闲空间。再把这部分空间加到/home目录上。

  实际操作用了30分钟左右全部完成。ubuntu的分区管理工具工作非常警慎。每进行一项重要调整后就要进行整个分区的完全检测一次。虽然用掉不少时间,但这是对自己和用户都负责的态度。

  最后,就是把图中sda9上的/home目录迁移到sda10分区上,并实现自动挂载。也是通过liveCD系统来完成的。不过注意一点,必须要有root权限。这个简单,虽然live系统的ROOT是随机的密码,到用户管理里改一下就可以了。有了ROOT,就可以很方便地把/home目录移动到sda10上。然后再改一下sda9分区里的/etc/fstab文件,把sda10自动挂载为/home。当然。别忘了sda9下也要有/home目录。目录为空就可以了。这样系统启动后自动就把sda10挂载到系统的/home目录下了。于是实现了/home目录存在于单独分区之上。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值