Changing /home to another HDD

Installing and upgrading FreeBSD.

Changing /home to another HDD

Postby caesius » 19 Feb 2011, 03:44

I have a single HDD at the moment. I want to keep this drive but add a new 320GB HDD and make that the new [FILE]/home[/FILE].

How should I go about this and are there any pitfalls to avoid? In my mind I will do this:

1. Connect new HDD and format with UFS.
2. Copy [FILE]/home/*[/FILE] onto the new HDD.
3. Edit [FILE]fstab[/FILE] and add the line:
Code: Select all
/dev/ad2s1 /usr/home ufs rw 1 1


How does this sound? Do I have to specify any flags to cp to retain permissions etc? Also, on tangential note, could I use ZFS for this new [FILE]/home[/FILE] partition?

Cheers.
caesius
Member
 
Posts: 277
Joined: 16 Nov 2008, 03:23
Location: New Zealand

Postby wblock@ » 19 Feb 2011, 04:39

Use at least -a with [man=1]cp[/man], but I would use [port]net/rsync[/port]:
[cmd="#"]rsync -aH /usr/home/ /mnt/[/cmd]

Might also want -A and -X or others.

If the new drive is faster than the old, you might be better moving the whole system over to it.
User avatar
wblock@
Old Fart
 
Posts: 10158
Joined: 07 Sep 2009, 23:23
Location: Milky Way galaxy

Postby jem » 19 Feb 2011, 11:48

If your home directories are to reside in a seperate filesystem from [FILE]/usr[/FILE], then just mount it directly under [FILE]/home[/FILE], not under [FILE]/usr/home[/FILE].

You'll have to delete the [FILE]/home[/FILE] symlink to [FILE]/usr/home[/FILE] first then create an empty [FILE]/home[/FILE] directory to use as the new mountpoint.
jem
Member
 
Posts: 342
Joined: 23 Oct 2009, 11:24

Postby SirDice » 19 Feb 2011, 14:24

jem wrote:If your home directories are to reside in a seperate filesystem from /usr, then just mount it directly under /home, not under /usr/home.

You'll have to delete the /home symlink to /usr/home first then create an empty /home directory to use as the new mountpoint.


And if you just mount it under [file]/usr/home/[/file] you don't have to change anything at all :e

This is from the top of my head:
Code: Select all
gpart create -s MBR ad2
gpart add -t freebsd-ufs -l myhome ad2
newfs /dev/gpt/myhome
mkdir /mnt/home
mount /dev/gpt/myhome /mnt/home
tar -C /usr -cf - home | tar -C /mnt -xvf -
umount /mnt/home
rm -rf /usr/home/*
mount /dev/gpt/myhome /usr/home/

You can also try GPT instead of MBR for the partitioning scheme, see [man=8]gpart[/man]. The piped tar commands will make sure everything is copied correctly, including hard and softlinks. The label makes it easier to 'handle' the disk. Now it won't matter which drive number or driver (ad0, ad1, da0, da1, ada0, etc.) it gets.

And last but not least, edit [file]/etc/fstab[/file]:
Code: Select all
/dev/gpt/myhome /usr/home/ ufs  rw  2   5


Obviously you need this placed after the [file]/usr/[/file] entry. The 5 is to make sure the fsck is run after the others have finished, higher numbers are done last. Especially when you have multiple (big) filesystems it pays off not to run them all at the same time.
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16149
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

Postby gkontos » 19 Feb 2011, 14:53

You don't need to use gpt for that unless you want to boot from it. Instead label the disk:
Code: Select all
glabel label -v name /dev/ad2 (where ad2 is your new drive)

And your fstab would look like this:
Code: Select all
/dev/label/name /usr/home/ ufs  rw  2   5

Assuming you mount your new drive under /tmp you can easily copy your data like this:
[CMD=]#(cd /home && tar cf - .) | (cd /mnt && tar xpf -)[/CMD]
Powered by BareBSD
User avatar
gkontos
Senior Member
 
Posts: 1370
Joined: 09 Dec 2009, 08:36
Location: Polidendri, GR


Return to Installing & Upgrading

Who is online

Users browsing this forum: No registered users and 2 guests