Ubuntu18 copy system to mobile hard disk

Because sometimes a notebook is needed for mobile office work, and sometimes a desktop graphics card is needed for computing, so I thought of copying the desktop Ubuntu 18 to the mobile hard disk, so that the mobile hard disk can be plugged into the notebook at ordinary times, and the notebook can be used to write code. Just plug it into your desktop when you need to do calculations.

All Linux systems are files, so you only need to copy the entire disk through GParted. However, since the hard disk where the system is located has changed, it is necessary to manually modify the Grub configuration information

copy system


  1. Use the U disk to boot, try Ubuntu without installing, press e to edit the Nvidia graphics card, change the quiet splash to nomodeset
  2. Ubuntu 18.04 comes with GParted, which cleans up an unallocated area larger than the original system on the mobile hard disk
  3. On the gparted interface, right-click the Ubuntu system partition to be backed up and select copy, then go to the free space of the new hard disk and right-click to select paste
  4. perform copy operation
  5. The last step, new UUID ,
    the hard disk universal unique identifier (UUID) under Ubuntu
    requires that the disk is not mounted. Right-click on each partition and select new UUID. If it is not new, the UUID of the hard disk bound to this partition is the previous hard disk, which will cause the boot of this system to point to the previous system

configure grub


The grub2 startup configuration file grub.cfg is in /boot/grub/grub.cfg.
Generally, it is not recommended to directly modify grub.cfg, because it is a file generated by various configuration files through update-grub.
But this is a chicken or an egg problem. Although grub.cfg is modified through the system, the system is started through grub.cfg. Modify the grub.cfg and configuration files at the same time, and then completely update the grub configuration information through update-grub after logging in to the system

/etc/default/grub	grub的默认配置文件,可以修改一些常见的参数
/etc/grub.d			这个文件夹下面是一些生成grub.cfg文件的可执行脚本,可以修改
/boot/grub/grub.cfg	系统引导时读取的文件之一,由其他文件生成的,一般不在这里修改

/etc/default/grub :


Here we have two files to modify:
grub.cfg
/etc/fstab

Mount the mobile hard disk

  1. View hard disk information and UUID
    sudo fdisk -l
    sudo blkid
    
  2. create folder
    sudo mkdir ubuntu-ssd/sda1
    sudo chmod 755 ubuntu-ssd/sda1
    sudo mkdir ubuntu-ssd/sda2
    sudo chmod 755 ubuntu-ssd/sda2
    
  3. mount
    sudo mount /dev/sda1 /media/ubuntu-ssd/sda1
    sudo mount /dev/sda2 /media/ubuntu-ssd/sda2
    

Modify UUID

  1. Open it first /etc/fstab, and you will find that the UUID value of the partition here is the UUID on the desktop, because the UUID is copied together when copying, so here you can change the original UUID to the new UUID
  2. revise grub.cfg.
    This file can also change the UUID value to a new one.
    This file is very long, but there is no need to modify all UUID values. This file is /etc/grub.dgenerated according to the modules inside. We only need to modify the UUID value of the Linux part.

restart the system

Restart the system, and the BIOS will start from the new hard disk. In the new hard disk system, execute it sudo update-grubto update /boot/grub/grub.cfg on the hard disk again. Since then, the entire system cloning process has been completed.

Reference blog:
Ubuntu system directly copy hard disk clone
to modify Ubuntu startup items

Guess you like

Origin blog.csdn.net/qq_20493631/article/details/114286129