If you have made these mistakes when installing your Linux Debian Server at home or work, this article might help you.
* You split the drive into / (root portion) and /home portion. 3 years later and 1-2 Debian upgrades you run out of space on root. You need to move it off to home partition that has 400GB+.
* You have installed ext3 on your / (root partition) instead of xfs for your server. You are finding that mdadm and ext3 and long running servers are not playing so nicely when things go not as planned. Your home partition is xfs so now you would like to move it off to home to be on xfs.
Moving root partition to home. This process should not be taken lightly. You should not be doing this if you are not having any problems. You are doing it at your own risk and as a result you need to read up on what each of these commands might do to your system. You should not be replacing, deleting any data. You should not be deleting old root until a week later when you confirmed it all worked.
When your computer boots and grub menu shows up press “e” to see what your grub is doing and write it down. Mine was doing below. When I search for some troubleshooting howto solutions the key why they didn’t work is because these modules were not loaded. insmod part_gpt and insmod ext2
in grub menu
search --fs-uuid --set a80.....
linux /vmlinuz-3.2.9-4-amd64 root=/dev/mapper/my_lvmgroup_root
*Download Debian live cd
*My case, gpt partitions. sda only has my boot partiton. My sdb,sdc,sdd contain 4TB raid 5 with 3 lvm groups for root,swap,home.
*Mount source (root partition) and destination (home partition)
mount /dev/mapper/my_lvmgroup_root src
mount /dev/mapper/my_lvmgroup_home dest
*Now the key is that you will need to create a home folder inside your home partition and move all the files there.
#now move the files you need. This will make current system accessible only through shell. You will need to access it via pressing for example Alt +F2 and using command line. So be prepared to have a backup tablet to troubleshoot.
#cp /mnt/dest/lucas /mnt/dest/home/lucas
*Now lets sync root partition onto home. Many web pages says to exclude proc,sys,tmp,etc but I decided to copy it since it should work either way.
*I have added other excludes as I see fit
rsync -aAXv --exclude=/lost+found --exclude=/root/trash/* --exclude=/var/tmp/* /mnt/src/* /mnt/dest/
*If your boot partition is located elsewhere. (You can tell if its mounted to a different partition in /mnt/src/etc/fstab. you need to mount it in dest.
*Mount the uuid of the boot into the /mnt/dest/boot
mount UUID=abc...123 /mnt/dest/boot
*I made a copy of that just in case in
#cp -r /mnt/dest/boot /mnt/dest/boot_copy
*Next day when a copy is done. Its time to update grub and /etc/fstab
*Lets create a root folder where we will mount old partition.
*Lets update /etc/fstab aka
#And change your /home partition to /
#Change your old / to /root_old
#The last item on the line is the order for fsck. 0 = nocheck, 1 = check first, 2=secondary check. So update your new / to 1 so that fsck gets it checked as needed.
*First in order to update grub we need real dev,proc,sys from the currently running system. (not these are from the live cd not /mnt/src)
mount -o bind /proc /mnt/dest/proc
mount -o bind /dev /mnt/dest/dev
mount -o bind /sys /mnt/dest/sys
*Now we will chroot…this changes the “/” to point elsewhere in my shell temporally.
*You should see
Found background image....
Found linux image....
found initrd image....
Found Debian GnuLinux 7.8 on /dev/mapper...
#Note for some reason my always says it found it on my root lvm not home lvm..but these instructions did work
*Install grub on your first device where you have current grub. This was required for me because even do I did update-grub it would load into the old / (root partition).
*When system reboots and grub menu shows up press e to see if it points to my_lvmgroup_home.
I guess one of the points for me was: on the old / there was a boot folder that had the old scripts pointing to lvmgroup_root….I renamed it to boot_notused….
I loaded the system, mounted everything src,dest,dev,sys,proc then
* Note 2: when I loaded on lvmgroup_home as / I needed to not only do update-grub but also grub-install /dev/sda
*Note 3: When searching for help somebody said “delete old root partition” and it should work…WRONG…NEVER DELETE old partition. With Linux as long as you don’t delete or overwrite your data you will be always able to go back. So don’t listen to people who tell you to delete your data. There is no going back from that.
*Note 4: At some time in the future I wanted to redo my Raid5 with proper gpt starting not at 63 sector but at 2048 byte. I moved my old raid data to a temporary drive 2TB, (made sure the drive boots and runs fine) deleted and recreated my new raid5 on new partitions tables in each drive and copied data back to raid5. When I follow all the steps above the system said it couldn’t find the /dev/mapper/mygroup_home… When I chroot i did mount -a and then I needed to also do a
update-initramfs -u to correct that.
#Guide that I was sticking by
#1 had missing mounts for proc,dev,sys
but the mkinitcpio was not required…didn’t reasearch waht it is
talks about grub and what it is
some other steps that are very similar
some other steps that are very similar
for note4 a little details on cylinder alignment sector 63 byte vs 2048 byte