Ubuntu: Moving to a new drive



Question:

I got a 240GB SSD for Christmas, as well as external casing for a hard drive. I have a laptop with a 500GB hard drive on it, and it's quite close to full. Right now, I have Windows 10 and Ubuntu on my HDD, inside my laptop, and a fresh install of Ubuntu on the SSD, connected externally. I want to have Ubuntu on the SSD, which will be connected internally. I'm not yet sure what I'm going to do with Windows, but I will probably need access to it rather soon.

Should I (once again) copy the old Linux partition to the SSD, and run Boot Repair on it from a Live USB? I didn't know about Boot Repair until today or yesterday, so I'm halfway through copying over my Home folder by now. I don't want to waste time with it if it won't work, but if it did, it would keep my programs and settings intact, and would be worth the time.

So, would it work?

lsblk output:

NAME   MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT  loop1    7:1    0   115M  1 loop  /snap/vlc/4  sdb      8:16   0 223.6G  0 disk    â"œâ"€sdb4   8:20   0 220.3G  0 part  /media/joeyubuntu/ae1867d3-bd73-4bd6-96df-93a0  â"œâ"€sdb2   8:18   0   512M  0 part    â""â"€sdb3   8:19   0   2.8G  0 part    loop8    7:8    0 193.5M  1 loop  /snap/vlc/65  loop6    7:6    0  83.1M  1 loop  /snap/core/3247  loop4    7:4    0   121M  1 loop  /snap/discord/38  loop2    7:2    0  83.7M  1 loop  /snap/core/3440  loop0    7:0    0   121M  1 loop  /snap/discord/41  sda      8:0    0 465.8G  0 disk    â"œâ"€sda4   8:4    0    25G  0 part    â"œâ"€sda2   8:2    0    16M  0 part    â"œâ"€sda9   8:9    0   2.8G  0 part  [SWAP]  â"œâ"€sda7   8:7    0  1000M  0 part    â"œâ"€sda5   8:5    0  1000M  0 part    â"œâ"€sda3   8:3    0 371.1G  0 part  /media/joeyubuntu/Windows  â"œâ"€sda1   8:1    0   260M  0 part  /boot/efi  â"œâ"€sda8   8:8    0  45.7G  0 part  /  â""â"€sda6   8:6    0    19G  0 part      â""â"€cryptswap1         253:0    0    19G  0 crypt [SWAP]  loop7    7:7    0 113.6M  1 loop  /snap/blender-tpaw/3  loop5    7:5    0  83.8M  1 loop  /snap/core/3604  loop3    7:3    0 204.8M  1 loop  /snap/discord/32`  


Solution:1

First partition your new disk. Use /dev/disk/by-id/ instead of /dev/sdX so you don't make mistakes.

sudo apt-get install gdisk partclone      lsblk -o NAME,VENDOR,MODEL      sudo gdisk /dev/disk/by-id/usb-modelnamenumber  

Take note that usb-modelnamenumber is a placeholder for your device which will be named by its model number and the interface its connected on like usb.

o  

to create a new GPT partition table.

n  

to add new partitions

1 EFI System 256MiB  2 Linux       60GiB  3 Windows    140GiB  4 Data        20GiB  5 Swap      ~3.6GiB  

add these by using the defaults for the first two prompts in gdisk partition number and first sector. Then for last sector and file system type use this syntax for each partition in order firs the last sector then the fstype:

+256M  ef00    +60G  8300    +140G  0700    +20G  8300  

Then for the last one just use the default which will be the rest of the disk just slightly under 3.6GiB. And use 8200 for the file system type.

Then write changes to disk with w:

sudo mkfs.vfat -F32 /dev/disk/by-id/usb-modelnamenumber-part1  sudo mkfs.ext4 /dev/disk/by-id/usb-modelnamenumber-part2  sudo mkfs.ntfs -f /dev/disk/by-id/usb-modelnamenumber-part3  sudo mkfs.ext4 /dev/disk/by-id/usb-modelnamenumber-part4  sudo mkswap /dev/disk/by-id/usb-modelnamenumber-part5  

You will need to go into Windows and shrink the Windows partition from disk management. Further you will need to restart you Ubuntu and from GRUB run in recovery mode. Then chroot /target Before running the following.

sudo partclone.fat32 -b -s /dev/sda1 -o /dev/disk/by-id/usb-modelnamenumber-part1  sudo partclone.ext4 -b -s /dev/sda8 -o /dev/disk/by-id/usb-modelnamenumber-part2  sudo partclone.ntfs -b -s /dev/sda3 -o /dev/disk/by-id/usb-modelnamenumber-part3  

After this you can return to normal Ubuntu.

It's not clear what sda2,4,5,6,7 are.

sudo mount /dev/disk/by-id/usb-modelnamenumber-part2 /mnt  sudo mount /dev/disk/by-id/usb-modelnamenumber-part1 /mnt/boot/efi  

Open /etc/fstab and change UUIDs because you copied this from an existing drive. They will be in a table where UUID=[UUID] is placed for each device. Replace the [UUID] part.

lsblk -o UUID /dev/disk/by-id/usb-modelnamenumber-part1  

For /boot/efi:

lsblk -o UUID /dev/disk/by-id/usb-modelnamenumber-part2  

For /:

lsblk -o UUID /dev/disk/by-id/usb-modelnamenumber-part5  

For swap:

sudo grub-install --target=x86_64-efi --boot-directory=/mnt/boot --efi-directory==/mnt/boot/efi --bootloader-id="UbuntuSSD"  sudo grub-mkconfig -o /mnt/boot/grub/grub.cfg  sudo umount /mnt/*  

After you've done this you should have two working systems depending on if you pick Ubuntu or UbuntuSSD. At this point you'd want to test if it works.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »