0

I installed ubuntu from a usb drive and it all went fine and is working well but i accidentally installed it ONTO the usb drive and now it needs to be plugged in all the time as that is where the os is actually located, how do i move it onto my computer's internal hard drive??

NAME FSTYPE LABEL UUID MOUNTPOINT  

sdb
├─sdb5 ext4 7c39212a-20e5-4e92-9d21-1714959c4b8e
└─sdb1
sda
├─sda2
├─sda5 ext4 6d2ddbb4-a126-4a80-aee6-1e7f6f6f73a1 /home
└─sda1 swap c6ac02d8-7986-420a-9374-129a3656b0c9 [SWAP]

NAME MOUNTPOINT LABEL SIZE FSTYPE UUID  

sdb 7.4G
├─sdb5 / 7.4G ext4 7c39212a-20e5-4e92-9d21-1714959c4b8e
└─sdb1 1K
sda 74.5G
├─sda2 1K
├─sda5 /home 18.6G ext4 6d2ddbb4-a126-4a80-aee6-1e7f6f6f73a1
└─sda1 [SWAP] 487M swap c6ac02d8-7986-420a-9374-129a3656b0c9

ubfan1
  • 17,838
  • Is the hard drive empty or does it have data on it? If so does it already have an OS on it? if it is empty, you can clone the USB to it using dd. Or you can do a fresh install to the computer's internal hard drive and copy the home directory from the USB to the computer using rsync or grsync. – C.S.Cameron Apr 20 '18 at 16:07
  • 2
    UUIDs need to be different, or you cannot have flash drive & hard drive mounted at same time as duplicate UUIDs are not allowed. Reinstall of grub and edit of fstab are the minimum changes required to fix up UUIDs. Generally better/easier just to do a new install & copy /home into new install on hard drive. Then your settings changes & data is still the same.Also if drive is gpt, you should not use dd to copy just a partition. UUID, GUIDs are in partition, partition table & backup partition table, so many fixes required. – oldfred Apr 20 '18 at 16:14
  • 2
    Are you sure that you installed Ubuntu into a USB drive? If I understand correctly, you write that you installed from a live Ubuntu USB drive to the same USB drive, but I would not think so, unless you really knew what you were doing. But it is more likely that you installed the bootloader to the USB drive (but the main part of Ubuntu to a root partition on the internal drive). Or have you got more than one USB drive, and two of them were connected during installation? Please check with the command sudo lsblk -f and post the output into your original question. – sudodus Apr 20 '18 at 16:16
  • If you really need to clone from the USB drive, I suggest that you use Clonezilla. – sudodus Apr 20 '18 at 16:23
  • 1
    Yes, If I recall correctly, an install from USB using Something else defaults to putting grub on the USB and not the hard drive. It is probably easier to reinstall using Something else than install grub manually. If the computer just has an empty HDD and a live flash drive and the source USB drive, dd can't be too dangerous but clonzilla is also a good tool, and UUID's should not be a problem as flash drive & hard drive will not be mounted at same time, but I have never had a problem with that anyway. – C.S.Cameron Apr 20 '18 at 17:58
  • @oldfred: if I mount 2 devices with the same UUID, the second device plugged in gets a 1 after the UUID number. – C.S.Cameron Apr 20 '18 at 19:19
  • You can mount several devices with the same UUID (or label), the problem is to boot from one device, when a cloned copy (with the same UUIDs) is present. – sudodus Apr 20 '18 at 19:24
  • I just booted clone live disk with original live disk plugged in without problem, when I check the UUID's in gparted I see that the UUID of the original disk is the same as the clone except it has a 1 after it, like if you have two casper-rw files mounted. Everything else seems to work OK. – C.S.Cameron Apr 20 '18 at 20:36
  • @C.S.Cameron Yes. It's easier to read than if it were in the comments. It would have been easier to read had you pasted it exactly the way it occurred on your screen. I'm sure you tried to format it, but if you would have left it exactly the way it was from the copy/paste, the system would have been able to make it appear correctly formatted the way it was on your screen. Sometimes it take a little work from both sides to get the best help. – L. D. James May 11 '18 at 16:35

1 Answers1

0

Choose the partition on your hard drive where you want to copy your Ubuntu partition. If you don't have a partition, the use Gparted to create one.

You might best consider reserving two partitions. One for the Ubuntu OS and one for swap. Specify as type ext4 for the Ubuntu partition. Specify as type swap for the swap partition. I would make the one for Ubuntu sufficient large. The swap partition should be about 1 1/2 times the size of the amount of ram you have in the computer.

Use this command to copy the Ubuntu partition from the USB to the hard drive. In this example I'll use /dev/sdb2 for the hard drive I'm using /dev/sda3. The dd command is a critical and non-forgiving operation, so you have to be very careful when using it. Writing to the wrong partition can cause all data to be removed from that partition.

$ sudo dd if=/dev/sdb2 of=/dev/sda3 bs=32M status=progress

The parameters are:

  • if= Read from this device (in your case it should be the USB Ubuntu partition)
  • of= Write to this device (in your case it should be the destination partition on your hard drive)
  • status= Display progress

Once you have the OS partition copied, install the Grub boot manager on your Hard Drive. While there are many ways to do it. I find the manual steps in this link fairly seamless:

Manually adding or fixing Grub

It works both with UEFI and bio boot.

Note:

The Destination partition must be equal or larger than the source when cloning the partition. Use Gparted to resize the new copied partition to match the size difference so that you will have full use of the space you allocated for Ubuntu.

L. D. James
  • 25,036
  • @sudodus this is what it says

    NAME FSTYPE LABEL UUID MOUNTPOINT sdb
    ├─sdb5 ext4 7c39212a-20e5-4e92-9d21-1714959c4b8e / └─sdb1
    sda
    ├─sda2
    ├─sda5 ext4 6d2ddbb4-a126-4a80-aee6-1e7f6f6f73a1 /home └─sda1 swap c6ac02d8-7986-420a-9374-129a3656b0c9 [SWAP]

    – Ajishio Taro Apr 21 '18 at 04:17
  • @AjishioTaro You would best place this information in your question. Edit and paste the information here. This way anyone trying to help can easily view your details. It'd be substantially easier to read also. – L. D. James Apr 21 '18 at 04:30
  • @AjishioTaro Add the output of this command to your question: sudo lsblk -o name,mountpoint,label,size,fstype,uuid – L. D. James Apr 21 '18 at 04:39
  • NAME MOUNTPOINT LABEL SIZE FSTYPE UUID sdb 7.4G
    ├─sdb5 / 7.4G ext4 7c39212a-20e5-4e92-9d21-1714959c4b8e └─sdb1 1K
    sda 74.5G
    ├─sda2 1K
    ├─sda5 /home 18.6G ext4 6d2ddbb4-a126-4a80-aee6-1e7f6f6f73a1 └─sda1 [SWAP] 487M swap c6ac02d8-7986-420a-9374-129a3656b0c9
    – Ajishio Taro May 10 '18 at 18:10
  • @AjishioTaro You're pasting the output to the wrong place. It needs to be added, as important details to your question. Add the output here. – L. D. James May 10 '18 at 18:17
  • so does that give you any useful information @L.D.James – Ajishio Taro May 11 '18 at 16:16