移动/home目录至独立分区
来源:互联网 发布:怎样申请软件著作权 编辑:程序博客网 时间:2024/05/18 02:50
原文: http://dpinglee.blog.163.com/blog/static/14409775320108185223169/
You can move any directory with this tips, and I just use this tip move my home directory to a independent disk.
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.
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.
总结一下:
1)新建一个有足够空间的分区给你要搬移的目录,比如/home
2) 新建一个目录,$mkdir /mnt/newhome
3)把新建的分区挂载到新建的目录下,$sudo mount -t ext3 /dev/hda5 /mnt/newhome
(这里假设了,新建的分区是ext3类型的,并且是在/dev/hda5)
4)把整个/home都拷贝过去,
$cd /home/
$find . -depth -print0 | cpio --null --sparse -pvd /mnt/newhome/
5)卸载 $sudo umount /mnt/newhome
6)把原来的/home 改名,$sudo mv /home /old_home
7)新建一个/home,sudo mkdir /home
8) 把分区挂载过来,$sudo mount /dev/hda5 /home
9)在 “/etc/fstab” file里加上/dev/hda5 /home ext3 nodev,nosuid 0 2,让系统启动的时候就自动挂载。
10)把就的home删除,$sudo rm -r /old_home(不必着急删除旧的home,试试没有问题之后在删除,以防出现问题)chj注释
==========================实践==========================
好吧, 在安装fedora17的时候 分区没有规划好,所以导致现在,更目录空间越来越小,进而导致一些奇怪的问题。
所以,决定重新分出一个分区,然后 将/home目录迁移过去。
首先: 在win7下,用acron disk 将F盘分出了20G。 结果,重启遇到error : unknown filesystem的问题。解决看这里
接下来将这个20G的分区格式化。$mkfs.ext4 /dev/sda6 (别写错了 sda后面的数字要确定好。)
然后按照上面文章步骤做就可以了。
总结:
通过迁移/home目录,学到了很多知识:
parted命令。grub2mkfs.ext4df
怎么在linux下给分区调整大小? parted命令能调整ntfs分区大小吗?
如果能在linux下直接调整分区大小,记得调整分区后更新grub。即$ grub2-mkconfig
这样就能在分区发生变化之后,保证正常启动了。
- 移动/home目录至独立分区
- 迁移Home目录到独立分区
- ubuntu将home目录迁移到独立分区(转)
- ubuntu将home目录迁移到独立分区
- Ubuntu 16.04 /home 目录迁移到独立分区的方法
- Ubuntu 16.04 /home 目录迁移到独立分区的方法
- Linux卸载home独立分区
- linux 不改变目录结构移动 home 目录到新分区
- ubuntu无损增加独立/home分区
- 移动/home 分区到其它分区
- ubuntu tips: Move /home to it’s own partition(移动"/home"目录到单独的分区)
- 迁移/home目录到单独分区
- 在系统工作时调整分区:移动/home
- 想对/home目录进行设置磁盘配额,但是/home不是独立的文件系统,怎么办?
- linux转移/home目录分区与磁盘配额的配置
- 【Ubuntu】将新的分区挂载到home目录
- 更改home分区
- 如何将现有的/home目迁移新的单独分区上,或者其它目录迁移到别的分区
- 10款免费且开源的项目管理工具
- 计算机顶级会议Rankings
- 基于内容的视频标注——视频类型层标注
- Robotium 数据驱动测试框架
- 线程同步组件
- 移动/home目录至独立分区
- 认真做好你的时间管理
- Java 编译 执行
- 一场空,结束了,原来都是一场空,不爽,真是不爽,原来是这样。。。
- ORA-12519: TNS:no appropriate service handler found 解决
- ARGOX CP-2140 如何把PPLB改为PPLA
- Android设计模式学习系列
- Linux命令学习手册-tee命令
- 各种备忘