You are not logged in.

#1 2015-10-30 17:24:30

AndyWM
Member
Registered: 2015-06-10
Posts: 20

Migrating /home contents to new partition?

When I set up my install I underestimated how much I'd need for /home. (Which is just a directory on root partition, currently nothing is mounted there).

I set my system partitions up in a weird way. I never repeated the mistake in other installs. But I never fixed it on my main system.
>I have a 20GB root,
>8gb swap
>500mb boot,
and then a 450gb partition just mounted to an arbitary place I called /massStorage.

Will I run into any issues (ownership, permission, etc...) if, as root, I run;

cp -R /home /massStorage.
umount /dev/sdb4 (massStorage)
mount /dev/sdb4 /home
genfstab > /etc/fstab

Offline

#2 2015-10-30 17:50:28

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Migrating /home contents to new partition?

AndyWM wrote:
cp -R /home /massStorage.
umount /dev/sdb4 (massStorage)
mount /dev/sdb4 /home
genfstab > /etc/fstab

That look ok. Here's some tips:

I'm not sure "cp -R /home /massStorage" is what you mean to do. Instead, consider:

mkdir /massStorage/storage
mv /massStorage/* /massStorage/storage/ # Which, of course, won't actually move the "storage/" directory, which is a good thing
cp -r /home/* /massStorage/

Tell me if any of that doesn't make sense.

Don't forget that, after you finish copying the "/home" directory, the contents are STILL there. So before you do the mount command, consider moving "/home" to "/home.BAK" and remaking the "/home" directory.

Instead of the "cp" command, consider using "rsync -av". It will preserve the date stamps and permissions and guarantee that the copy finishes successfully. Also, it allows you to stop and restart the copy process. rsync is my new favorite command. big_smile

Sooo... When was the last time you made an external backup? big_smile

Offline

#3 2015-10-30 18:09:06

AndyWM
Member
Registered: 2015-06-10
Posts: 20

Re: Migrating /home contents to new partition?

Hmm...

mkdir /massStorage/storage
mv /massStorage/* /massStorage/storage/

I have emptied /massStorage - so I don't see the point of doing this?

So. New order

mkdir /home.BAK
mv /home /home.BAK
mkdir /home
umount /dev/sdb4
mount /dev/sdb4 /home
rsync -av /home.BAK/home /home
genfstab > /etc/fstab

Look okay?

And, yeah - I've backed anything worthwhile to an external drive...

Last edited by AndyWM (2015-10-30 18:11:24)

Offline

#4 2015-10-30 18:09:59

respiranto
Member
Registered: 2015-05-15
Posts: 479
Website

Re: Migrating /home contents to new partition?

drcouzelis wrote:
mkdir /massStorage/storage
mv /massStorage/* /massStorage/storage/ # Which, of course, won't actually move the "storage/" directory, which is a good thing
cp -r /home/* /massStorage/

Just in case you have some hidden files in /massStorage:

mv /massStorage/{,.[!.]}* /massStorage/storage/

Alternatively you could use `shopt -s dotglob' and `shopt -u dotglob' bevore calling `mv'

Additionally, I would recommend using `cp' with the --preserve=all and the --no-dereference options.
This is what I use in my backup script.

Offline

#5 2015-10-30 18:19:28

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 217

Re: Migrating /home contents to new partition?

All previous content of /massStorage should land into /home/USERNAME, not /home only, cause this area is reserved for root.

The second important thing - /etc/fstab. There should be line with /home, but not with /massStorage. Previous massStorage will be new /home. After /etc/fstab edition generate new initramfs:

mkinitcpio -p linux

Offline

#6 2015-10-30 18:25:49

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Migrating /home contents to new partition?

AndyWM wrote:

Look okay?

Sure, except for "rsync -av /home.BAK/home /home". rsync has a funny way of handling directories (so make sure you test this before making any big commitments):

rsync -av /home.BAK/home  /home # Create the directory "/home/home/" and copy the contents
rsync -av /home.BAK/home/ /home # Copy the contents of "/home.BAK/home/" to the destination directory

Do you see the difference? Actually, I'm not even quite sure I got that right... tongue

Other than that it looks fine I think. smile

@Fixxer: Why is a new initramfs needed?

Last edited by drcouzelis (2015-10-30 18:29:23)

Offline

#7 2015-10-30 18:43:18

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 217

Re: Migrating /home contents to new partition?

Why is a new initramfs needed?

Many many years ago I have had some errors with similar operation. Maybe now it isn't necessary ... File is empty:

lsinitcpio initramfs-linux.img | grep fstab
./etc/fstab

Offline

#8 2015-10-30 19:36:14

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Migrating /home contents to new partition?

You can use cp, but you have to "cp -a" ; which will conserve file attributes. It's better to pass the options -avH if you use rsync, without -H, hardlinks won't be preserved.

Last edited by olive (2015-10-30 19:36:49)

Offline

Board footer

Powered by FluxBB