Moving home to a partition on the same disk

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
deepakdeshp
Level 20
Level 20
Posts: 12337
Joined: Sun Aug 09, 2015 10:00 am

Moving home to a partition on the same disk

Post by deepakdeshp »

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
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
WharfRat

Re: Moving home to a partition on the same disk

Post by WharfRat »

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:
deepakdeshp
Level 20
Level 20
Posts: 12337
Joined: Sun Aug 09, 2015 10:00 am

Re: Moving home to a partition on the same disk

Post by deepakdeshp »

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.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
Locked

Return to “Hardware Support”