[SOLVED] Need help Moving Distro Partition to new HDD
Linux MintThis forum is for the discussion of Linux Mint.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Ok, so I have Googled this for days now, and there is lots of detail on how to move a Partition to another partition, or disk to another disk, but I cannot find info/help on how to move a partition (from a multi-boot system) to another disk and make it bootable.
Here is what I'd like to do, and would like a Linux guru to help me with it. This is a printout of lsblk -f -p of my system for reference:
Ignoring sda and sdb for now, I currently have a multi-boot (grub) system that boots either Mint (/dev/sdc5) or Ubuntu (/dev/sdc3). I no longer want the Ubuntu installation, and would like to remove ALL partitions in sdc that are not required, and have my Mint partition resized to take up all available disk space (as though I have installed it from scratch).
So what I have tried is to firstly attach a USB disk to the system, then copy the sdc5 partition using dd to this disk. If I remove sdc5 (and leave the USB disk connected) and reboot, the system fails to boot saying something like it can't find bootable media. This step is just really a test to see if the partition I want copied correctly before deleting the original partition(s). It is at this point I gave up as I don't know what to do, and I am too scared of trashing my partitions...
You'd best check sdc1, the EFI partition to see what you have there. Are you booting from the Ubuntu Grub2 or from the Mint Grub2? Do you have separate directories in the EFI directory for Mint and Ubuntu?
Simply copying the contents of the Mint partition (sdc5) is not going to allow you to boot another usb. With an EFI system, you need the specific Mint directory from the efi partition.
Since all you plan to do is remove the Ubuntu partition, you just need to verify that you are booting with Mint's Grub, then you can resize or create another partition for data from the old Ubuntu partition. If you see the green Mint boot screen, you should be alright. You should be able to select Mint from the boot options in the BIOS also, can you do that?
You'd best check sdc1, the EFI partition to see what you have there. Are you booting from the Ubuntu Grub2 or from the Mint Grub2? Do you have separate directories in the EFI directory for Mint and Ubuntu?
Simply copying the contents of the Mint partition (sdc5) is not going to allow you to boot another usb. With an EFI system, you need the specific Mint directory from the efi partition.
Since all you plan to do is remove the Ubuntu partition, you just need to verify that you are booting with Mint's Grub, then you can resize or create another partition for data from the old Ubuntu partition. If you see the green Mint boot screen, you should be alright. You should be able to select Mint from the boot options in the BIOS also, can you do that?
Here is the Contents of the EFI partition:
Code:
MintXPS EFI # ls
Boot Microsoft ubuntu
As far as booting from grub2... not really sure (how can I verify?) I did install Grub Customizer
Mint is an Ubuntu derivative and it may use the name 'ubuntu' for the directory in the EFI partition so the 'ubuntu' you see in your EFI directory could be the Ubuntu or the Mint. Mount your efi partition and navigate to the /EFI/ubuntu directory. There should be a stub grub.cfg file there which will have on the first line the UUID and the partition. If the root shows hd2,gpt5, that's Mint if it is gpt3, that's Ubuntu. It may not show hd2, it depends upon how you are accessing it and how many drives are attached. If you haven't changed drives and you ran the lsblk output above from the installed Mint, I would expect it to show hd2,gpt5. Good luck.
I no longer want the Ubuntu installation, and would like to remove ALL partitions in sdc that are not required, and have my Mint partition resized to take up all available disk space (as though I have installed it from scratch).
It's not that simple - nothing every is, as you've already found. It can be done with difficulty, but the same effect can be achieved by merely reusing the partitions space as-is.
Quote:
So what I have tried is to firstly attach a USB disk to the system, then copy the sdc5 partition using dd to this disk. If I remove sdc5 (and leave the USB disk connected) and reboot, the system fails to boot saying something like it can't find bootable media. This step is just really a test to see if the partition I want copied correctly before deleting the original partition(s).
You need to accommodate that efi partition - that's where the boot code is.
Quote:
It is at this point I gave up as I don't know what to do, and I am too scared of trashing my partitions...
Good - quite reasonable.
Your test is invalid, but the idea is ok - but all you really need to do is backup your data. The system can always be reinstalled in need (not just this, say a disk crash), and it will sort out all the boot issues - then just get your data back.
As for the space issue itself, let's see that "fdisk -l" you were asked to provide. Or better,
Thank you to everyone here who took the time to reply... much appreciated.
Here is the output of
Code:
sudo parted /dev/sdc "print free"
Code:
Model: ATA SAMSUNG SSD PM84 (scsi)
Disk /dev/sdc: 256GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
3 1049kB 316MB 315MB ext4
2 316MB 420MB 105MB fat32 EFI system partition boot, esp
1 420MB 164GB 163GB ext4
5 164GB 250GB 85.8GB ext4
6 250GB 256GB 6450MB linux-swap(v1)
256GB 256GB 335kB Free Space
And here is output from fdisk -l
Code:
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3DD6A6D2-CE38-45DE-A199-E74ED7A175C9
Device Start End Sectors Size Type
/dev/sda1 34 262177 262144 128M Microsoft reserved
/dev/sda2 264192 976771071 976506880 465.7G Microsoft basic data
Disk /dev/sdb: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 7ABE885E-8AC3-44D4-B494-14B8D4F8C6ED
Device Start End Sectors Size Type
/dev/sdb1 63 5860528063 5860528001 2.7T Microsoft basic data
Partition 1 does not start on physical sector boundary.
Disk /dev/sdc: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 95F48649-68F6-11E4-8253-AC7BA141AF5E
Device Start End Sectors Size Type
/dev/sdc1 821248 319893503 319072256 152.1G Linux filesystem
/dev/sdc2 616448 821247 204800 100M EFI System
/dev/sdc3 2048 616447 614400 300M Linux filesystem
/dev/sdc5 319893504 487520255 167626752 80G Linux filesystem
/dev/sdc6 487520256 500117503 12597248 6G Linux swap
Partition table entries are not in disk order.
Ok, so it seems that this might not be as stright forward as I thought (as syg00 mentioned). What if I 'dd' the Mint Partition to an image file, format sdc, then copy it back. This would mean that I will (somehow) need to put the boot thing (grub? mbr? efi?) back. Is that possible?
Incase you're wondering why I don't just do a standard back, then re-install, then restore.... it's because I have WINE based software installed that need windowns .dll's registered in all sorts of system places (and it was a real nightmare to get to work) and I don't want to have to go through all that pain again if I can avoid it
what I can see:
if /dev/sdc1 is your ubuntu, which you want to drop you can boot mint and remove everything from that filesystem (= make it empty).
Next you can shrink it to a few megs or even less (but probably you can use 6G as swap later).
Next you can increase the size /dev/sdc5 - because it is next to sdc1 and you can add the space freed in the previous step - using an usb boot and gparted.
I think this will work without modifying the partition layout, just by resizing them.
Furthermore you can move swap to sdc1 and add sdc6 to sdc5, but it will modify the layout therefore it may have impact on boot.
All of what pan64 is reasonable and do-able. Simply.
Another option is to use /dev/sda1 (after reformat) as /home. Not quite as simple, but also doable. /home is where all the growth typically is, and it will also free up space on /dev/sda5 as a side benefit.
Get some backups first - Mint includes tools to do this. I do not consider dd a backup tool in this context - it has its uses, but this ain't one of them.
Ok, that is certainly an option, but what if...
I 'dd' sdc5 to an image somewhere, then disconnect sdc and add a new disk to the system. I will do a clean install of mint to this new disk and set up the swap partition etc as I want. After that, I 'dd' the image over the clean install partition (thus keeping the boot system in place). If this works, then I can just clone that new disk to the old sdc disk.
Any thoughts?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.