Moving root partition to another drive
Hi . Got a bit of a problem i need to move the root partition to another drive my own fault i did not make it big enough to start with but i cant face a complete rebuild of the system i have several 1Tb drives lurking but how do i switch things to a new drive . I remember doing that many many years ago but cant remember how now any help out there would be greatfull Thanks Pete
Best option would be to boot from USB drive so that the partitions that should be moved are not in use. Then you could either move the partitions using "dd" or move the data using "rsync". Once the root partition is moved follow the Arch install guide to install the boot loader on the new drive (arch-chroot, grub-install, etc…). Am 27.10.22 um 15:34 schrieb pete:
Hi .
Got a bit of a problem i need to move the root partition to another drive my own fault i did not make it big enough to start with but i cant face a complete rebuild of the system i have several 1Tb drives lurking but how do i switch things to a new drive .
I remember doing that many many years ago but cant remember how now any help out there would be greatfull
Thanks
Pete
You may have multiple options/avenues to achieve this depending on which filesystem and partitioning techniques you implemented. But before proceeding, have you tried clearing pacman and Aur caches, removed orphans, untracked or lost files, etc? And here is information aligned with "uwe's" feedback . https://wiki.archlinux.org/title/System_backup Sent from ProtonMail mobile -------- Mensaje original -------- El 27 oct 2022 15:37, Uwe Sauter escribió:
Best option would be to boot from USB drive so that the partitions that should be moved are not in use. Then you could either move the partitions using "dd" or move the data using "rsync". Once the root partition is moved follow the Arch install guide to install the boot loader on the new drive (arch-chroot, grub-install, etc…). Am 27.10.22 um 15:34 schrieb pete: > Hi . > > Got a bit of a problem i need to move the root partition to another drive my > own fault i did not make it big enough to start with but i cant face a > complete rebuild of the system i have several 1Tb drives lurking but how do > i switch things to a new drive . > > I remember doing that many many years ago but cant remember how now any help > out there would be greatfull > > Thanks > > Pete
Got a bit of a problem i need to move the root partition to another drive my own fault i did not make it big enough to start with but i cant face a complete rebuild of the system i have several 1Tb drives lurking but how do i switch things to a new drive . The easiest and safest way is to create a fresh partition of at least the same size on the new drive, create an empty file system, mount both file systems (old and new), and rsync data from old to new. Then unmount the new partition. From Live ISO of course. This way you do not need to care about partition size and also gain a bit of a cleanup in file system’s structures.
The alternative way is to simply invoke: `cp /dev/old_disk /dev/new_disk` (or `pv -ctrab /dev/old_disk >/dev/new_disk` if you care about the progress bar). Preferably followed by `blockdef --flushbufs /dev/new_disk` to minimize the risk of data not being synced to medium on system shutdown due to some error.⁽¹⁾ This will blindly copy *all* the partitions. The drawback is that — if the target drive is larger — the partition will not use all available space. You will have to resize both the partition and the file system afterwards, which is a more risky move. So the previous method is something I find better. Finally, install the bootloader and adjust “/etc/fstab” to refer to the new partition (if needed). ____ ⁽¹⁾ Very unlikely. But if that happens, you will not learn about it until it’s probably too late.
1. Format the the new drive with the wanted file system. 2. Restart the computer and boot a live Linux from DVD, USB or what ever media you prefer. 3. Mount the old partition, mount the new partition. 4. Open a terminal. 5. Become root by running $ sudo -i 5. Copy the root directory by running # cp -ai /mnt/old/* /mnt/new/ Usage of the * is only ok, if the root directory /mnt/old/ doesn't contain hidden directories or files. 5. Verify the copy by running # diff -r --no-dereference /mnt/old/ /mnt/new/ 6. Install the bootloader and/or update the bootloaders configuration. How to do this depends on your setup and the used bootloader. I for example use syslinux for a Linux multi-boot machine, but without chainloading. IOW what bootloader are you using? Does this particular root partition contain the bootloader config or does e.g. another Linux install provide the bootloader config? Etc. pp.? Regards, Ralf
On Thu, 27 Oct 2022 16:02:17 +0200 Ralf Mardorf <ralf-mardorf@riseup.net> wrote:
1. Format the the new drive with the wanted file system. 2. Restart the computer and boot a live Linux from DVD, USB or what ever media you prefer. 3. Mount the old partition, mount the new partition. 4. Open a terminal. 5. Become root by running
$ sudo -i
5. Copy the root directory by running
# cp -ai /mnt/old/* /mnt/new/
Usage of the * is only ok, if the root directory /mnt/old/ doesn't contain hidden directories or files.
5. Verify the copy by running
# diff -r --no-dereference /mnt/old/ /mnt/new/
6. Install the bootloader and/or update the bootloaders configuration.
How to do this depends on your setup and the used bootloader. I for example use syslinux for a Linux multi-boot machine, but without chainloading.
IOW what bootloader are you using? Does this particular root partition contain the bootloader config or does e.g. another Linux install provide the bootloader config? Etc. pp.?
Regards, Ralf
Hi Ralf Thanks for that i am also using syslinux for boot i fell out with grub basically the root partition is a result of my cockup i have several 1Tb drives i was going to use one of those as the root partition the entire drive Just wish i had thought a bit more about it when i set the machine up several years ago now you learn , I will have to study some . once again thanks Pete
On Thu, Oct 27, 2022 at 18:32:42 +0100, pete wrote:
Thanks for that i am also using syslinux for boot i fell out with grub basically the root partition is a result of my cockup i have several 1Tb drives i was going to use one of those as the root partition the entire drive
You may want to look into LVM (Logical Volume Manager, check the wiki), it will give you a lot more flexibility to grow and/or move stuff around later. Geert
On Thu, 27 Oct 2022 16:02:17 +0200 Ralf Mardorf <ralf-mardorf@riseup.net> wrote:
1. Format the the new drive with the wanted file system. 2. Restart the computer and boot a live Linux from DVD, USB or what ever media you prefer. 3. Mount the old partition, mount the new partition. 4. Open a terminal. 5. Become root by running
$ sudo -i
5. Copy the root directory by running
# cp -ai /mnt/old/* /mnt/new/
Usage of the * is only ok, if the root directory /mnt/old/ doesn't contain hidden directories or files.
5. Verify the copy by running
# diff -r --no-dereference /mnt/old/ /mnt/new/
6. Install the bootloader and/or update the bootloaders configuration.
How to do this depends on your setup and the used bootloader. I for example use syslinux for a Linux multi-boot machine, but without chainloading.
IOW what bootloader are you using? Does this particular root partition contain the bootloader config or does e.g. another Linux install provide the bootloader config? Etc. pp.?
Regards, Ralf
Hi Ralf thanks for you help i wound up using this that i found "https://browse-tutorials.com/tutorial/arch-linux-move-root-partition-hdd-ssd" Obviously drives changed to suit one thing i did not do was the /var bit and ignored from line 26 down . System is now working again with space on the drive no more complaints about not enough space on device Cheers Pete
participants (6)
-
Geert Hendrickx
-
Jedisocialist
-
mpan
-
pete
-
Ralf Mardorf
-
Uwe Sauter