Chinaunix首页 | 论坛 | 博客
  • 博客访问: 113402
  • 博文数量: 29
  • 博客积分: 2615
  • 博客等级: 少校
  • 技术积分: 461
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-28 16:01
文章分类

全部博文(29)

文章存档

2012年(1)

2011年(4)

2010年(4)

2009年(4)

2008年(16)

分类: LINUX

2009-02-09 15:51:33

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

[]

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

阅读(567) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~