Moving home to a partition on the same disk

Questions about hardware,drivers and peripherals
Forum rules
Before you post please read how to get help
Post Reply
deepakdeshp
Level 15
Level 15
Posts: 5613
Joined: Sun Aug 09, 2015 10:00 am

Moving home to a partition on the same disk

Post by deepakdeshp » Sun May 20, 2018 6:07 am

Hello ,
As a step in this I have to copy the /home partition to another one.
I plan to do following

Code: Select all

sudo mkdir /home1 ;sudo mount /dev/destination /home1; sudo chmod 644 /home1 ;sudo chown owner:owner /home1 [b]cp -rpd /home /home1 [/b] 
is the command to copy and preserver all permissions /home to /home1 correct?

Code: Select all

cp -rpd /home /home1
.
After verifying the sizes of /home and /home1 being the same with du -sm I would proceed as follows

Code: Select all

sudo umount /home /home1

Code: Select all

sudo mount /dev/destination /home
.

Please review once, especially the command

Code: Select all

 cp -rpd /home /home1 
.
Thanks all in anticipation
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help, and keeps the forum clean.
Regards,
Deepak

I am using Mint 19.2 Cinnamon 64 bit with AMD A8/7410 processor . Memory 8GB

User avatar
WharfRat
Level 21
Level 21
Posts: 13071
Joined: Thu Apr 07, 2011 8:15 pm

Re: Moving home to a partition on the same disk

Post by WharfRat » Sun May 20, 2018 8:39 am

If you want to move your home to its own partition, this works - enter one line at a time and change the partition to use in the first line to your new home partition

Code: Select all

PART=sda6

FMT=ext4

sudo cp -a /etc/fstab /etc/fstab.old

sudo mkdir /mnt/newhome

sudo mount -t $FMT /dev/$PART /mnt/newhome

sudo chown $USER:$USER /mnt/newhome

cd /home

find . -depth -print0 | cpio --null --sparse -pvd /mnt/newhome/

sudo umount /mnt/newhome

sudo mv /home /old_home

sudo mkdir /home

sudo mount /dev/$PART /home

sudo rm -r /old_home

echo -e "# /dev/$PART home\n$(blkid|grep $PART|grep -wo "UUID=\"[^\"]*\""|tr -d '"')  /home   $FMT   errors=remount-ro,noatime  0 2" |sudo tee -a /etc/fstab

Good luck :wink:
ImageImage

deepakdeshp
Level 15
Level 15
Posts: 5613
Joined: Sun Aug 09, 2015 10:00 am

Re: Moving home to a partition on the same disk

Post by deepakdeshp » Mon May 21, 2018 1:52 pm

Thank you. That's a killer script with a lots of wizardry. I will be moving /home, which doesnt have a partition now to sda10 which already has some directories and files. I see that the script doesnt do anything to disturb or delete the current files. I will do the transition after a fortnight or so.

If Wharfrat runs any blog, I am eager to know the address.!!
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help, and keeps the forum clean.
Regards,
Deepak

I am using Mint 19.2 Cinnamon 64 bit with AMD A8/7410 processor . Memory 8GB

Post Reply

Return to “Hardware Support”