- Migrate installation to new hardware
- Contents
- Adapt to new hardware
- Hard drive vs. SSD
- CPU vendor
- GPU vendor
- UEFI vs. MBR boot code booting
- Bottom to top
- On the old system
- List of installed packages
- pacman cache
- On the new system
- Installation guide first half
- Copy pacman cache
- Installation guide second half
- Install previously installed software
- Top to bottom
- Clean up the old system
- Copy the system to a new drive
- Disk cloning
- File copying
- Transport options
- Update fstab
- Reinstall the boot loader
- Regenerate kernel image
- Reconfigure audio
- Reconfigure network
- Vmware Linux Guest Add a New Hard Disk Without Rebooting Guest
- Step # 1: Add a New Disk To Vm Guest
- Step # 2: Rescan the SCSI Bus to Add a SCSI Device Without rebooting the VM
- How Do I Delete a Single Device Called /dev/sdc?
- How Do I Add a Single Device Called /dev/sdc?
- Step #3: Format a New Disk
- Step #4: Create a Mount Point And Update /etc/fstab
- Optional Task: Label the partition
- How to Add a New Disk to an Existing Linux Server
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Related Posts
- 32 thoughts on “How to Add a New Disk to an Existing Linux Server”
- Got something to say? Join the discussion. Cancel reply
Migrate installation to new hardware
This article discusses the steps required for moving an Arch Linux system to new hardware. The goal is to achieve the same ArchLinux installation, in terms of the installed software and configuration that is independent of the hardware.
There are two different approaches to migrating an installation:
- Bottom to top: Install a fresh Arch Linux system on the new hardware, afterwards restore the installed packages and configuration files, e.g. as described in dotfiles.
- Top to bottom: Clone the old harddrive to the new harddrive, or place the old harddrive into the new system; modify configuration files where necessary.
The top to bottom approach gives a more exact reproduction of the original system than the bottom to top approach.
Contents
Adapt to new hardware
Before you begin, research aspects of the new hardware and make a list of differences. Common differences are
Hard drive vs. SSD
See the article SSD.
CPU vendor
If you switch the CPU, to a CPU from another vendor (e.g. Intel to AMD), change the Microcode configuration.
GPU vendor
If you changed the GPU to a GPU from another vendor (e.g. from Amd to NVIDIA) change the graphics driver.
UEFI vs. MBR boot code booting
If you switch to a more recent mainboard with UEFI, it might be preferable or required to switch from «MBR boot code» booting to UEFI booting. In this case a new EFI system partition is needed.
Bottom to top
On the old system
We define here a minimal configuration that carries over from the old to the new system which differentiates this approach from the Installation guide. Think about the configuration files from /etc and dotfiles in /home that you want to copy to the new system, as well as user data files. If you will not have access to the old system from the new system then backup up all the files that you want to copy over.
List of installed packages
gives you a nice list of explicitly installed packages from the repositories and from the AUR. Include it in your backup if you make one.
You may also use the following script to give you a better overview of the binaries and libraries installed unbeknownst to pacman (e. g. installed via Steam, Desura or using their own install methods):
pacman cache
Consider backing up /var/cache/pacman/pkg/ if you do not change architectures (for example from x86 to x86_64).
On the new system
Installation guide first half
For basics about installing a new system, refer to the Installation guide. Follow the first half of the installation guide up to but excluding the pacstrap command.
Copy pacman cache
Copy the pacman cache found at /var/cache/pacman/pkg/ from the old to the new system, or from the backup to the new system.
Installation guide second half
Continue with the installation guide from, and including the pacstrap command, up to the end, but do not reboot. Do not skip the pacstrap command as it does additional work besides the installation of packages.
Install previously installed software
Edit pkglist.txt (and pkglist_aur.txt) and remove drivers that are not needed on the new system. Then install any other previously installed software with
Top to bottom
There are two options for the Top to Bottom approach, you can either keep the drive where the system is already installed, and modify its contents, or you can copy the system to a new drive. If you keep the drive, and modify it, then place it back into the old system, the modifications will likely prevent the old system from booting.
Clean up the old system
It is also worth to clean up your system before cloning it, as described in System maintenance#Clean the filesystem. Make sure that the old system is still working as expected after the cleanup before moving on.
Copy the system to a new drive
There are two fundamental methods for copying the system to a new drive, disk cloning and file copying.
Disk cloning
It is required to use a live linux system rather than the old Arch Linux system; for example you could use the Arch Linux USB flash installation media. The partition layout and filesystems of the old system will be reproduced.
File copying
- Create new partitions and filesystems on the new drive. You can use the opportunity to chose a different partition layout and/or filesystems than before.
- For each filesystem, copy the files from the old to the new drive, using rsync or other tools that preserve permissions, attributes, etc., see rsync#Full system backup, rsync#File system cloning for further details.
Transport options
There are many different methods for how to transport the data between the two drives:
- Connect origin and destination HDDs to the same computer, either the old or the new one. Data link: old HDD -> computer -> new HDD.
- Make use of temporary storage devices like external HDDs, or cloud backups. Data link: old HDD -> old computer -> storage -> new computer -> new HDD. For an overview see the article System backup.
- Transfer data over network, for example with rsync. Data link: old HDD -> old computer -> network -> new computer -> new HDD.
For the first two options, consider that you might need adapters to connect the HDDs (PATA->SATA, USB-HDD-Cases, etc.), and choose a connection that is sufficiently fast.
The last two options require you to use a live linux system on the new computer, as it is not possible to boot from the new hard drive at this point.
Update fstab
If you are using an Arch Linux Installation Image, mount the new root partition to /mnt , and any other partitions required like you would in a normal install (see Installation guide#Mount the file systems).
Insert an arbitrary comment such as #end of old fstab at the end of your /mnt/etc/fstab . Generate a new fstab file as indicated on Installation guide#Fstab, appending it to the current fstab file. In general, always review the fstab file created by genfstab. In this case, check the older fstab entries before the comment, if they are outdated or duplicates then delete them, and if the old entries remain useful then keep them. For example, mount entries for network drives can be kept. In general it is recommended to use Persistent block device naming.
Reinstall the boot loader
You might need to reinstall and/or reconfigure the boot loader for the following reasons:
- Different disks, partition layout, or filesystem
- Adding UEFI boot entries into the new mainboard NVRAM
- Migration from «MBR boot code» booting to UEFI booting
- Migration from USB to SATA/NVMe
- Updating the kernel commandline
- In case of a different GPU, update the framebuffer mode
- Update the Microcode initramfs image
If you are using a Arch Linux live environment, then before reinstalling the boot loader, change root into the new system:
Refer to the article on your boot loader for instructions on how to (re)install it.
Regenerate kernel image
It is recommended to regenerate the initramfs image with mkinitcpio, although initially the fallback initramfs image may work.
Reconfigure audio
- alsamixer volume
- save settings
Reconfigure network
If the old installation and the migrated installation shall coexist in the same network, set a new hostname with hostnamectl.
Also consider configuration changes that are required after a change in hostname:
- /etc/hosts
- other apps using hostname: synergy, nut (network ups tools)
- grep -Ri ‘hostname’ /etc (as the root user)should give some hints on the files to be updated
The network interface names may change when using dhcpcd with named network interfaces.
- Running dmesg | grep ‘renamed from eth’ as root might help to find the new interface name
- remove old: disable dhcpcd@enpXs0.service
- activate new: enable dhcpcd@enpXs0.service
Источник
Vmware Linux Guest Add a New Hard Disk Without Rebooting Guest
A s a system admin, I need to use additional hard drives for to provide more storage space or to separate system data from user data. This procedure, adding physical block devices to virtualized guests, describes how to add a hard drive on the host to a virtualized guest using VMWare software running Linux as guest.
It is possible to add or remove a SCSI device explicitly, or to re-scan an entire SCSI bus without rebooting a running Linux VM guest. This how to is tested under Vmware Server and Vmware Workstation v6.0 (but should work with older version too). All instructions are tested on RHEL, Fedora, CentOS and Ubuntu Linux guest / hosts operating systems.
Step # 1: Add a New Disk To Vm Guest
First, you need to add hard disk by visiting vmware hardware settings menu.
Click on VM > Settings
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Fig.01: Vmware Virtual Machine Settings
Alternatively you can press CTRL + D to bring settings dialog box.
Click on Add+ to add new hardware to guest:
Fig.02: VMWare adding a new hardware
Select hardware type Hard disk and click on Next
Fig.03 VMware Adding a new disk wizard
Select create a new virtual disk and click on Next
Fig.04: Vmware Wizard Disk
Set virtual disk type to SCSI and click on Next
Fig.05: Vmware Virtual Disk
Set maximum disk size as per your requirements and click on Next
Fig.06: Finalizing Disk Virtual Addition
Finally, set file location and click on Finish.
Step # 2: Rescan the SCSI Bus to Add a SCSI Device Without rebooting the VM
A rescan can be issued by typing the following command:
echo «- — -» > /sys/class/scsi_host/ host# /scan
fdisk -l
tail -f /var/log/message
Sample outputs:
Fig.01:Linux Vmware Rescan New Scsi Disk Without Reboot
Now type the following to send a rescan request:
echo «- — -» > /sys/class/scsi_host/ host0 /scan
fdisk -l
tail -f /var/log/message
Sample Outputs:
How Do I Delete a Single Device Called /dev/sdc?
In addition to re-scanning the entire bus, a specific device can be added or existing device deleted using the following command:
# echo 1 > /sys/block/ devName /device/delete
# echo 1 > /sys/block/ sdc /device/delete
How Do I Add a Single Device Called /dev/sdc?
To add a single device explicitly, use the following syntax:
For e.g. add /dev/sdc with host # 0, bus # 0, target # 2, and LUN # 0, enter:
# echo «scsi add-single-device 0 0 2 0″>/proc/scsi/scsi
# fdisk -l
# cat /proc/scsi/scsi
Sample Outputs:
Step #3: Format a New Disk
Now, you can create partition using fdisk and format it using mkfs.ext3 command:
# fdisk /dev/sdc
### [if you want ext3 fs] ###
# mkfs.ext3 /dev/sdc3
### [if you want ext4 fs] ###
# mkfs.ext4 /dev/sdc3
Step #4: Create a Mount Point And Update /etc/fstab
# mkdir /disk3
Open /etc/fstab file, enter:
# vi /etc/fstab
Append as follows:
Save and close the file.
Optional Task: Label the partition
You can label the partition using e2label command. For example, if you want to label the new partition /backupDisk, enter
# e2label /dev/sdc1 /backupDisk
See “how%20to%20label%20a%20Linux%20partition%E2%80%9D%20for%20more%20info.
Источник
How to Add a New Disk to an Existing Linux Server
As system administrators, we would have got requirements wherein we need to configure raw hard disks to the existing servers as part of upgrading server capacity or sometimes disk replacement in case of disk failure.
In this article, I will take you through the steps by which we can add the new raw hard disk to an existing Linux server such as RHEL/CentOS or Debian/Ubuntu.
Important: Please note that the purpose of this article is to show only how to create a new partition and doesn’t include partition extension or any other switches.
I am using fdisk utility to do this configuration.
I have added a hard disk of 20GB capacity to be mounted as a /data partition.
fdisk is a command line utility to view and manage hard disks and partitions on Linux systems.
This will list the current partitions and configurations.
Find Linux Partition Details
After attaching the hard disk of 20GB capacity, the fdisk -l will give the below output.
Find New Partition Details
New disk added is shown as /dev/xvdc . If we are adding physical disk it will show as /dev/sda based of the disk type. Here I used a virtual disk.
To partition a particular hard disk, for example /dev/xvdc.
Commonly used fdisk commands.
- n – Create partition
- p – print partition table
- d – delete a partition
- q – exit without saving the changes
- w – write the changes and exit.
Here since we are creating a partition use n option.
Create New Partition in Linux
Create either primary/extended partitions. By default we can have upto 4 primary partitions.
Create Primary Partition
Give the partition number as desired. Recommended to go for the default value 1 .
Assign a Partition Number
Give the value of the first sector. If it is a new disk, always select default value. If you are creating a second partition on the same disk, we need to add 1 to the last sector of the previous partition.
Assign Sector to Partition
Give the value of the last sector or the partition size. Always recommended to give the size of the partition. Always prefix + to avoid value out of range error.
Assign Partition Size
Save the changes and exit.
Save Partition Changes
Now format the disk with mkfs command.
Format New Partition
Once formatting has been completed, now mount the partition as shown below.
Make an entry in /etc/fstab file for permanent mount at boot time.
Conclusion
Now you know how to partition a raw disk using fdisk command and mount the same.
We need to be extra cautious while working with the partitions especially when you are editing the configured disks. Please share your feedback and suggestions.
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.
Related Posts
32 thoughts on “How to Add a New Disk to an Existing Linux Server”
I will suggest using UUID to mount devices. This gives some hardware independence, especially when working on a cloud where you can add and move devices as needed.
Use the uuid corresponding to the device and drive name of your convenience.
If I create a /home folder on the second drive, will it merge with the /home folder on the first drive? Can not be afraid of data loss of the first disk?
It will not merge the old /home folder, instead, it will replace it.
What I would do is:
- make a good backup of your server.
- sudo su (or login as root).
- mount the new drive (with the correct fstab entry: UUID=[drive uuid] /home_new ext4 defaults 0 0) to /home_new.
- sync the old home folder to the new home folder: rsync -av /home/ /home_new/.
- rename the old home folder: mv /home /home_old.
- change the fstab entry to mount the new drive to /home ( UUID=[drive uuid] /home ext4 defaults 0 0).
- Reboot your server. Now your new drive is mounted at /home with all of the original home contents, and your old home folder is accessible at /home_old.
Once you are comfortable, delete the old home folder.
If you run into problems, login as root, unmount /home, comment out or remove the fstab entry for the new drive, rename /home_old to /home and reboot.
I have a problem using Ubuntu. I have installed two hard drives one 128GB SSD and the other is 500 HD. On by default, I set 128 as a boot like using window and ubuntu at a time.
I have a problem there is when I open window in dual boot mode all partition work normal and good but when I open ubuntu my 500 Gb disk cannot show on ubuntu platform what I happen.
my all data exist on 500gb hard and I cannot see in ubuntu please guide some tricks
I need to add another hard disk in rhel7 system and wanted to create a ‘sdb’ partition. May I know how to create it?
Follow the same procedure as explained in this article, for adding new disk to an existing RHEL 7 system..
Thank you Ravi Saive
I need to add graphically not a command line mode…..
In graphical mode how to add the hard disk…
I think you can do it by using any graphical disk management utility like Gparted or any other, that you need to find out..
You added 20 Gb Hard disk but in fdisk it is showing 21.5 GB. HOW??
Thanks Lakshmi! It’s very helpful!
Thanks Lakshmi. It worked well for my RHEL VM.
Thanks — I was able to follow this guide and get my drive installed with no headaches at all!
It might be useful to update with instructions to change the owner of the newly assigned drive. In Ubuntu 16.04, my freshly installed drive belonged to the user `root` and the group `root`. I just had to run `sudo chown : /dev/sda1` (in Ubuntu it seems both name and group are your login name) to get write access to the drive.
In your /etc/fstab consider using the UUID instead of the automatically assigned /dev/***.
UUID can be found using blkid.
Hi, before the command.
you should add: mkdir /data (if there is no /data)
Got something to say? Join the discussion. Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Источник