免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1236 | 回复: 0
打印 上一主题 下一主题

Move home to its own partition [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-02-09 15:51 |只看该作者 |倒序浏览

This article is used so much used in support that it is locked from editing to avoid that it is destroyed.
Unfortunately we even had the entire howto section of the wiki destroyed once and parts of it several times.
If you want to contribute please do so in the discussion tab and if it is good I will include it in the main article /husse
If you,like me, have a long story with Windows the chance is that you
only created two partitions when you installed Linux Mint - at least I
did. Linux handles partitions much better than Windows so it's a good
thing to have a few partitions.
You can use this guide to move any folder to its own partition
simply by replacing home with your folder (boot, var and usr are the
most likely candidates)
You may have to use the live CD at some stage for this, if necessary
files cannot be found when you move around. If you try this you should
know how to do that so that's not included
Contents [
hide
]

  Changed recommendations
We would now recommend you not to have a separate home, but a
separate partition for all your data which you mount in home. This way
you get a new fresh home when (if) you install. This is slightly
simpler to achieve - see also below for guidance
1) Follow the steps below except "Make the partition your new home"
Instead create a folder in home, you could call it Data
Edit fstab so the partition gets mounted - for Elyssa this would be
gksu gedit /etc/fstab (or kdesu kate or gksu thunar)
and add the line
/dev/sdax        /home/your_username/Data         ext3        relatime        0        2
sdax would of course be changed to the number your partition has
Then mount the partition - you could reboot but better is
sudo mount -t ext3   /dev/sdax   /home/your_username/Data
We assume that you don't have a separate home partition, but that really does not matter
Check that the new partition is there with all its data
Now delete everything in home except the hidden files and folders  - they contain your present settings
Change Thunderbird so it starts using the profile folder in Data instead of the one directly in home
This is done by editing the file profiles.ini in /home/your_username/.mozilla-thunderbird
Change the path to the path to your profile in Data and change IsRelative from 1 to 0
We would not recommend the same for Firefox, but do save the bookmarks in the Data partition.
Of course there may be other applications where you want to use a "profile" in the new Data partition
  The simple basics
It's really very simple to achieve this goal.
1) Create a partition
2) Copy /home to that partition
3) Remove/rename your old /home folder
4) Mount the /home partition in a new /home folder
As always there is a but (or rather several).
  Create a partition
GParted can resize a partition on your disk to make room for a new
partition for home. Before you do this it's best to defragment the
partition you want to shrink if it is a Windows partition (FAT, NTFS)
and back up your data!
It should not be a problem though, if you are careful. You have to
decide for your self if you want take the (small) risk of data loss. I
back up all valuable partitions daily so data loss is no problem for
me.
Format the new partition, the preferred file system is ext3
  Copy /home to that partition
This has to be done in several steps.
First create a folder to mount your new empty partition in.
sudo mkdir /mnt/newhome
It seems that mnt is a folder often used for this purpose.
Mount the new partition:
sudo mount -t ext3 /dev/sda4 /mnt/newhome
Change sda4 to what ever your partition is labeled. Check that the partition is mounted - you could right click > Properties.
  Copying is not just copying
You may think copy is copy, so what? However there are things like
hidden files, symbolic and hard links and user rights to consider. This
is a problem in Windows as well as Linux.
One method, presented by the above mentioned blog is this elaborate
command: "find . -depth -print0 | cpio –null –sparse -pvd".
Unfortunately there is no sudo which lead me to the erroneous
conclusion that you should not copy as root, but that's the only way to
do it. This is much simpler and does the job:
sudo cp -a -v -u /home/* /mnt/newhome/
-a means the options dpR together.
-d is "preserve=link"
-p is "never follow symbolic links"
-R is "copy directories recursively"
-v is "verbose"
-u is "copy only when the SOURCE file is newer than the destination file or when the destination file is missing"
This gives a correct copy of /home in the new partition
Check the copy - there should be the same number of files and bytes in /home and in your new partition.
  Make the partition your new home
First, rename your current home:
sudo mv /home /old_home
Then make a new home folder:
sudo mkdir /home
Unmount the partition:
sudo umount /mnt/newhome
Mount the partition in your new home folder:
sudo mount /dev/sda4 /home
Of course you should change sda4 to what ever you have. Now you have a working home on its own partition.
Make the change last:
Edit fstab, sudo gedit /etc/fstab, and add:
/dev/sda4 /home ext3 nodev,nosuid 0 2
Again change sda4 to whatever you have.
If you used the guide to move /boot the line in fstab is
/dev/sda4 /boot           ext3    defaults        0       2
and again change sda4 to whatever you have.
Finally  - when everything is ok get rid of the old home
sudo rm -r /old_home
You are done!
Installing when you have home on a separate partition
My recommendation here has changed.
Move all hidden files and folders (in /home of course) into an archive
so you get a fresh install without the risk that old settings play
tricks on you.
Do not delete them - there are settings for different applications you may want to use when you reinstall - use with care
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/18280/showart_1820705.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP