Logo

dev-resources.site

for different kinds of informations.

Shifting Linux Filesystem From One SSD To Another

Published at
8/8/2023
Categories
linux
archlinux
ubuntu
admin
Author
soumikchakrab11
Categories
4 categories in total
linux
open
archlinux
open
ubuntu
open
admin
open
Author
15 person written this
soumikchakrab11
open
Shifting Linux Filesystem From One SSD To Another

Storyline

I use my gaming laptop as a daily driver for streaming and coding since I shifted to a new city. The base storage of the laptop is a 128G ssd in which I have a running archlinux installation with EFI boot partition and Linux filesystem partition. Now I wanted to play games on Lutris but my root partition only being 128G I need more space for more games.
I bought a 500G ssd and an external M.2 to USB adapter so that I can move my installation there.

Execution

First we need to create a similar partition table in the new ssd. Lets say when we connected the ssd using the external M.2 USB adapter its being detected as /dev/sdc. Check the device from the following command.

sudo fdisk -l
Enter fullscreen mode Exit fullscreen mode

Lets say our root file system is on device

/dev/nvme0n1, check the partition table against /dev/nvme0n1 by using the same command as above

sudo fdisk -l
Enter fullscreen mode Exit fullscreen mode

Image description
In my case I have two partitions against nvme0n1

nvme0n1p1 300M EFI System
nvme0n1p2 118.9G Linux filesystem

Now I will try to replicate a similar file system to /dev/sdc

sudo fdisk /dev/sdc
# now press m from help
Enter fullscreen mode Exit fullscreen mode

Image description

  • press g to create a new gpt partition table
  • press n to create the first partition
  • press enter to accept the default starting sector
  • then enter +300M to create a partition with ending sector allowing a 300MB partition

Image description

  • press t to change the partition type
  • press L to list all existing partition numbers and choose the number listed against the EFI System otherwise the default would be linux filesystem

Image description

  • In my case EFI System is listed against 1 so I enter 1 as input and press enter

Image description

After the partitions has been created we can replicate data from one partition to another using dd command

# copy the EFI System data
sudo dd if=/dev/nvme0n1p1 of=/dev/sdc1

# copy the linux filesystem data
sudo dd if=/dev/nvme0n1p2 of=/dev/sdc2
Enter fullscreen mode Exit fullscreen mode
  • Now use we need to resize the dd filesystem of sdc2 to allow the whole ssd space
sudo resize2fs /dev/sdc2
Enter fullscreen mode Exit fullscreen mode

We are not done yet we still need to refresh the boot partition grub settings against the new storage in which we replicated the file system,

  • First create a linux bootable live usb, in my case I am using ubuntu.
  • Replace the ssd with the new ssd and bootup the system using the live usb created.
  • Now we need to manually mount the partitions before we can update grub
  • First we mount the linux file system partition
# first we mount the linux file system
sudo mount /dev/nvme0n1p2 /mnt

# then we mount the EFI partition
sudo mount /dev/nvme0n1p1 /mnt/boot/efi

# then we bind mount before performing chroot
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys

# now we perform the chroot command
sudo chroot /mnt

# now we perform the grub install and grub update commands
grub-install
Enter fullscreen mode Exit fullscreen mode
  • Now we are done. Reboot the system and boot from the storage device itself the operating system should boot up fine
admin Article's
30 articles in total
Favicon
You Won't Believe What This Salesforce Admin Training Can Do!
Favicon
5 Key Errors That Can Cost You the Salesforce Admin Exam
Favicon
Introducing Flashboard: Instant Admin Panels for PostgreSQL
Favicon
Text Editor
Favicon
Backpex - a highly customizable admin panel for Phoenix LiveView applications
Favicon
Navigating Your Salesforce Journey: Choosing Between Admin and Developer Paths
Favicon
Top 5 Php Frameworks to be included in the Best of 2025 List
Favicon
Vue-extendable Tailwind admin panel
Favicon
GWS Admin Tips #1 - Automate work through csv
Favicon
Free Bootstrap 5 Admin Template - Ranger
Favicon
Goodbye SSH: Discover Stalwart's Web-Based Admin Interface
Favicon
Building a Full-Fledged Application Using Only Django Admin
Favicon
Better monitoring of Traces with Grafana Tempo
Favicon
From Darkness to Light Managing Linux Servers with Web UI
Favicon
Pimcore Demo installed locally but can not log into Admin using the credentials set at the time of installation
Favicon
50 Bootstrap 5 Admin Dashboard Templates 2024.
Favicon
Shifting Linux Filesystem From One SSD To Another
Favicon
Need an advice about dashboard creating
Favicon
Permission/Roles Voyager Laravel
Favicon
Need help with the following error…!
Favicon
How to Become a Salesforce Administrator in Easy Steps?
Favicon
15+ Free Angular Dashboard Templates of 2022
Favicon
Install Mac Apps without admin rights
Favicon
Build an Admin Panel Fast with Rails7 and Infold
Favicon
The Admin Framework for Minimalist
Favicon
WHY HTML DEVELOPERS USE BOOTSTRAP 5 ADMIN TEMPLATES TO MAKE DEVELOPMENT FASTER
Favicon
We added a few new job categories
Favicon
10 Best Angular 14 Admin Templates in 2022
Favicon
Admin-panel testing
Favicon
Sync folders using diff + awk

Featured ones: