LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux Mint
User Name
Password
Linux Mint This forum is for the discussion of Linux Mint.

Notices


Reply
  Search this Thread
Old 04-24-2018, 03:01 AM   #1
LouFer
LQ Newbie
 
Registered: Apr 2018
Posts: 8

Rep: Reputation: Disabled
Need help Moving Distro Partition to new HDD


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:

Code:
NAME        FSTYPE LABEL  UUID                                 MOUNTPOINT
/dev/sda                                                       
├─/dev/sda1                                                    
└─/dev/sda2 ntfs   VMDK   CCA038DEA038D0A6                     /mnt/VMDK
/dev/sdb                                                       
└─/dev/sdb1 ntfs   Backup 0EBA0D4C0EBA0D4C                     /mnt/Backup
/dev/sdc                                                       
├─/dev/sdc1 ext4          4b104ecc-091d-4e38-8009-3844216471d8 /media/louis/4b104ecc-091d-4e38-8009-3844216471d8
├─/dev/sdc2 vfat          0A61-2F3B                            /boot/efi
├─/dev/sdc3 ext4   MBR    0535afdb-888f-4563-b009-d22911630266 
├─/dev/sdc5 ext4          406bef67-8af7-4b50-8e9c-63ed35bf4f0b /
└─/dev/sdc6 swap          3c7ce9ed-8fb0-4672-b442-9b4a922b53af [SWAP]
/dev/sr0
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...

Any help would be appreciated
 
Old 04-25-2018, 12:16 PM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
you don't need to remove sdc5, but sdc3. next boot from usb and use gparted to resize sdc5.
But first would be nice to post the result of fdisk -l
 
Old 04-25-2018, 12:48 PM   #3
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,539

Rep: Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496
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?
 
Old 04-25-2018, 01:56 PM   #4
LouFer
LQ Newbie
 
Registered: Apr 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
But first would be nice to post the result of 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.
 
Old 04-25-2018, 02:00 PM   #5
LouFer
LQ Newbie
 
Registered: Apr 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
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

Last edited by LouFer; 04-25-2018 at 02:02 PM.
 
Old 04-25-2018, 04:24 PM   #6
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,539

Rep: Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496
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.
 
1 members found this post helpful.
Old 04-25-2018, 06:35 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Quote:
Originally Posted by LouFer View Post
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,
Code:
sudo parted /dev/sdc "print free"
 
1 members found this post helpful.
Old 04-25-2018, 06:47 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,001

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
More tips. Don't get distracted from other posts.

I like to boot to a live media and use gparted to move/copy partitions. That won't make it usable but it will move or copy.

Looks like you have a hybrid efi mbr deal? Could be wrong. See what sudo efibootmgr says about how you are booting too.
 
Old 04-26-2018, 01:24 AM   #9
LouFer
LQ Newbie
 
Registered: Apr 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
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
 
Old 04-26-2018, 01:31 AM   #10
LouFer
LQ Newbie
 
Registered: Apr 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jefro View Post
See what sudo efibootmgr says about how you are booting too.
Here is the output from sudo efibootmgr

Code:
BootCurrent: 0002
Timeout: 0 seconds
BootOrder: 0002,0003,0013,000D,000E,0000,0001,0007,0008
Boot0000* P5: SAMSUNG SSD PM841 mSATA 25
Boot0001* P1: HL-DT-ST DVDRW/BDROM CH30N
Boot0002* ubuntu
Boot0003* Windows Boot Manager
Boot0007  UEFI OS
Boot0008  UEFI OS
Boot000D* UEFI: IP4 Realtek PCIe GBE Family Controller
Boot000E* UEFI: IP6 Realtek PCIe GBE Family Controller
Boot0013* ubuntu
 
Old 04-26-2018, 01:38 AM   #11
LouFer
LQ Newbie
 
Registered: Apr 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Here is a screenshot of Disks program if that helps...
The highlighted partition is the Mint partition that I want expanded to use whole disk
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2018-04-26 07-34-52.png
Views:	12
Size:	47.3 KB
ID:	27504  
 
Old 04-26-2018, 02:02 AM   #12
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
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.

sdc3 is irrelevant, it is only 300M.

Last edited by pan64; 04-26-2018 at 02:03 AM.
 
1 members found this post helpful.
Old 04-26-2018, 02:26 AM   #13
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
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.
 
Old 04-26-2018, 03:55 AM   #14
LouFer
LQ Newbie
 
Registered: Apr 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
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?

Last edited by LouFer; 04-26-2018 at 03:57 AM.
 
Old 04-26-2018, 04:02 AM   #15
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
That also may work, but you need to keep the old disk and image as long as the new one really works. I'm not really sure about that process.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
HDD Partition Failed Boot / ddrescue Operation Completed / Now What to Try and Restore Failing HDD/Partition? GNewbie Linux - Newbie 15 10-14-2016 03:42 PM
Moving a folder, versus moving its contents (within the same partition) the dsc General 7 06-29-2012 04:46 AM
New HDD install w/data recovery from old HDD w/different distro w/encrypted /home forbinproject Linux - Laptop and Netbook 1 02-27-2012 10:18 PM
Moving primary(boot) partition to another HDD shukuboy Linux - Hardware 3 01-14-2009 11:05 AM
Moving root from a dual-boot HDD to a new HDD Androoski SUSE / openSUSE 1 05-13-2005 10:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux Mint

All times are GMT -5. The time now is 01:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration