Linux move partition start

How to move Linux root partition to another drive quickly

Jun 21, 2019 · 4 min read

There’s a bunch of information over internet on how to clone the Linux drives or partitions between other drives and partitions using solution like partclone , clonezilla , partimage , dd or similar, and while most of them are working just fine, they’re not always the fastest possible way to achieve the result.

Today I want to show you another approach that combines most of them, and I am finding it the easiest and fastest of all.

  1. You are using GRUB 2 as a boot loader
  2. You have two disks/partitions where a destination one is at least the same size or larger than the original one.

Let’s dive in into action.

Just “dd” it…

First thing that we h ave to do, is to create a direct copy of our current root partition from our source disk into our target one.

Before you start, you have to know what are the device names of your drives, to check on that type in:

You should see the list of all the disks and partitions inside your system, along with the corresponding device names, most probably something like /dev/sdx where the x will be replaced with proper device letter, in addition to that you’ll see all of the partitions for that device prefixed with partition number, so something like /dev/sdx1

Based on the partition size, device identifier and the file-system, you can say what partitions you’ll switch your installation from and which one will be the target one.

I am assuming here, that you already have the proper destination partition created, but if you do not, you can utilize one of the tools like GParted or similar to create it.

Once you’ll have those identifiers, let’s use dd to create a clone, with command similar to.

Where /dev/sdx1 is your source partition, and /dev/sdy1 is your destination one.

It’s really important to provide the proper devices into if and of arguments, cause otherwise you can overwrite your source disk instead!

The above process will take a while and once it’s finished you should already be able to mount your new partition into the system by using two commands:

There’s also a chance that your device will be mounted automatically but that varies on a Linux distro of choice.

Once you execute it, if everything went smoothly you should be able to run

And as the outcome you should see all the files from the core partition, being stored in the new location.

It finishes the first and most important part of the operation.

Now the tricky part

We do have our new partition moved into shiny new drive, but the problem that we have, is the fact that since they’re the direct clones both of the devices will have the same UUIDs and if we want to load your installation from the new device properly, we’ll have to adjust that as well.

Читайте также:  Цветной интерфейс для windows

First, execute following command to see the current disk uuid’s

You’ll see all of the partitions with the corresponding UUID.
Now, if we want to change it we have to first generate a new one using:

which will generate a brand new UUID for us, then let’s copy it result and execute command similar to:

where in place of /dev/sdy1 you should provide your target partition device identifier, and in place of -U flag value, you should paste the value generated from uuidgen command.

Now the last thing to do, is to update our fstab file on new partition so that it’ll contain the proper UUID, to do this, let’s edit it with.

you’ll see something similar to the code below inside:

The bold part is important for us, so what we want to do, is to paste our new UUID replacing the current one specified for the / path.

And that’s almost it

The last part you have to do is to simply update the grub.

There are a number of options here, for the brave ones you can edit the /boot/grub/grub.cfg

Another option is to simply reinstall grub into our new drive with command:

And if you do not want to bother with editing or reinstalling grub manually, you can simply use the tool called grub-customizer to have a simple and easy GUI for all of those operations.

Источник

Top 6 Partition Managers (CLI + GUI) for Linux

Are you looking to tweak or manage your disks partitions in Linux? In this article, we will review some of the best tools that help Linux users partition and manage their disks. We will see both command line utilities as well as GUI applications for managing disk partitions in Linux.

I favor the command line over GUI (graphical user interface), I will start by describing the text based utilities and then GUI applications as follows.

1. Fdisk

fdisk is a powerful and popular command line tool used for creating and manipulating disk partition tables. It supports multiple partition tables formats, including MS-DOS and GPT. It provides a user-friendly, text based and menu driven interface to display, create, resize, delete, modify, copy and move partitions on disks.

Fdisk Partition Tool

2. GNU Parted

Parted is a popular command line tool for managing hard disk partitions. It supports multiple partition table formats, including MS-DOS, GPT, BSD and many more. With it, you can add, delete, shrink and extend disk partitions along with the file systems located on them.

Parted Partition Program

It can help you create space for installing new operating systems, reorganizing disk usage, and move data to new hard disks.

3. Gparted

GParted is a free, cross platform and advanced graphical disk partition manager that works on Linux operating systems, Mac OS X and Windows.

GParted Partition Manager and Editor

It is used to resize, copy, move, label, check or delete partitions without data loss, enabling you to grow or shrink root partition, create space for new operating systems and attempt data rescue from lost partitions. It can be used to manipulate file systems including EXT2/3/4.

4. GNOME Disks a.k.a ( GNOME Disks Utility)

GNOME Disks is a core system utility used for disk partition management and S.M.A.R.T monitoring. It is used to format and create partition on drives, mount and unmount partitions. It ships in with the well known GNOME desktop environment.

Gnome Disks

Lately, it’s been gaining features for advanced usage. The latest version (at the time of this writing) has a new feature for adding, resizing partitions, checking filesystems for any damages and repairing them.

5. KDE Partition Manager

KDE partition manager is a useful graphical utility for managing disk devices, partitions and file systems on your computer. It comes with the KDE desktop environment.

Читайте также:  How to install ventoy on linux

KDE Partition Manager

Most of its underlying work is performed by programs. It can be used to easily create, copy, move, delete, resize without losing data, backup and restore partitions. It supports various including EXT2/3/4, BTRFS NTFS, FAT16/32, XFS, and more.

6. Qtparted

In addition, you can also use Qtparted, is a Partition Magic (proprietary software for Windows) clone and Qt front-end to GNU Parted. Note that it still in development and you may likely experience any kind of problem with latest release. In that case try to use the CVS version or a previous stable version.

QTParted Partition Magic

It may not be one of the best options now but you can give it a try. More features are yet being added to it.

You might also like to read these following related articles.

These are the best partition managers and editors available for Linux operating systems. Which tool do you use? Let us know via the comment section below. Also let us know of any other partition managers for Linux, missing in the list above.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Ubuntu Documentation

The purpose of this how-to is to describe how to move your Ubuntu Linux partition to a different partition either in same hard-disk or different hard-disk.

Many other article of same subject in Internet seems to be outdated on following parts:

  1. Grub2 (Ubuntu 9.10 and later)
  2. UUID for partition identification (Ubuntu 6.10 and later)

Hence, the main purpose of this article to fill in the gap as well as one stop reference for the entire steps.

Following are outlines of steps involved:

  • Create new target partition
  • Clone current Linux partition to target partition
  • Generate and update UUID for target partition
  • Update grub and fstab
  • Update MBR to point the new grub.

Few assumptions I make are:

  1. Your Ubuntu is 9.10 or later
  2. Your Ubuntu is on ext4 partition (gparted should be to copy/paste any other file-system as well, however these steps were tested on ext4)
  3. Your Ubuntu configuration is of standard (not too customized)
  4. Grub2 is your boot loader

SystemRescueCd — I prefer this rescue CD as it comes with gparted utility

  • You are not changing swap partition
  • If any of above assumptions do not apply to your system, then you will need to execute following steps with cautions.

    Step 1: Booting through Rescue CD

    A copy of SystemRescueCd can be obtain from here.

  • Burn this to a CD
  • And reboot the machine to boot from the rescue CD
    • You may need to change configuration in your bios to enable boot up from CD
  • Choose default booting option and type «wizard» once it goes to prompt
  • Now you should have X desktop loaded.
  • Step 2: Create new partition

    • Launch gparted from start menu
    • Using gparted create a new partition on your target hard-disk.

      Make sure the size new partition is same or bigger than your current Ubuntu partition used space.

    • You may also mount current Ubuntu partition to clean up unnecessary files in the partition to reduce the size.
    • And once you are done, make sure to unmount

    Step 3: Clone Ubuntu partition to new location

    • On gparted window, right-click on Ubuntu partition and select «Copy»
    • Then right-click on the new partition you have just created and select «Paste»
      • gparted will start step-by-step copy process. This may take a while.
      • You may also opt to use dd for the same purpose, but I prefer gparted because
        • It does calculate optimal way to copy over the data (block size)
        • It able to verbose current progress status

    Step 4: Generate and update UUID

    • Since step 3 copy and paste produce the new partition with exact same UUID, this will conflict and grub not able to tell the partitions apart. Hence we need to update UUID information on new partition.
    • Following is to check current UUID (You should notice duplicate UUID)
    • And following is to generate and update UUID.
    • Verify UUID (All UUIDs should be unique now)

    Step 5: Update grub and fstab

      Reboot your system from Rescue system back to normal Ubuntu

    Once you have booted to your original Ubuntu, mount the partition via gnome -> Places option

  • Edit grub.cfg file from new partition.
  • Note that you should edit grub.cfg from new partition and not from «/boot/grub/grub.cfg»

    • Using gedit, find and replace every «(hdX,Y)» appropriately
      • X and Y should be replaced based on your new partition’s /dev/sdZY or /dev/hdZY, if Z is ‘a’ then X should be ‘0’, if Z is ‘b’ then X should be ‘1’ and so on.

      Using gedit, find and replace every «—fs-uuid —set » based on new generated UUID.

    • Also still within the same file, find and replace every ‘menuentry ‘Ubuntu. » to «menuentry ‘UBUNTU. «. This is just to verify which grub is used for main boot menu. This will be overwritten by grub-update later.
    • Edit fstab file from new partition

    Note that you should edit grub.cfg from new partition and not from «/etc/fstab»

      Using gedit, find and replace root mount point’s (line with «/») based on new generated UUID.

    Step 6: Update MBR to point the new grub

    • By now, you have 2 proper bootable Ubuntu in your system, and the idea now is to make the new Ubuntu partition self bootable without any dependencies to old Ubuntu partition. And to get ride the old Ubuntu partition eventually.
    • Before updating MBR, backup current MBR data

    Mount the partition via gnome -> Places option (if is not mounted)

  • Run grub setup for new partition
  • Where [instance] is the version you want to make bootable

    • Update new ubuntu partition as bootable
    • Find and select your old Ubuntu partition to highlight the partition
    • Click the «Settings» gear button and select «Edit Mount Options»
    • Uncheck «Mount at Startup» and click «OK»
    • Find and select your new Ubuntu partition to highlight the partition
    • Click the «Settings» gear button and select «Edit Mount Options»
    • Set «Automatic Mount Options» to OFF
    • Check «Mount at startup»
    • «Show in user interface» and «Require additional authorization to mount» should NOT be checked
    • Mount options should be «errors=remount-ro»
    • Mount point should be «/»
    • Click «OK»
    • Reboot you machine again
    • On booting, make sure new partition’s grub menu is displayed as.
    • Finally, once rebooted successfully on new Ubuntu partition.
    • Refresh the GRUB 2 menu
    • Make sure Ubuntu from new partition is perfectly fine before deleting the old Ubuntu partition.
    • In case to revert back to old Ubuntu partition, all you need to do is restore the backed-up MBR image.

    Источник

    Читайте также:  Open windows installer package
    Оцените статью